summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2019-10-07 07:24:11 -0700
committerRoshan Pius <rpius@google.com>2019-10-09 14:23:31 -0700
commitbbaee0b899a9606f405e27e0af50ee98d2023de4 (patch)
tree09433c03758e3c6cbd8cadb3c8fcd27d772b67d5 /tests
parent0ab35f26f0da8885a5d249a678187993da425447 (diff)
WifiNetworkFactory: Send match callback on registration
If the UI registers its callback to the platform and if we already have some matching results for the request, send it immediately to the UI. Otherwise, we'll need to wait for the next scan results to present users with matches. Bug: 134712530 Test: atest com.android.server.wifi Test: Manually verified with CtsVerifier tests that the UI does not start out with a blank page (because the matched networks are already found by using the cached results). Change-Id: Ice7f89952c0a71c181ea5de58e417c02e7f2bf91
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java61
1 files changed, 49 insertions, 12 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java
index c5d401a21..ad6394c99 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java
@@ -1001,13 +1001,8 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
verifyPeriodicScans(0, PERIODIC_SCAN_INTERVAL_MS);
- ArgumentCaptor<List<ScanResult>> matchedScanResultsCaptor =
- ArgumentCaptor.forClass(List.class);
- verify(mNetworkRequestMatchCallback).onMatch(matchedScanResultsCaptor.capture());
-
- assertNotNull(matchedScanResultsCaptor.getValue());
// We expect no network match in this case.
- assertEquals(0, matchedScanResultsCaptor.getValue().size());
+ verify(mNetworkRequestMatchCallback, never()).onMatch(any());
// Don't increment metrics until we have a match
verify(mWifiMetrics, never()).incrementNetworkRequestApiMatchSizeHistogram(anyInt());
@@ -1046,13 +1041,8 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
verifyPeriodicScans(0, PERIODIC_SCAN_INTERVAL_MS);
- ArgumentCaptor<List<ScanResult>> matchedScanResultsCaptor =
- ArgumentCaptor.forClass(List.class);
- verify(mNetworkRequestMatchCallback).onMatch(matchedScanResultsCaptor.capture());
-
- assertNotNull(matchedScanResultsCaptor.getValue());
// We expect no network match in this case.
- assertEquals(0, matchedScanResultsCaptor.getValue().size());
+ verify(mNetworkRequestMatchCallback, never()).onMatch(any());
}
/**
@@ -2583,6 +2573,53 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
verify(mWifiMetrics).incrementNetworkRequestApiNumUserApprovalBypass();
}
+ /**
+ * Verify network specifier matching for a specifier containing a specific SSID match using
+ * 4 WPA_PSK scan results, each with unique SSID when the UI callback registration is delayed.
+ */
+ @Test
+ public void testNetworkSpecifierMatchSuccessUsingLiteralSsidMatchCallbackRegistrationDelayed()
+ throws Exception {
+ // Setup scan data for open networks.
+ setupScanData(SCAN_RESULT_TYPE_WPA_PSK,
+ TEST_SSID_1, TEST_SSID_2, TEST_SSID_3, TEST_SSID_4);
+
+ // Setup network specifier for open networks.
+ PatternMatcher ssidPatternMatch =
+ new PatternMatcher(TEST_SSID_1, PatternMatcher.PATTERN_LITERAL);
+ Pair<MacAddress, MacAddress> bssidPatternMatch =
+ Pair.create(MacAddress.ALL_ZEROS_ADDRESS, MacAddress.ALL_ZEROS_ADDRESS);
+ WifiConfiguration wifiConfiguration = new WifiConfiguration();
+ wifiConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
+ WifiNetworkSpecifier specifier = new WifiNetworkSpecifier(
+ ssidPatternMatch, bssidPatternMatch, wifiConfiguration, TEST_UID_1,
+ TEST_PACKAGE_NAME_1);
+
+ mNetworkRequest.networkCapabilities.setNetworkSpecifier(specifier);
+ mWifiNetworkFactory.needNetworkFor(mNetworkRequest, 0);
+
+ validateUiStartParams(true);
+
+ verifyPeriodicScans(0, PERIODIC_SCAN_INTERVAL_MS);
+
+ // Ensure we did not send any match callbacks, until the callback is registered
+ verify(mNetworkRequestMatchCallback, never()).onMatch(any());
+
+ // Register the callback & ensure we triggered the on match callback.
+ mWifiNetworkFactory.addCallback(mAppBinder, mNetworkRequestMatchCallback,
+ TEST_CALLBACK_IDENTIFIER);
+ ArgumentCaptor<List<ScanResult>> matchedScanResultsCaptor =
+ ArgumentCaptor.forClass(List.class);
+ verify(mNetworkRequestMatchCallback).onMatch(matchedScanResultsCaptor.capture());
+
+ assertNotNull(matchedScanResultsCaptor.getValue());
+ // We only expect 1 network match in this case.
+ validateScanResults(matchedScanResultsCaptor.getValue(), mTestScanDatas[0].getResults()[0]);
+
+ verify(mWifiMetrics).incrementNetworkRequestApiMatchSizeHistogram(
+ matchedScanResultsCaptor.getValue().size());
+ }
+
private void sendNetworkRequestAndSetupForConnectionStatus() throws RemoteException {
sendNetworkRequestAndSetupForConnectionStatus(TEST_SSID_1);
}