summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGlen Kuhne <kuh@google.com>2016-09-16 16:35:57 -0700
committerGlen Kuhne <kuh@google.com>2016-09-19 14:26:59 -0700
commit9ff7dea01b09f658492b7b8fa122695e56d28cdc (patch)
treeb7589a67d39b04bc4554a949d53e49feddf448e4 /tests
parent7a36be372edfa3f7fe0e37320b9b21a5fbadf277 (diff)
downloadandroid_frameworks_opt_net_wifi-9ff7dea01b09f658492b7b8fa122695e56d28cdc.tar.gz
android_frameworks_opt_net_wifi-9ff7dea01b09f658492b7b8fa122695e56d28cdc.tar.bz2
android_frameworks_opt_net_wifi-9ff7dea01b09f658492b7b8fa122695e56d28cdc.zip
Wifi Metrics: dumpsys arg for clean output
Modify the way dumpsys works in wifi so that 'dumpsys wifi wifiMetricsProto clean' outputs only serialized base64 encoded wifi metrics proto bytes. BUG=31556602 Test: Created new unit test Change-Id: Id1aa319a03a5e2bcffb1276057cb770679015abd
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java33
1 files changed, 33 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 cf8204b8e..5cd14668f 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
@@ -106,6 +106,25 @@ public class WifiMetricsTest {
mDeserializedWifiMetrics = WifiMetricsProto.WifiLog.parseFrom(protoBytes);
}
+ /**
+ * Gets the 'clean dump' proto bytes from mWifiMetrics & deserializes it into
+ * mDeserializedWifiMetrics
+ */
+ public void cleanDumpProtoAndDeserialize() throws Exception {
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
+ PrintWriter writer = new PrintWriter(stream);
+ String[] args = new String[0];
+
+ when(mClock.elapsedRealtime()).thenReturn(TEST_RECORD_DURATION_MILLIS);
+ //Test proto dump, by passing in proto arg option
+ args = new String[]{WifiMetrics.PROTO_DUMP_ARG, WifiMetrics.CLEAN_DUMP_ARG};
+ mWifiMetrics.dump(null, writer, args);
+ writer.flush();
+ String protoByteString = stream.toString();
+ byte[] protoBytes = Base64.decode(protoByteString, Base64.DEFAULT);
+ mDeserializedWifiMetrics = WifiMetricsProto.WifiLog.parseFrom(protoBytes);
+ }
+
/** Verifies that dump() includes the expected header */
@Test
public void stateDumpIncludesHeader() throws Exception {
@@ -583,6 +602,20 @@ public class WifiMetricsTest {
assertEquals(mDeserializedWifiMetrics.connectionEvent.length, 2);
}
+ /**
+ * Tests that after setting metrics values they can be serialized and deserialized with the
+ * $ adb shell dumpsys wifi wifiMetricsProto clean
+ */
+ @Test
+ public void testClearMetricsDump() throws Exception {
+ setAndIncrementMetrics();
+ startAndEndConnectionEventSucceeds();
+ cleanDumpProtoAndDeserialize();
+ assertDeserializedMetricsCorrect();
+ assertEquals("mDeserializedWifiMetrics.connectionEvent.length",
+ 2, mDeserializedWifiMetrics.connectionEvent.length);
+ }
+
private void assertStringContains(
String actualString, String expectedSubstring) {
assertTrue("Expected text not found in: " + actualString,