summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKai Shi <kaishi@google.com>2020-04-14 15:03:27 -0700
committerKai Shi <kaishi@google.com>2020-04-14 15:03:27 -0700
commit2693c3a8265476521c5dbb599cab444268769c5b (patch)
treeb5c6fedcffa5fff924d6feeecc31b7d75211147b /tests
parent82298418fe24c1d0d8f62ba1b79e55d168bf6351 (diff)
Check internet status for pre-scan sufficiency check
If internet status is not acceptable, don't skip screen-on scan even if RSSI is high and there is a recent network selection. Test: atest com.android.server.wifi Bug: 154040171 Change-Id: I4ffded56a7aae2740c625f25ca2158de39c79220
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java21
1 files changed, 21 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 d66f6ddb8..32e85f528 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java
@@ -1755,6 +1755,8 @@ public class WifiConnectivityManagerTest extends WifiBaseTest {
* Verify that we perform full band scan in the following two cases
* 1) Current RSSI is low, no active stream, network is insufficient
* 2) Current RSSI is high, no active stream, and a long time since last network selection
+ * 3) Current RSSI is high, no active stream, and a short time since last network selection,
+ * internet status is not acceptable
*
* Expected behavior: WifiConnectivityManager does full band scan in both cases
*/
@@ -1767,6 +1769,7 @@ public class WifiConnectivityManagerTest extends WifiBaseTest {
when(mWifiNS.isNetworkSufficient(eq(mWifiInfo))).thenReturn(false);
when(mWifiNS.hasActiveStream(eq(mWifiInfo))).thenReturn(false);
when(mWifiNS.hasSufficientLinkQuality(eq(mWifiInfo))).thenReturn(false);
+ when(mWifiNS.hasInternetOrExpectNoInternet(eq(mWifiInfo))).thenReturn(true);
final List<Integer> channelList = new ArrayList<>();
channelList.add(TEST_FREQUENCY_1);
@@ -1802,6 +1805,7 @@ public class WifiConnectivityManagerTest extends WifiBaseTest {
when(mWifiNS.isNetworkSufficient(eq(mWifiInfo))).thenReturn(true);
when(mWifiNS.hasActiveStream(eq(mWifiInfo))).thenReturn(false);
when(mWifiNS.hasSufficientLinkQuality(eq(mWifiInfo))).thenReturn(true);
+ when(mWifiNS.hasInternetOrExpectNoInternet(eq(mWifiInfo))).thenReturn(true);
when(mClock.getElapsedSinceBootMillis()).thenReturn(600_000L + 1L);
mWifiConnectivityManager.handleScreenStateChanged(true);
// Set WiFi to connected state to trigger periodic scan
@@ -1809,6 +1813,19 @@ public class WifiConnectivityManagerTest extends WifiBaseTest {
WifiConnectivityManager.WIFI_STATE_CONNECTED);
verify(mWifiScanner, times(2)).startScan(anyObject(), anyObject(), anyObject(),
anyObject());
+
+ // Verify case 3
+ when(mWifiNS.isNetworkSufficient(eq(mWifiInfo))).thenReturn(false);
+ when(mWifiNS.hasActiveStream(eq(mWifiInfo))).thenReturn(false);
+ when(mWifiNS.hasSufficientLinkQuality(eq(mWifiInfo))).thenReturn(true);
+ when(mWifiNS.hasInternetOrExpectNoInternet(eq(mWifiInfo))).thenReturn(false);
+ when(mClock.getElapsedSinceBootMillis()).thenReturn(0L);
+ mWifiConnectivityManager.handleScreenStateChanged(true);
+ // Set WiFi to connected state to trigger periodic scan
+ mWifiConnectivityManager.handleConnectionStateChanged(
+ WifiConnectivityManager.WIFI_STATE_CONNECTED);
+ verify(mWifiScanner, times(2)).startScan(anyObject(), anyObject(), anyObject(),
+ anyObject());
}
/**
@@ -1824,6 +1841,7 @@ public class WifiConnectivityManagerTest extends WifiBaseTest {
when(mWifiNS.isNetworkSufficient(eq(mWifiInfo))).thenReturn(false);
when(mWifiNS.hasActiveStream(eq(mWifiInfo))).thenReturn(true);
when(mWifiNS.hasSufficientLinkQuality(eq(mWifiInfo))).thenReturn(false);
+ when(mWifiNS.hasInternetOrExpectNoInternet(eq(mWifiInfo))).thenReturn(true);
mResources.setInteger(
R.integer.config_wifi_framework_associated_partial_scan_max_num_active_channels,
@@ -1878,6 +1896,7 @@ public class WifiConnectivityManagerTest extends WifiBaseTest {
when(mWifiNS.isNetworkSufficient(eq(mWifiInfo))).thenReturn(false);
when(mWifiNS.hasActiveStream(eq(mWifiInfo))).thenReturn(false);
when(mWifiNS.hasSufficientLinkQuality(eq(mWifiInfo))).thenReturn(true);
+ when(mWifiNS.hasInternetOrExpectNoInternet(eq(mWifiInfo))).thenReturn(true);
mResources.setInteger(
R.integer.config_wifi_framework_associated_partial_scan_max_num_active_channels,
@@ -1931,6 +1950,8 @@ public class WifiConnectivityManagerTest extends WifiBaseTest {
public void checkSingleScanSettingsWhenConnectedWithHighDataRateNotInCache() {
when(mWifiNS.isNetworkSufficient(eq(mWifiInfo))).thenReturn(true);
when(mWifiNS.hasActiveStream(eq(mWifiInfo))).thenReturn(true);
+ when(mWifiNS.hasSufficientLinkQuality(eq(mWifiInfo))).thenReturn(true);
+ when(mWifiNS.hasInternetOrExpectNoInternet(eq(mWifiInfo))).thenReturn(true);
final List<Integer> channelList = new ArrayList<>();
channelList.add(TEST_FREQUENCY_1);