summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Plass <mplass@google.com>2017-04-19 16:45:08 -0700
committerMichael Plass <mplass@google.com>2017-06-13 11:42:23 -0700
commite802d02eb96d3cbe774110c432f957976deb92b3 (patch)
tree4a097a65c5a57e15202cf7fbeb41cef0cefeb877 /tests
parent12f18f1708c4d27388478230c03fd51a59e22f98 (diff)
[WifiScoreReport] Simplifed scorer/quick handover
Introduce a simplified scorer for the currently-connected wifi. For now, this is only in effect when the developer preference for aggressive handover of wifi to cellular is in effect. Bug: 37577414 Test: manual, added unit tests Change-Id: I7a27c5d3686a4fbb9429f68497d47e6ea9ae7a85
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java50
1 files changed, 45 insertions, 5 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java b/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java
index 41f14dd75..1f5927d95 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java
@@ -49,6 +49,7 @@ public class WifiScoreReportTest {
WifiScoreReport mWifiScoreReport;
ScanDetailCache mScanDetailCache;
WifiInfo mWifiInfo;
+ int mAggr; // Aggressive handover
@Mock Context mContext;
@Mock NetworkAgent mNetworkAgent;
@Mock Resources mResources;
@@ -106,6 +107,7 @@ public class WifiScoreReportTest {
config.hiddenSSID = false;
mWifiInfo = new WifiInfo();
mWifiInfo.setFrequency(2412);
+ mAggr = 0;
when(mWifiConfigManager.getSavedNetworks()).thenReturn(Arrays.asList(config));
when(mWifiConfigManager.getConfiguredNetwork(anyInt())).thenReturn(config);
mWifiConfiguration = config;
@@ -138,10 +140,9 @@ public class WifiScoreReportTest {
*/
@Test
public void calculateAndReportScoreSucceeds() throws Exception {
- int aggressiveHandover = 0;
mWifiInfo.setRssi(-77);
mWifiScoreReport.calculateAndReportScore(mWifiInfo,
- mNetworkAgent, aggressiveHandover, mWifiMetrics);
+ mNetworkAgent, mAggr, mWifiMetrics);
verify(mNetworkAgent).sendNetworkScore(anyInt());
verify(mWifiMetrics).incrementWifiScoreCount(anyInt());
}
@@ -155,7 +156,7 @@ public class WifiScoreReportTest {
public void networkAgentMayBeNull() throws Exception {
mWifiInfo.setRssi(-33);
mWifiScoreReport.enableVerboseLogging(true);
- mWifiScoreReport.calculateAndReportScore(mWifiInfo, null, 0, mWifiMetrics);
+ mWifiScoreReport.calculateAndReportScore(mWifiInfo, null, mAggr, mWifiMetrics);
verify(mWifiMetrics).incrementWifiScoreCount(anyInt());
}
@@ -174,7 +175,7 @@ public class WifiScoreReportTest {
mWifiInfo.txSuccessRate = 5.1; // proportional to pps
mWifiInfo.rxSuccessRate = 5.1;
for (int i = 0; i < 10; i++) {
- mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, 0, mWifiMetrics);
+ mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mAggr, mWifiMetrics);
}
int score = mWifiInfo.score;
assertTrue(score > CELLULAR_THRESHOLD_SCORE);
@@ -197,10 +198,49 @@ public class WifiScoreReportTest {
mWifiInfo.txSuccessRate = 0.1;
mWifiInfo.rxSuccessRate = 0.1;
for (int i = 0; i < 10; i++) {
- mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, 0, mWifiMetrics);
+ mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mAggr, mWifiMetrics);
}
int score = mWifiInfo.score;
assertTrue(score < CELLULAR_THRESHOLD_SCORE);
verify(mNetworkAgent, atLeast(1)).sendNetworkScore(score);
}
+
+ /**
+ * Test reporting with aggressive handover
+ */
+ @Test
+ public void calculateAndReportScoreSucceedsAggressively() throws Exception {
+ mAggr = 1;
+ mWifiInfo.setRssi(-77);
+ mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mAggr, mWifiMetrics);
+ verify(mNetworkAgent).sendNetworkScore(anyInt());
+ verify(mWifiMetrics).incrementWifiScoreCount(anyInt());
+ }
+
+ /**
+ * Test low rssi with aggressive handover
+ */
+ @Test
+ public void giveUpOnBadRssiAggressively() throws Exception {
+ mAggr = 1;
+ mWifiInfo.setRssi(-83);
+ mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mAggr, mWifiMetrics);
+ int score = mWifiInfo.score;
+ verify(mNetworkAgent, atLeast(1)).sendNetworkScore(score);
+ assertTrue(score < CELLULAR_THRESHOLD_SCORE);
+ }
+
+ /**
+ * Test high rssi with aggressive handover
+ */
+ @Test
+ public void allowGoodRssiAggressively() throws Exception {
+ mAggr = 1;
+ mWifiInfo.setRssi(-65);
+ mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mAggr, mWifiMetrics);
+ int score = mWifiInfo.score;
+ verify(mNetworkAgent, atLeast(1)).sendNetworkScore(score);
+ assertTrue(score > CELLULAR_THRESHOLD_SCORE);
+ }
+
}