Merge "WifiManagerTest: allow for multiple modes" into pi-dev
am: 1f34a7fcd9 Change-Id: I0738a52e6af618c7c739a1a1ec1aa434cfd7b1d3
This commit is contained in:
@@ -874,10 +874,9 @@ public class WifiManagerTest extends AndroidTestCase {
|
||||
|
||||
TestLocalOnlyHotspotCallback callback = startLocalOnlyHotspot();
|
||||
|
||||
// at this point, wifi should be off
|
||||
assertFalse(mWifiManager.isWifiEnabled());
|
||||
|
||||
stopLocalOnlyHotspot(callback, wifiEnabled);
|
||||
|
||||
// wifi should either stay on, or come back on
|
||||
assertEquals(wifiEnabled, mWifiManager.isWifiEnabled());
|
||||
}
|
||||
|
||||
@@ -889,7 +888,7 @@ public class WifiManagerTest extends AndroidTestCase {
|
||||
* tethering is started.
|
||||
* Note: Location mode must be enabled for this test.
|
||||
*/
|
||||
public void testSetWifiEnabledByAppDoesNotStopHotspot() {
|
||||
public void testSetWifiEnabledByAppDoesNotStopHotspot() throws Exception {
|
||||
if (!WifiFeature.isWifiSupported(getContext())) {
|
||||
// skip the test if WiFi is not supported
|
||||
return;
|
||||
@@ -901,15 +900,18 @@ public class WifiManagerTest extends AndroidTestCase {
|
||||
|
||||
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();
|
||||
// at this point, wifi should be off
|
||||
assertFalse(mWifiManager.isWifiEnabled());
|
||||
|
||||
// now we should fail to turn on wifi
|
||||
assertFalse(mWifiManager.setWifiEnabled(true));
|
||||
|
||||
stopLocalOnlyHotspot(callback, wifiEnabled);
|
||||
assertEquals(wifiEnabled, mWifiManager.isWifiEnabled());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -933,9 +935,6 @@ public class WifiManagerTest extends AndroidTestCase {
|
||||
|
||||
TestLocalOnlyHotspotCallback callback = startLocalOnlyHotspot();
|
||||
|
||||
// at this point, wifi should be off
|
||||
assertFalse(mWifiManager.isWifiEnabled());
|
||||
|
||||
// now make a second request - this should fail.
|
||||
TestLocalOnlyHotspotCallback callback2 = new TestLocalOnlyHotspotCallback(mLOHSLock);
|
||||
try {
|
||||
@@ -944,9 +943,12 @@ public class WifiManagerTest extends AndroidTestCase {
|
||||
Log.d(TAG, "Caught the IllegalStateException we expected: called startLOHS twice");
|
||||
caughtException = true;
|
||||
}
|
||||
if (!caughtException) {
|
||||
// second start did not fail, should clean up the hotspot.
|
||||
stopLocalOnlyHotspot(callback2, wifiEnabled);
|
||||
}
|
||||
assertTrue(caughtException);
|
||||
|
||||
stopLocalOnlyHotspot(callback, wifiEnabled);
|
||||
assertEquals(wifiEnabled, mWifiManager.isWifiEnabled());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user