summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMukesh Agrawal <quiche@google.com>2016-06-29 20:28:40 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-06-29 20:28:40 +0000
commit21d43031a1141caae823977a1e1015b596f47895 (patch)
tree5ba2506562290c43b200efbe23309941945fe392 /tests
parent06a68478d7ab476da36b70d26eee9b0adef3d03c (diff)
parente1db4e04054d8cc302fb96c4f78370845650504e (diff)
downloadandroid_frameworks_opt_net_wifi-21d43031a1141caae823977a1e1015b596f47895.tar.gz
android_frameworks_opt_net_wifi-21d43031a1141caae823977a1e1015b596f47895.tar.bz2
android_frameworks_opt_net_wifi-21d43031a1141caae823977a1e1015b596f47895.zip
Merge "WifiLogger: use R for ring buffer sizing" into nyc-mr1-dev
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiLoggerTest.java37
1 files changed, 26 insertions, 11 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiLoggerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiLoggerTest.java
index 55dc683c7..81c6274e8 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiLoggerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiLoggerTest.java
@@ -16,7 +16,9 @@
package com.android.server.wifi;
+import android.content.Context;
import android.test.suitebuilder.annotation.SmallTest;
+import com.android.internal.R;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
@@ -52,11 +54,15 @@ public class WifiLoggerTest {
@Mock WifiStateMachine mWsm;
@Mock WifiNative mWifiNative;
@Mock BuildProperties mBuildProperties;
+ @Mock Context mContext;
WifiLogger mWifiLogger;
private static final String FAKE_RING_BUFFER_NAME = "fake-ring-buffer";
- private WifiNative.RingBufferStatus mFakeRbs;
+ private static final int SMALL_RING_BUFFER_SIZE_KB = 32;
+ private static final int LARGE_RING_BUFFER_SIZE_KB = 1024;
+ private static final int BYTES_PER_KBYTE = 1024;
+ private WifiNative.RingBufferStatus mFakeRbs;
/**
* Returns the data that we would dump in a bug report, for our ring buffer.
* @return a 2-D byte array, where the first dimension is the record number, and the second
@@ -85,7 +91,14 @@ public class WifiLoggerTest {
when(mBuildProperties.isUserdebugBuild()).thenReturn(false);
when(mBuildProperties.isUserBuild()).thenReturn(true);
- mWifiLogger = new WifiLogger(mWsm, mWifiNative, mBuildProperties);
+ MockResources resources = new MockResources();
+ resources.setInteger(R.integer.config_wifi_logger_ring_buffer_default_size_limit_kb,
+ SMALL_RING_BUFFER_SIZE_KB);
+ resources.setInteger(R.integer.config_wifi_logger_ring_buffer_verbose_size_limit_kb,
+ LARGE_RING_BUFFER_SIZE_KB);
+ when(mContext.getResources()).thenReturn(resources);
+
+ mWifiLogger = new WifiLogger(mContext, mWsm, mWifiNative, mBuildProperties);
mWifiNative.enableVerboseLogging(0);
}
@@ -197,7 +210,7 @@ public class WifiLoggerTest {
final boolean verbosityToggle = false;
mWifiLogger.startLogging(verbosityToggle);
- final byte[] data = new byte[WifiLogger.RING_BUFFER_BYTE_LIMIT_SMALL];
+ final byte[] data = new byte[SMALL_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE];
mWifiLogger.onRingBufferData(mFakeRbs, data);
mWifiLogger.captureBugReportData(WifiLogger.REPORT_REASON_NONE);
@@ -214,7 +227,7 @@ public class WifiLoggerTest {
final boolean verbosityToggle = false;
mWifiLogger.startLogging(verbosityToggle);
- final byte[] data1 = new byte[WifiLogger.RING_BUFFER_BYTE_LIMIT_SMALL];
+ final byte[] data1 = new byte[SMALL_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE];
final byte[] data2 = {1, 2, 3};
mWifiLogger.onRingBufferData(mFakeRbs, data1);
mWifiLogger.onRingBufferData(mFakeRbs, data2);
@@ -526,7 +539,7 @@ public class WifiLoggerTest {
final boolean verbosityToggle = false;
mWifiLogger.startLogging(verbosityToggle);
mWifiLogger.onRingBufferData(
- mFakeRbs, new byte[WifiLogger.RING_BUFFER_BYTE_LIMIT_SMALL + 1]);
+ mFakeRbs, new byte[SMALL_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE + 1]);
mWifiLogger.captureBugReportData(WifiLogger.REPORT_REASON_NONE);
assertEquals(0, getLoggerRingBufferData().length);
}
@@ -540,7 +553,7 @@ public class WifiLoggerTest {
when(mBuildProperties.isUserBuild()).thenReturn(false);
mWifiLogger.startLogging(verbosityToggle);
mWifiLogger.onRingBufferData(
- mFakeRbs, new byte[WifiLogger.RING_BUFFER_BYTE_LIMIT_SMALL + 1]);
+ mFakeRbs, new byte[SMALL_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE + 1]);
mWifiLogger.captureBugReportData(WifiLogger.REPORT_REASON_NONE);
assertEquals(0, getLoggerRingBufferData().length);
}
@@ -554,7 +567,7 @@ public class WifiLoggerTest {
when(mBuildProperties.isUserBuild()).thenReturn(false);
mWifiLogger.startLogging(verbosityToggle);
mWifiLogger.onRingBufferData(
- mFakeRbs, new byte[WifiLogger.RING_BUFFER_BYTE_LIMIT_SMALL + 1]);
+ mFakeRbs, new byte[SMALL_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE + 1]);
mWifiLogger.captureBugReportData(WifiLogger.REPORT_REASON_NONE);
assertEquals(0, getLoggerRingBufferData().length);
}
@@ -564,7 +577,8 @@ public class WifiLoggerTest {
public void ringBufferSizeIsLargeInVerboseMode() throws Exception {
final boolean verbosityToggle = true;
mWifiLogger.startLogging(verbosityToggle);
- mWifiLogger.onRingBufferData(mFakeRbs, new byte[WifiLogger.RING_BUFFER_BYTE_LIMIT_LARGE]);
+ mWifiLogger.onRingBufferData(
+ mFakeRbs, new byte[LARGE_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE]);
mWifiLogger.captureBugReportData(WifiLogger.REPORT_REASON_NONE);
assertEquals(1, getLoggerRingBufferData().length);
}
@@ -574,7 +588,8 @@ public class WifiLoggerTest {
public void startLoggingGrowsRingBuffersIfNeeded() throws Exception {
mWifiLogger.startLogging(false /* verbose disabled */);
mWifiLogger.startLogging(true /* verbose enabled */);
- mWifiLogger.onRingBufferData(mFakeRbs, new byte[WifiLogger.RING_BUFFER_BYTE_LIMIT_LARGE]);
+ mWifiLogger.onRingBufferData(
+ mFakeRbs, new byte[LARGE_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE]);
mWifiLogger.captureBugReportData(WifiLogger.REPORT_REASON_NONE);
assertEquals(1, getLoggerRingBufferData().length);
}
@@ -584,7 +599,7 @@ public class WifiLoggerTest {
public void startLoggingShrinksRingBuffersIfNeeded() throws Exception {
mWifiLogger.startLogging(true /* verbose enabled */);
mWifiLogger.onRingBufferData(
- mFakeRbs, new byte[WifiLogger.RING_BUFFER_BYTE_LIMIT_SMALL + 1]);
+ mFakeRbs, new byte[SMALL_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE + 1]);
// Existing data is nuked (too large).
mWifiLogger.startLogging(false /* verbose disabled */);
@@ -593,7 +608,7 @@ public class WifiLoggerTest {
// New data must obey limit as well.
mWifiLogger.onRingBufferData(
- mFakeRbs, new byte[WifiLogger.RING_BUFFER_BYTE_LIMIT_SMALL + 1]);
+ mFakeRbs, new byte[SMALL_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE + 1]);
mWifiLogger.captureBugReportData(WifiLogger.REPORT_REASON_NONE);
assertEquals(0, getLoggerRingBufferData().length);
}