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.
This commit is contained in:
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package android.net.cts;
|
package android.net.cts;
|
||||||
|
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -31,6 +30,8 @@ import android.net.wifi.WifiManager;
|
|||||||
import android.test.AndroidTestCase;
|
import android.test.AndroidTestCase;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.android.internal.telephony.PhoneConstants;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -115,34 +116,9 @@ public class ConnectivityManagerTest extends AndroidTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testSetNetworkPreference() {
|
public void testSetNetworkPreference() {
|
||||||
// verify swtiching between two default networks - need to connectable networks though
|
// getNetworkPreference() and setNetworkPreference() are both deprecated so they do
|
||||||
// could use test and whatever the current active network is
|
// not preform any action. Verify they are at least still callable.
|
||||||
int originalPref = mCm.getNetworkPreference();
|
mCm.setNetworkPreference(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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetActiveNetworkInfo() {
|
public void testGetActiveNetworkInfo() {
|
||||||
@@ -194,13 +170,13 @@ public class ConnectivityManagerTest extends AndroidTestCase {
|
|||||||
final String invalidateFeature = "invalidateFeature";
|
final String invalidateFeature = "invalidateFeature";
|
||||||
final String mmsFeature = "enableMMS";
|
final String mmsFeature = "enableMMS";
|
||||||
final int failureCode = -1;
|
final int failureCode = -1;
|
||||||
final int wifiOnlyStartFailureCode = 3;
|
final int wifiOnlyStartFailureCode = PhoneConstants.APN_REQUEST_FAILED;
|
||||||
final int wifiOnlyStopFailureCode = 1;
|
final int wifiOnlyStopFailureCode = -1;
|
||||||
|
|
||||||
NetworkInfo ni = mCm.getNetworkInfo(TYPE_MOBILE);
|
NetworkInfo ni = mCm.getNetworkInfo(TYPE_MOBILE);
|
||||||
if (ni != null) {
|
if (ni != null) {
|
||||||
assertEquals(failureCode, mCm.startUsingNetworkFeature(TYPE_MOBILE,
|
assertEquals(PhoneConstants.APN_REQUEST_FAILED,
|
||||||
invalidateFeature));
|
mCm.startUsingNetworkFeature(TYPE_MOBILE, invalidateFeature));
|
||||||
assertEquals(failureCode, mCm.stopUsingNetworkFeature(TYPE_MOBILE,
|
assertEquals(failureCode, mCm.stopUsingNetworkFeature(TYPE_MOBILE,
|
||||||
invalidateFeature));
|
invalidateFeature));
|
||||||
} else {
|
} else {
|
||||||
@@ -212,8 +188,8 @@ public class ConnectivityManagerTest extends AndroidTestCase {
|
|||||||
|
|
||||||
ni = mCm.getNetworkInfo(TYPE_WIFI);
|
ni = mCm.getNetworkInfo(TYPE_WIFI);
|
||||||
if (ni != null) {
|
if (ni != null) {
|
||||||
// Should return failure(-1) because MMS is not supported on WIFI.
|
// Should return failure because MMS is not supported on WIFI.
|
||||||
assertEquals(failureCode, mCm.startUsingNetworkFeature(TYPE_WIFI,
|
assertEquals(PhoneConstants.APN_REQUEST_FAILED, mCm.startUsingNetworkFeature(TYPE_WIFI,
|
||||||
mmsFeature));
|
mmsFeature));
|
||||||
assertEquals(failureCode, mCm.stopUsingNetworkFeature(TYPE_WIFI,
|
assertEquals(failureCode, mCm.stopUsingNetworkFeature(TYPE_WIFI,
|
||||||
mmsFeature));
|
mmsFeature));
|
||||||
|
|||||||
Reference in New Issue
Block a user