summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorxshu <xshu@google.com>2020-08-17 19:31:28 -0700
committerxshu <xshu@google.com>2020-09-02 16:31:02 -0700
commit6aa15665ac75806ff5c688cff47e8dd671130b1f (patch)
treea32a3d18ed81128c372e4776e072e0f1575e986b /tests
parent4036c533b3da963ef103a923037ca944e3c283ea (diff)
Add WifiStatus to UserAction metrics
(cherry-picked from c53ba0980a30bf07a73dc56743183315c0b70041) Include a snapshot of latest wifi status in the UserActionEvent. Updated-PDD: true Bug: 165118962 Test: atest com.android.server.wifi Change-Id: I21b617a520c11babfc39fa8d0103900fd78ea270 Merged-In: I21b617a520c11babfc39fa8d0103900fd78ea270
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
index d16ef3dcf..0a5a512b2 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
@@ -2417,6 +2417,41 @@ public class WifiMetricsTest extends WifiBaseTest {
}
/**
+ * Verify the WifiStatus field in a UserActionEvent is populated correctly.
+ * @throws Exception
+ */
+ @Test
+ public void testLogWifiStatusInUserActionEvent() throws Exception {
+ // setups WifiStatus for information
+ int expectedRssi = -55;
+ int testNetworkId = 1;
+ int expectedTx = 1234;
+ int expectedRx = 2345;
+
+ WifiInfo wifiInfo = mock(WifiInfo.class);
+ when(wifiInfo.getRssi()).thenReturn(expectedRssi);
+ when(wifiInfo.getNetworkId()).thenReturn(testNetworkId);
+ mWifiMetrics.handlePollResult(wifiInfo);
+ mWifiMetrics.incrementThroughputKbpsCount(expectedTx, expectedRx, RSSI_POLL_FREQUENCY);
+ mWifiMetrics.setNominatorForNetwork(testNetworkId,
+ WifiMetricsProto.ConnectionEvent.NOMINATOR_SAVED_USER_CONNECT_CHOICE);
+
+ // generate a user action event and then verify fields
+ int testEventType = WifiMetricsProto.UserActionEvent.EVENT_FORGET_WIFI;
+ mWifiMetrics.logUserActionEvent(testEventType, testNetworkId);
+ dumpProtoAndDeserialize();
+
+ WifiMetricsProto.UserActionEvent[] userActionEvents = mDecodedProto.userActionEvents;
+ assertEquals(1, userActionEvents.length);
+ assertEquals(WifiMetricsProto.UserActionEvent.EVENT_FORGET_WIFI,
+ userActionEvents[0].eventType);
+ assertEquals(expectedRssi, userActionEvents[0].wifiStatus.lastRssi);
+ assertEquals(expectedTx, userActionEvents[0].wifiStatus.estimatedTxKbps);
+ assertEquals(expectedRx, userActionEvents[0].wifiStatus.estimatedRxKbps);
+ assertTrue(userActionEvents[0].wifiStatus.isStuckDueToUserConnectChoice);
+ }
+
+ /**
* Test the logging of UserActionEvent with invalid network ID
*/
@Test