am c3486218: Merge "Update CTS ConnectivityManager tests to work with L release." into lmp-dev
* commit 'c34862184cfc47596f47088759ffac6ccb0b0b6c':
Update CTS ConnectivityManager tests to work with L release.
diff --git a/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java b/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java
index 5656119..d79ecdd 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.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 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 @@
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 @@
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));