diff options
author | xshu <xshu@google.com> | 2018-03-15 16:48:17 -0700 |
---|---|---|
committer | xshu <xshu@google.com> | 2018-04-18 11:12:38 -0700 |
commit | 338d87ce46cf0766005f747bb82ac590ceaff54d (patch) | |
tree | b3d83a312a879e5624f75916a0407bdb5b41faa9 /tests | |
parent | 3a48dfd8ab53cf4050a17009afd829e6483369bb (diff) |
metrics: Watchdog success delay
Tracks how long it takes for wifi to connect after a watchdog trigger.
Bug: 75001353
Test: compile, run ./frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Change-Id: Iad9a20b38ad92d76cfc46d9fd01f2f565e9a22d0
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java | 12 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java | 6 |
2 files changed, 17 insertions, 1 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java b/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java index 0cbc06ac2..1cd9750fe 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java @@ -44,6 +44,7 @@ public class WifiLastResortWatchdogTest { @Mock WifiMetrics mWifiMetrics; @Mock SelfRecovery mSelfRecovery; @Mock WifiStateMachine mWifiStateMachine; + @Mock Clock mClock; private String[] mSsids = {"\"test1\"", "\"test2\"", "\"test3\"", "\"test4\""}; private String[] mBssids = {"6c:f3:7f:ae:8c:f3", "6c:f3:7f:ae:8c:f4", "de:ad:ba:b1:e5:55", @@ -60,7 +61,7 @@ public class WifiLastResortWatchdogTest { public void setUp() throws Exception { initMocks(this); mLooper = new TestLooper(); - mLastResortWatchdog = new WifiLastResortWatchdog(mSelfRecovery, mWifiMetrics, + mLastResortWatchdog = new WifiLastResortWatchdog(mSelfRecovery, mClock, mWifiMetrics, mWifiStateMachine, mLooper.getLooper()); mLastResortWatchdog.setBugReportProbability(1); } @@ -1456,6 +1457,11 @@ public class WifiLastResortWatchdogTest { assertFailureCountEquals(bssids[i], 0, 0, 0); } + final long timeAtFailure = 100; + final long timeAtReconnect = 5000; + final long expectedDuration = timeAtReconnect - timeAtFailure; + when(mClock.getElapsedSinceBootMillis()).thenReturn(timeAtFailure, timeAtReconnect); + //Increment failure counts for (int i = 0; i < WifiLastResortWatchdog.FAILURE_THRESHOLD; i++) { mLastResortWatchdog.noteConnectionFailureAndTriggerIfNeeded( @@ -1490,6 +1496,8 @@ public class WifiLastResortWatchdogTest { // Verify that WifiMetrics counted this as a Watchdog success verify(mWifiMetrics, times(1)).incrementNumLastResortWatchdogSuccesses(); + verify(mWifiMetrics, times(1)).setWatchdogSuccessTimeDurationMs(eq(expectedDuration)); + // Verify takeBugReport is called mLooper.dispatchAll(); verify(mWifiStateMachine, times(1)).takeBugReport(anyString(), anyString()); @@ -1499,6 +1507,7 @@ public class WifiLastResortWatchdogTest { // Verify that WifiMetrics has still only counted one success verify(mWifiMetrics, times(1)).incrementNumLastResortWatchdogSuccesses(); + verify(mWifiMetrics, times(1)).setWatchdogSuccessTimeDurationMs(eq(expectedDuration)); // Verify takeBugReport not called again mLooper.dispatchAll(); verify(mWifiStateMachine, times(1)).takeBugReport(anyString(), anyString()); @@ -1542,6 +1551,7 @@ public class WifiLastResortWatchdogTest { // Verify that WifiMetrics did not count another success, as the connection could be due // to the newly available network #5 verify(mWifiMetrics, times(1)).incrementNumLastResortWatchdogSuccesses(); + verify(mWifiMetrics, times(1)).setWatchdogSuccessTimeDurationMs(eq(expectedDuration)); } /** diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java index 665b60b46..8212169dc 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java @@ -286,6 +286,7 @@ public class WifiMetricsTest { private static final int NUM_WPS_OTHER_CONNECTION_FAILURE = 16; private static final int NUM_WPS_SUPPLICANT_FAILURE = 12; private static final int NUM_WPS_CANCELLATION = 11; + private static final long NUM_WATCHDOG_SUCCESS_DURATION_MS = 65; /** Number of notifications per "Connect to Network" notification type. */ private static final int[] NUM_CONNECT_TO_NETWORK_NOTIFICATIONS = {0, 10, 20, 30, 40}; @@ -659,6 +660,8 @@ public class WifiMetricsTest { for (int i = 0; i < NUM_WPS_CANCELLATION; i++) { mWifiMetrics.incrementWpsCancellationCount(); } + + mWifiMetrics.setWatchdogSuccessTimeDurationMs(NUM_WATCHDOG_SUCCESS_DURATION_MS); } private void addSoftApEventsToMetrics() { @@ -924,6 +927,9 @@ public class WifiMetricsTest { assertEquals(NUM_WPS_OTHER_CONNECTION_FAILURE, wps_metrics.numWpsOtherConnectionFailure); assertEquals(NUM_WPS_SUPPLICANT_FAILURE, wps_metrics.numWpsSupplicantFailure); assertEquals(NUM_WPS_CANCELLATION, wps_metrics.numWpsCancellation); + + assertEquals(NUM_WATCHDOG_SUCCESS_DURATION_MS, + mDecodedProto.watchdogTriggerToConnectionSuccessDurationMs); } /** |