summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Plass <mplass@google.com>2018-04-01 21:54:38 -0700
committerMichael Plass <mplass@google.com>2018-04-06 13:16:50 -0700
commite2219127c2ec54059982709f01b342e19370be25 (patch)
treecf3383170d80fec4b9a0255cc2abb65676bb4cfe /tests
parentbebbafc510f5a6bd539840d85ff74bf13b6db65e (diff)
Request ip reachablility checks on low wifi score
This is under control of the nud param of wifi_score_params Bug: 73383969 Test: Unit tests Test: Manual test with nud=1, and with nud=10 Change-Id: Ia7f0ec8d0ff1bd658b414bcce389dcb9ce357dc0
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ScoringParamsTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java84
2 files changed, 84 insertions, 2 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/ScoringParamsTest.java b/tests/wifitests/src/com/android/server/wifi/ScoringParamsTest.java
index 42a4c133d..fc9b33ad2 100644
--- a/tests/wifitests/src/com/android/server/wifi/ScoringParamsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ScoringParamsTest.java
@@ -94,7 +94,7 @@ public class ScoringParamsTest {
public void testToString() throws Exception {
mScoringParams = new ScoringParams();
String expect =
- "rssi2=-83:-80:-73:-60,rssi5=-80:-77:-70:-57,pps=0:1:100,horizon=15,nud=0";
+ "rssi2=-83:-80:-73:-60,rssi5=-80:-77:-70:-57,pps=0:1:100,horizon=15,nud=8";
String actual = mScoringParams.toString();
assertEquals(expect, actual);
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java b/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java
index bf662f01a..38e45d306 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java
@@ -16,6 +16,8 @@
package com.android.server.wifi;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.AdditionalAnswers.answerVoid;
import static org.mockito.ArgumentMatchers.anyString;
@@ -272,7 +274,7 @@ public class WifiScoreReportTest {
mWifiInfo.rxSuccessRate = mScoringParams.getYippeeSkippyPacketsPerSecond() + 0.1;
assertTrue(mWifiInfo.txSuccessRate > 10);
mWifiInfo.setFrequency(5220);
- for (int r = -30; r >= -200; r -= 2) {
+ for (int r = -30; r >= -120; r -= 2) {
mWifiInfo.setRssi(r);
mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mWifiMetrics);
assertTrue(mWifiInfo.score > ConnectedScore.WIFI_TRANSITION_SCORE);
@@ -289,6 +291,86 @@ public class WifiScoreReportTest {
}
/**
+ * Never ask for nud check when nud=0
+ */
+ @Test
+ public void neverAskForNudCheckWhenNudKnobIsZero() throws Exception {
+ assertTrue(mScoringParams.update("nud=0"));
+ assertEquals(0, mScoringParams.getNudKnob());
+ mWifiInfo.setFrequency(5220);
+ for (int rssi = -30; rssi >= -120; rssi -= 1) {
+ mWifiInfo.setRssi(rssi);
+ mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mWifiMetrics);
+ assertFalse(mWifiScoreReport.shouldCheckIpLayer());
+ }
+ }
+
+ /**
+ * Eventually ask for nud check when nud=1
+ */
+ @Test
+ public void eventuallyAskForNudCheckWhenNudKnobIsOne() throws Exception {
+ String oops = "nud=1";
+ long lastAskedMillis = 0; // Check that we don't send too soon
+ int asks = 0; // Keep track of how many time we asked
+ assertTrue(mScoringParams.update("nud=1"));
+ assertEquals(1, mScoringParams.getNudKnob());
+ mWifiInfo.setFrequency(5220);
+ for (int rssi = -40; rssi >= -120; rssi -= 1) {
+ mWifiInfo.setRssi(rssi);
+ mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mWifiMetrics);
+ boolean ask = mWifiScoreReport.shouldCheckIpLayer();
+ if (ask) {
+ assertTrue(mWifiInfo.score < ConnectedScore.WIFI_TRANSITION_SCORE);
+ assertTrue(oops, mClock.mWallClockMillis >= lastAskedMillis + 5000);
+ lastAskedMillis = mClock.mWallClockMillis;
+ oops += " " + lastAskedMillis + ":" + mWifiInfo.score;
+ mWifiScoreReport.noteIpCheck();
+ asks++;
+ }
+ }
+ assertTrue(oops + " asks:" + asks, asks > 5 && asks < 12);
+ }
+
+
+ /**
+ * Ask for more nud checks when nud=10
+ */
+ @Test
+ public void askForMoreNudChecksWhenNudKnobIsBigger() throws Exception {
+ String oops = "nud=10";
+ long lastAskedMillis = 0; // Check that we don't send too soon
+ int asks = 0; // Keep track of how many time we asked
+ assertTrue(mScoringParams.update("nud=10"));
+ assertEquals(10, mScoringParams.getNudKnob());
+ mWifiInfo.setFrequency(5220);
+ for (int rssi = -40; rssi >= -120; rssi -= 1) {
+ mWifiInfo.setRssi(rssi);
+ mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mWifiMetrics);
+ boolean ask = mWifiScoreReport.shouldCheckIpLayer();
+ if (ask) {
+ assertTrue(mWifiInfo.score < ConnectedScore.WIFI_TRANSITION_SCORE);
+ assertTrue(oops, mClock.mWallClockMillis >= lastAskedMillis + 5000);
+ lastAskedMillis = mClock.mWallClockMillis;
+ oops += " " + lastAskedMillis + ":" + mWifiInfo.score;
+ mWifiScoreReport.noteIpCheck();
+ asks++;
+ }
+ }
+ assertTrue(oops + " asks:" + asks, asks > 12 && asks < 80);
+ }
+
+ /**
+ * Test initial conditions, and after reset()
+ */
+ @Test
+ public void exerciseReset() throws Exception {
+ assertFalse(mWifiScoreReport.shouldCheckIpLayer());
+ mWifiScoreReport.reset();
+ assertFalse(mWifiScoreReport.shouldCheckIpLayer());
+ }
+
+ /**
* This setup causes some reports to be generated when println
* methods are called, to check for "concurrent" modification
* errors.