summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Plass <mplass@google.com>2020-02-21 20:09:20 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-02-21 20:09:20 +0000
commite2cf2e5c7809366692256a44609a021aa7925573 (patch)
treecb64beac417426bbce1892d2f6e3adcd270c7d0c /tests
parent4a5f80458a4d231c053e7cdd1d0e29296a129ac3 (diff)
parentab37e880f228312bcaabec2aded2433745fea0e9 (diff)
Merge "[WifiNetworkSelector] User-selected network is sufficient for a while"
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java
index 1e72cb758..0b91ea675 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java
@@ -65,6 +65,7 @@ public class WifiNetworkSelectorTest extends WifiBaseTest {
private static final int RSSI_BUMP = 1;
private static final int DUMMY_NOMINATOR_ID_1 = -2; // lowest index
private static final int DUMMY_NOMINATOR_ID_2 = -1;
+ private static final int WAIT_JUST_A_MINUTE = 60_000;
private static final HashSet<String> EMPTY_BLACKLIST = new HashSet<>();
/** Sets up test. */
@@ -216,6 +217,7 @@ public class WifiNetworkSelectorTest extends WifiBaseTest {
private int mThresholdQualifiedRssi2G;
private int mThresholdQualifiedRssi5G;
private int mMinPacketRateActiveTraffic;
+ private int mSufficientDurationAfterUserSelection;
private CompatibilityScorer mCompatibilityScorer;
private ScoreCardBasedScorer mScoreCardBasedScorer;
private ThroughputScorer mThroughputScorer;
@@ -234,6 +236,9 @@ public class WifiNetworkSelectorTest extends WifiBaseTest {
R.bool.config_wifi_framework_enable_associated_network_selection);
mMinPacketRateActiveTraffic = setupIntegerResource(
R.integer.config_wifiFrameworkMinPacketPerSecondActiveTraffic, 16);
+ mSufficientDurationAfterUserSelection = setupIntegerResource(
+ R.integer.config_wifiSufficientDurationAfterUserSelectionMilliseconds,
+ WAIT_JUST_A_MINUTE);
doReturn(false).when(mResource).getBoolean(R.bool.config_wifi11axSupportOverride);
}
@@ -868,6 +873,33 @@ public class WifiNetworkSelectorTest extends WifiBaseTest {
false);
}
+ /**
+ * New network selection is not performed if the currently connected network
+ * was recently selected.
+ */
+ @Test
+ public void networkIsSufficientWhenRecentlyUserSelected() {
+ // Approximate mClock.getElapsedSinceBootMillis value mocked by testStayOrTryToSwitch
+ long millisSinceBoot = SystemClock.elapsedRealtime()
+ + WifiNetworkSelector.MINIMUM_NETWORK_SELECTION_INTERVAL_MS + 2000;
+ when(mWifiConfigManager.getLastSelectedTimeStamp())
+ .thenReturn(millisSinceBoot
+ - WAIT_JUST_A_MINUTE
+ + 1000);
+ setupWifiConfigManager(0); // testStayOrTryToSwitch first connects to network 0
+ // Rssi after connected.
+ when(mWifiInfo.getRssi()).thenReturn(mThresholdQualifiedRssi2G + 1);
+ // No streaming traffic.
+ when(mWifiInfo.getSuccessfulTxPacketsPerSecond()).thenReturn(0.0);
+ when(mWifiInfo.getSuccessfulRxPacketsPerSecond()).thenReturn(0.0);
+
+ testStayOrTryToSwitch(
+ mThresholdQualifiedRssi2G + 1 /* rssi before connected */,
+ false /* not a 5G network */,
+ false /* not open network */,
+ // Should not try to switch.
+ false);
+ }
/**
* New network selection is performed if the currently connected network has bad rssi.