Merge "wifi: add test for tracking Passpoint AP on devices with Passpoint disabled" into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
f1cc8b82b3
@@ -20,9 +20,11 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.anyInt;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -580,4 +582,40 @@ public class WifiTrackerTest {
|
||||
mWorkerThread.quit();
|
||||
updateScores();
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that tracking a Passpoint AP on a device with Passpoint disabled doesn't cause
|
||||
* any crash.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void trackPasspointApWithPasspointDisabled() throws Exception {
|
||||
WifiTracker tracker = createMockedWifiTracker();
|
||||
|
||||
// Add a Passpoint AP to the scan results.
|
||||
List<ScanResult> results = new ArrayList<>();
|
||||
ScanResult passpointAp = new ScanResult(
|
||||
WifiSsid.createFromAsciiEncoded(SSID_1),
|
||||
BSSID_1,
|
||||
0, // hessid
|
||||
0, //anqpDomainId
|
||||
null, // osuProviders
|
||||
"", // capabilities
|
||||
RSSI_1,
|
||||
0, // frequency
|
||||
SystemClock.elapsedRealtime() * 1000 /* microsecond timestamp */);
|
||||
passpointAp.setFlag(ScanResult.FLAG_PASSPOINT_NETWORK);
|
||||
results.add(passpointAp);
|
||||
|
||||
// Update access point and verify UnsupportedOperationException is being caught for
|
||||
// call to WifiManager#getMatchingWifiConfig.
|
||||
when(mockWifiManager.getConfiguredNetworks())
|
||||
.thenReturn(new ArrayList<WifiConfiguration>());
|
||||
when(mockWifiManager.getScanResults()).thenReturn(results);
|
||||
doThrow(new UnsupportedOperationException())
|
||||
.when(mockWifiManager).getMatchingWifiConfig(any(ScanResult.class));
|
||||
tracker.forceUpdate();
|
||||
verify(mockWifiManager).getMatchingWifiConfig(any(ScanResult.class));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user