summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Plass <mplass@google.com>2017-10-06 10:27:00 -0700
committerMichael Plass <mplass@google.com>2018-01-19 21:12:52 +0000
commit929c521de00d91d269d2d4cad613904c76c366a1 (patch)
tree2521667a033b74cef291f9453f232d05e78115b1 /tests
parent72ca252ebfb5d91b13627a5f95b89db7b6adc1e5 (diff)
Metrics for connected wifi score
Note when switches of the default network would happen, based on score. Increase MAX_STA_EVENTS by 50% to allow some headroom for the additional StaEvent type. (cherry picked from commit e6fb5b05c294b853f768caa93de509b4afa8adef) Bug: 67429363 Bug: 71708302 Test: Unit tests Test: Manually check dumpsys output Change-Id: Id35695502966c96ce817322e1aa5b17f5522f5e4 Merged-In: I163d3831dd207d1dbb6d65f643f0f0418601b54b
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java32
1 files changed, 30 insertions, 2 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
index 6e0b7759c..04e43d1bd 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
@@ -782,6 +782,31 @@ public class WifiMetricsTest {
// pending their implementation</TODO>
}
+ /**
+ * Test that score breach events are properly generated
+ */
+ @Test
+ public void testScoreBeachEvents() throws Exception {
+ int upper = WifiMetrics.LOW_WIFI_SCORE + 7;
+ int mid = WifiMetrics.LOW_WIFI_SCORE;
+ int lower = WifiMetrics.LOW_WIFI_SCORE - 8;
+ mWifiMetrics.setWifiState(WifiMetricsProto.WifiLog.WIFI_ASSOCIATED);
+ for (int score = upper; score >= mid; score--) mWifiMetrics.incrementWifiScoreCount(score);
+ mWifiMetrics.incrementWifiScoreCount(mid + 1);
+ mWifiMetrics.incrementWifiScoreCount(lower); // First breach
+ for (int score = lower; score <= mid; score++) mWifiMetrics.incrementWifiScoreCount(score);
+ mWifiMetrics.incrementWifiScoreCount(mid - 1);
+ mWifiMetrics.incrementWifiScoreCount(upper); // Second breach
+
+ dumpProtoAndDeserialize();
+
+ assertEquals(2, mDecodedProto.staEventList.length);
+ assertEquals(StaEvent.TYPE_SCORE_BREACH, mDecodedProto.staEventList[0].type);
+ assertEquals(lower, mDecodedProto.staEventList[0].lastScore);
+ assertEquals(StaEvent.TYPE_SCORE_BREACH, mDecodedProto.staEventList[1].type);
+ assertEquals(upper, mDecodedProto.staEventList[1].lastScore);
+ }
+
private static final String SSID = "red";
private static final int CONFIG_DTIM = 3;
private static final int NETWORK_DETAIL_WIFIMODE = 5;
@@ -1060,7 +1085,7 @@ public class WifiMetricsTest {
private static final int ASSOC_TIMEOUT = 1;
private static final int LOCAL_GEN = 1;
private static final int AUTH_FAILURE_REASON = WifiManager.ERROR_AUTH_FAILURE_WRONG_PSWD;
- private static final int NUM_TEST_STA_EVENTS = 14;
+ private static final int NUM_TEST_STA_EVENTS = 15;
private static final String sSSID = "\"SomeTestSsid\"";
private static final WifiSsid sWifiSsid = WifiSsid.createFromAsciiEncoded(sSSID);
private static final String sBSSID = "01:02:03:04:05:06";
@@ -1108,7 +1133,8 @@ public class WifiMetricsTest {
{StaEvent.TYPE_CMD_START_ROAM, 0, 1},
{StaEvent.TYPE_CONNECT_NETWORK, 0, 1},
{StaEvent.TYPE_NETWORK_AGENT_VALID_NETWORK, 0, 0},
- {StaEvent.TYPE_FRAMEWORK_DISCONNECT, StaEvent.DISCONNECT_API, 0}
+ {StaEvent.TYPE_FRAMEWORK_DISCONNECT, StaEvent.DISCONNECT_API, 0},
+ {StaEvent.TYPE_SCORE_BREACH, 0, 0}
};
// Values used to generate the StaEvent log calls from WifiMonitor
// <type>, <reason>, <status>, <local_gen>,
@@ -1141,6 +1167,8 @@ public class WifiMetricsTest {
{StaEvent.TYPE_NETWORK_AGENT_VALID_NETWORK, -1, -1, 0,
/**/ 0, 0, 0, 0}, /**/
{StaEvent.TYPE_FRAMEWORK_DISCONNECT, -1, -1, 0,
+ /**/ 0, 0, 0, 0}, /**/
+ {StaEvent.TYPE_SCORE_BREACH, -1, -1, 0,
/**/ 0, 0, 0, 0} /**/
};