cts(wifi): Fix WifiManager.testWifiManagerActions
The current assertion in the test is incorrect. When we disable wifi, we should expect scans to pass if location scans are turned on, else scans should fail. Also, reset mScanResults in startScan so that it doesn't contain stale scan results. Bug: 38224452 Test: Run the cts test with both location scan turned on & off. `cts-tradefed run cts-dev --module CtsNetTestCases -t android.net.wifi.cts.WifiManagerTest#testWifiManagerActions` Change-Id: I27bc88ca4883d9233da9e911397192a1eef4422b
This commit is contained in:
@@ -188,6 +188,7 @@ public class WifiManagerTest extends AndroidTestCase {
|
||||
private void startScan() throws Exception {
|
||||
synchronized (mMySync) {
|
||||
mMySync.expectedState = STATE_SCANNING;
|
||||
mScanResults = null;
|
||||
assertTrue(mWifiManager.startScan());
|
||||
long timeout = System.currentTimeMillis() + TIMEOUT_MSEC;
|
||||
while (System.currentTimeMillis() < timeout && mMySync.expectedState == STATE_SCANNING)
|
||||
@@ -239,10 +240,17 @@ public class WifiManagerTest extends AndroidTestCase {
|
||||
assertTrue(mWifiManager.reconnect());
|
||||
assertTrue(mWifiManager.reassociate());
|
||||
assertTrue(mWifiManager.disconnect());
|
||||
startScan();
|
||||
setWifiEnabled(false);
|
||||
startScan();
|
||||
Thread.sleep(DURATION);
|
||||
assertTrue(mWifiManager.isScanAlwaysAvailable());
|
||||
if (mWifiManager.isScanAlwaysAvailable()) {
|
||||
// Make sure at least one AP is found.
|
||||
assertNotNull("mScanResult should not be null!", mScanResults);
|
||||
assertFalse("empty scan results!", mScanResults.isEmpty());
|
||||
} else {
|
||||
// Make sure no scan results are available.
|
||||
assertNull("mScanResult should be null!", mScanResults);
|
||||
}
|
||||
final String TAG = "Test";
|
||||
assertNotNull(mWifiManager.createWifiLock(TAG));
|
||||
assertNotNull(mWifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL, TAG));
|
||||
|
||||
Reference in New Issue
Block a user