summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRandy Pan <zpan@google.com>2016-06-24 10:22:33 -0700
committerRandy Pan <zpan@google.com>2016-06-28 15:09:38 -0700
commitcb26f07ae9c558f8c6136c951a7f633d0ccfe79f (patch)
tree325a09eac50fdc1afa11e774b828368edd8e356f /tests
parent450fee26a21eb56d536df147d3e88d3549f807c0 (diff)
downloadandroid_frameworks_opt_net_wifi-cb26f07ae9c558f8c6136c951a7f633d0ccfe79f.tar.gz
android_frameworks_opt_net_wifi-cb26f07ae9c558f8c6136c951a7f633d0ccfe79f.tar.bz2
android_frameworks_opt_net_wifi-cb26f07ae9c558f8c6136c951a7f633d0ccfe79f.zip
WCM: Listen to all single scan results
In addition to single scan results initiated by WCM itself, it listens to the single scans requested by other modules as well. This gives us more opportunities to connect to a network. We don't check if a single scan is scheduled by WCM watchdog any more since we now listen to all single scan results. Bug: 29606099 Tests: Wifi Framework Unit Test & manual tests Change-Id: I2a1df0337005878f415eccc425600267434c2e54
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java
index d8209de43..022997d67 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java
@@ -17,6 +17,7 @@
package com.android.server.wifi;
import static com.android.server.wifi.WifiConfigurationTestUtil.generateWifiConfig;
+import static com.android.server.wifi.WifiStateMachine.WIFI_WORK_SOURCE;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
@@ -45,6 +46,7 @@ import com.android.server.wifi.MockAnswerUtil.AnswerWithArguments;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.ArgumentCaptor;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
@@ -128,6 +130,10 @@ public class WifiConnectivityManagerTest {
WifiScanner mockWifiScanner() {
WifiScanner scanner = mock(WifiScanner.class);
+ ArgumentCaptor<ScanListener> allSingleScanListenerCaptor =
+ ArgumentCaptor.forClass(ScanListener.class);
+
+ doNothing().when(scanner).registerScanListener(allSingleScanListenerCaptor.capture());
// dummy scan results. QNS PeriodicScanListener bulids scanDetails from
// the fullScanResult and doesn't really use results
@@ -144,6 +150,7 @@ public class WifiConnectivityManagerTest {
public void answer(ScanSettings settings, ScanListener listener,
WorkSource workSource) throws Exception {
listener.onResults(scanDatas);
+ allSingleScanListenerCaptor.getValue().onResults(scanDatas);
}}).when(scanner).startScan(anyObject(), anyObject(), anyObject());
// This unfortunately needs to be a somewhat valid scan result, otherwise
@@ -915,4 +922,26 @@ public class WifiConnectivityManagerTest {
verify(mWifiScanner, times(WifiConnectivityManager.MAX_SCAN_RESTART_ALLOWED + 1)).startScan(
anyObject(), anyObject(), anyObject());
}
+
+ /**
+ * Listen to scan results not requested by WifiConnectivityManager and
+ * act on them.
+ *
+ * Expected behavior: WifiConnectivityManager calls
+ * WifiStateMachine.autoConnectToNetwork() with the
+ * expected candidate network ID and BSSID.
+ */
+ @Test
+ public void listenToAllSingleScanResults() {
+ ScanSettings settings = new ScanSettings();
+ ScanListener scanListener = mock(ScanListener.class);
+
+ // Request a single scan outside of WifiConnectivityManager.
+ mWifiScanner.startScan(settings, scanListener, WIFI_WORK_SOURCE);
+
+ // Verify that WCM receives the scan results and initiates a connection
+ // to the network.
+ verify(mWifiStateMachine).autoConnectToNetwork(
+ CANDIDATE_NETWORK_ID, CANDIDATE_BSSID);
+ }
}