From 67e673f04eab563809c241a8d465bcd132741581 Mon Sep 17 00:00:00 2001 From: Paul Jensen Date: Thu, 25 Sep 2014 10:07:21 -0400 Subject: [PATCH] Update CTS ConnectivityManager tests to work with L release. Removed most of getNetworkPreference() and setNetworkPreference() tests as these functions are now fully deprecated and do nothing. Just test that they are still callable. Adjust startUsingNetworkFeature() and stopUsingNetworkFeature() failure codes to match new behavior. Tested on devices with Wifi and Cellular radios, and Wifi-only. bug:17417896 bug:17354855 Change-Id: Iea8b25e399f4e5b6ec3d2101ebf520f89697c4da --- .../net/cts/ConnectivityManagerTest.java | 46 +++++-------------- 1 file changed, 11 insertions(+), 35 deletions(-) diff --git a/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java b/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java index 5656119d0f..d79ecdddb4 100644 --- a/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java +++ b/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java @@ -16,7 +16,6 @@ package android.net.cts; - import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -31,6 +30,8 @@ import android.net.wifi.WifiManager; import android.test.AndroidTestCase; import android.util.Log; +import com.android.internal.telephony.PhoneConstants; + import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -115,34 +116,9 @@ public class ConnectivityManagerTest extends AndroidTestCase { } public void testSetNetworkPreference() { - // verify swtiching between two default networks - need to connectable networks though - // could use test and whatever the current active network is - int originalPref = mCm.getNetworkPreference(); - int currentPref = originalPref; - for (int type = -1; type <= ConnectivityManager.MAX_NETWORK_TYPE+1; type++) { - mCm.setNetworkPreference(type); - NetworkConfig c = mNetworks.get(type); - boolean expectWorked = (c != null && c.isDefault()); - int totalSleep = 0; - int foundType = ConnectivityManager.TYPE_NONE; - while (totalSleep < 1000) { - try { - Thread.currentThread().sleep(100); - } catch (InterruptedException e) {} - totalSleep += 100; - foundType = mCm.getNetworkPreference(); - if (currentPref != foundType) break; - } - if (expectWorked) { - assertTrue("We should have been able to switch prefered type " + type, - foundType == type); - } else { - assertTrue("We should not have been able to switch type " + type, - foundType != type); - } - currentPref = foundType; - } - mCm.setNetworkPreference(originalPref); + // getNetworkPreference() and setNetworkPreference() are both deprecated so they do + // not preform any action. Verify they are at least still callable. + mCm.setNetworkPreference(mCm.getNetworkPreference()); } public void testGetActiveNetworkInfo() { @@ -194,13 +170,13 @@ public class ConnectivityManagerTest extends AndroidTestCase { final String invalidateFeature = "invalidateFeature"; final String mmsFeature = "enableMMS"; final int failureCode = -1; - final int wifiOnlyStartFailureCode = 3; - final int wifiOnlyStopFailureCode = 1; + final int wifiOnlyStartFailureCode = PhoneConstants.APN_REQUEST_FAILED; + final int wifiOnlyStopFailureCode = -1; NetworkInfo ni = mCm.getNetworkInfo(TYPE_MOBILE); if (ni != null) { - assertEquals(failureCode, mCm.startUsingNetworkFeature(TYPE_MOBILE, - invalidateFeature)); + assertEquals(PhoneConstants.APN_REQUEST_FAILED, + mCm.startUsingNetworkFeature(TYPE_MOBILE, invalidateFeature)); assertEquals(failureCode, mCm.stopUsingNetworkFeature(TYPE_MOBILE, invalidateFeature)); } else { @@ -212,8 +188,8 @@ public class ConnectivityManagerTest extends AndroidTestCase { ni = mCm.getNetworkInfo(TYPE_WIFI); if (ni != null) { - // Should return failure(-1) because MMS is not supported on WIFI. - assertEquals(failureCode, mCm.startUsingNetworkFeature(TYPE_WIFI, + // Should return failure because MMS is not supported on WIFI. + assertEquals(PhoneConstants.APN_REQUEST_FAILED, mCm.startUsingNetworkFeature(TYPE_WIFI, mmsFeature)); assertEquals(failureCode, mCm.stopUsingNetworkFeature(TYPE_WIFI, mmsFeature));