Merge "WifiManagerTest: allow for multiple modes" into oreo-mr1-cts-dev
am: 354de98f9a Change-Id: I4b8dd8fbb8e4765cba4e95e521f528f6dd752df3
This commit is contained in:
@@ -833,10 +833,9 @@ public class WifiManagerTest extends AndroidTestCase {
|
|||||||
|
|
||||||
TestLocalOnlyHotspotCallback callback = startLocalOnlyHotspot();
|
TestLocalOnlyHotspotCallback callback = startLocalOnlyHotspot();
|
||||||
|
|
||||||
// at this point, wifi should be off
|
|
||||||
assertFalse(mWifiManager.isWifiEnabled());
|
|
||||||
|
|
||||||
stopLocalOnlyHotspot(callback, wifiEnabled);
|
stopLocalOnlyHotspot(callback, wifiEnabled);
|
||||||
|
|
||||||
|
// wifi should either stay on, or come back on
|
||||||
assertEquals(wifiEnabled, mWifiManager.isWifiEnabled());
|
assertEquals(wifiEnabled, mWifiManager.isWifiEnabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -848,7 +847,7 @@ public class WifiManagerTest extends AndroidTestCase {
|
|||||||
* tethering is started.
|
* tethering is started.
|
||||||
* Note: Location mode must be enabled for this test.
|
* Note: Location mode must be enabled for this test.
|
||||||
*/
|
*/
|
||||||
public void testSetWifiEnabledByAppDoesNotStopHotspot() {
|
public void testSetWifiEnabledByAppDoesNotStopHotspot() throws Exception {
|
||||||
if (!WifiFeature.isWifiSupported(getContext())) {
|
if (!WifiFeature.isWifiSupported(getContext())) {
|
||||||
// skip the test if WiFi is not supported
|
// skip the test if WiFi is not supported
|
||||||
return;
|
return;
|
||||||
@@ -860,15 +859,18 @@ public class WifiManagerTest extends AndroidTestCase {
|
|||||||
|
|
||||||
boolean wifiEnabled = mWifiManager.isWifiEnabled();
|
boolean wifiEnabled = mWifiManager.isWifiEnabled();
|
||||||
|
|
||||||
|
if (wifiEnabled) {
|
||||||
|
// disable wifi so we have something to turn on (some devices may be able to run
|
||||||
|
// simultaneous modes)
|
||||||
|
setWifiEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
TestLocalOnlyHotspotCallback callback = startLocalOnlyHotspot();
|
TestLocalOnlyHotspotCallback callback = startLocalOnlyHotspot();
|
||||||
// at this point, wifi should be off
|
|
||||||
assertFalse(mWifiManager.isWifiEnabled());
|
|
||||||
|
|
||||||
// now we should fail to turn on wifi
|
// now we should fail to turn on wifi
|
||||||
assertFalse(mWifiManager.setWifiEnabled(true));
|
assertFalse(mWifiManager.setWifiEnabled(true));
|
||||||
|
|
||||||
stopLocalOnlyHotspot(callback, wifiEnabled);
|
stopLocalOnlyHotspot(callback, wifiEnabled);
|
||||||
assertEquals(wifiEnabled, mWifiManager.isWifiEnabled());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -892,9 +894,6 @@ public class WifiManagerTest extends AndroidTestCase {
|
|||||||
|
|
||||||
TestLocalOnlyHotspotCallback callback = startLocalOnlyHotspot();
|
TestLocalOnlyHotspotCallback callback = startLocalOnlyHotspot();
|
||||||
|
|
||||||
// at this point, wifi should be off
|
|
||||||
assertFalse(mWifiManager.isWifiEnabled());
|
|
||||||
|
|
||||||
// now make a second request - this should fail.
|
// now make a second request - this should fail.
|
||||||
TestLocalOnlyHotspotCallback callback2 = new TestLocalOnlyHotspotCallback(mLOHSLock);
|
TestLocalOnlyHotspotCallback callback2 = new TestLocalOnlyHotspotCallback(mLOHSLock);
|
||||||
try {
|
try {
|
||||||
@@ -903,9 +902,12 @@ public class WifiManagerTest extends AndroidTestCase {
|
|||||||
Log.d(TAG, "Caught the IllegalStateException we expected: called startLOHS twice");
|
Log.d(TAG, "Caught the IllegalStateException we expected: called startLOHS twice");
|
||||||
caughtException = true;
|
caughtException = true;
|
||||||
}
|
}
|
||||||
|
if (!caughtException) {
|
||||||
|
// second start did not fail, should clean up the hotspot.
|
||||||
|
stopLocalOnlyHotspot(callback2, wifiEnabled);
|
||||||
|
}
|
||||||
assertTrue(caughtException);
|
assertTrue(caughtException);
|
||||||
|
|
||||||
stopLocalOnlyHotspot(callback, wifiEnabled);
|
stopLocalOnlyHotspot(callback, wifiEnabled);
|
||||||
assertEquals(wifiEnabled, mWifiManager.isWifiEnabled());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user