diff options
author | Oscar Shu <xshu@google.com> | 2018-04-17 20:53:13 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-04-17 20:53:13 +0000 |
commit | 3a48dfd8ab53cf4050a17009afd829e6483369bb (patch) | |
tree | b028c5375a87448780fa12ea55fd9183b8122c3b /tests | |
parent | dd06605ed8c1249718eb881e3ebde3ee6da82eca (diff) | |
parent | 1f2ef2776476457b3eb2df70e39d53770c6b2b77 (diff) |
Merge "metrics: count connection failures after watchdog trigger" into pi-dev
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java | 40 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java | 6 |
2 files changed, 46 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java b/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java index 4abc77f91..0cbc06ac2 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java @@ -1810,4 +1810,44 @@ public class WifiLastResortWatchdogTest { mLooper.dispatchAll(); verify(mWifiStateMachine, times(1)).takeBugReport(anyString(), anyString()); } + + + /** + * Test metrics incrementing connection failure count after watchdog has already been triggered + */ + @Test + public void testIncrementingWatchdogConnectionFailuresAfterTrigger() { + String[] ssids = {"\"test1\""}; + String[] bssids = {"6c:f3:7f:ae:8c:f3"}; + int[] frequencies = {2437}; + String[] caps = {"[WPA2-EAP-CCMP][ESS]"}; + int[] levels = {-60}; + boolean[] isEphemeral = {false}; + boolean[] hasEverConnected = {true}; + List<Pair<ScanDetail, WifiConfiguration>> candidates = createFilteredQnsCandidates(ssids, + bssids, frequencies, caps, levels, isEphemeral, hasEverConnected); + mLastResortWatchdog.updateAvailableNetworks(candidates); + + // Ensure new networks have zero'ed failure counts + for (int i = 0; i < ssids.length; i++) { + assertFailureCountEquals(bssids[i], 0, 0, 0); + } + + //Increment failure counts + for (int i = 0; i < WifiLastResortWatchdog.FAILURE_THRESHOLD; i++) { + mLastResortWatchdog.noteConnectionFailureAndTriggerIfNeeded( + ssids[0], bssids[0], WifiLastResortWatchdog.FAILURE_CODE_ASSOCIATION); + } + + // Verify relevant WifiMetrics calls were made once with appropriate arguments + verify(mWifiMetrics, times(1)).incrementNumLastResortWatchdogTriggers(); + + // Verify that failure count after trigger is not incremented yet + verify(mWifiMetrics, never()).incrementWatchdogTotalConnectionFailureCountAfterTrigger(); + + // Fail 1 more time and verify this time it's counted + mLastResortWatchdog.noteConnectionFailureAndTriggerIfNeeded( + ssids[0], bssids[0], WifiLastResortWatchdog.FAILURE_CODE_ASSOCIATION); + verify(mWifiMetrics, times(1)).incrementWatchdogTotalConnectionFailureCountAfterTrigger(); + } } diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java index 4a3239065..665b60b46 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java @@ -229,6 +229,7 @@ public class WifiMetricsTest { private static final int NUM_LAST_RESORT_WATCHDOG_TRIGGERS_WITH_BAD_DHCP = 9; private static final int NUM_LAST_RESORT_WATCHDOG_TRIGGERS_WITH_BAD_OTHER = 10; private static final int NUM_LAST_RESORT_WATCHDOG_SUCCESSES = 5; + private static final int WATCHDOG_TOTAL_CONNECTION_FAILURE_COUNT_AFTER_TRIGGER = 6; private static final int NUM_RSSI_LEVELS_TO_INCREMENT = 20; private static final int FIRST_RSSI_LEVEL = -80; private static final int NUM_OPEN_NETWORK_SCAN_RESULTS = 1; @@ -475,6 +476,9 @@ public class WifiMetricsTest { for (int i = 0; i < NUM_LAST_RESORT_WATCHDOG_SUCCESSES; i++) { mWifiMetrics.incrementNumLastResortWatchdogSuccesses(); } + for (int i = 0; i < WATCHDOG_TOTAL_CONNECTION_FAILURE_COUNT_AFTER_TRIGGER; i++) { + mWifiMetrics.incrementWatchdogTotalConnectionFailureCountAfterTrigger(); + } for (int i = 0; i < NUM_RSSI_LEVELS_TO_INCREMENT; i++) { for (int j = 0; j <= i; j++) { mWifiMetrics.incrementRssiPollRssiCount(MIN_RSSI_LEVEL + i); @@ -777,6 +781,8 @@ public class WifiMetricsTest { mDecodedProto.numLastResortWatchdogTriggersWithBadOther); assertEquals(NUM_LAST_RESORT_WATCHDOG_SUCCESSES, mDecodedProto.numLastResortWatchdogSuccesses); + assertEquals(WATCHDOG_TOTAL_CONNECTION_FAILURE_COUNT_AFTER_TRIGGER, + mDecodedProto.watchdogTotalConnectionFailureCountAfterTrigger); assertEquals(TEST_RECORD_DURATION_SEC, mDecodedProto.recordDurationSec); for (int i = 0; i < NUM_RSSI_LEVELS_TO_INCREMENT; i++) { |