summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMukesh Agrawal <quiche@google.com>2016-04-11 20:04:26 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-04-11 20:04:26 +0000
commit492900e5895d4480292d5f7518d109e6b3b9fb47 (patch)
treecce5a699f81a97f775c9e9c0a56e1b57d76f1600 /tests
parent4cd91e207897c250c7fc0e6ed3176698dce29093 (diff)
parentcf2c37cff48a96fe221121dfe6a0360a54ed9ebb (diff)
Merge "WifiStateMachine: reduce number of LogRecords" into nyc-dev
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
index 73c1dfb40..c16a416cc 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
@@ -31,6 +31,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.withSettings;
+import android.app.ActivityManager;
import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.PackageManager;
@@ -108,6 +109,10 @@ public class WifiStateMachineTest {
private static final int MANAGED_PROFILE_UID = 1100000;
private static final int OTHER_USER_UID = 1200000;
+ private static final int LOG_REC_LIMIT_IN_VERBOSE_MODE =
+ (ActivityManager.isLowRamDeviceStatic()
+ ? WifiStateMachine.NUM_LOG_RECS_VERBOSE_LOW_MEMORY
+ : WifiStateMachine.NUM_LOG_RECS_VERBOSE);
private long mBinderToken;
@@ -999,4 +1004,53 @@ public class WifiStateMachineTest {
assertEquals(":3b4a:1d2c:1100:3322", mWsm.getGsmSimAuthResponse(
new String[] { "1A2B", "0123" }, tm));
}
+
+ /**
+ * Verifies that, by default, we allow only the "normal" number of log records.
+ */
+ @Test
+ public void normalLogRecSizeIsUsedByDefault() {
+ for (int i = 0; i < WifiStateMachine.NUM_LOG_RECS_NORMAL * 2; i++) {
+ mWsm.sendMessage(WifiStateMachine.CMD_BOOT_COMPLETED);
+ }
+ mLooper.dispatchAll();
+ assertEquals(WifiStateMachine.NUM_LOG_RECS_NORMAL, mWsm.getLogRecSize());
+ }
+
+ /**
+ * Verifies that, in verbose mode, we allow a larger number of log records.
+ */
+ @Test
+ public void enablingVerboseLoggingIncreasesLogRecSize() {
+ assertTrue(LOG_REC_LIMIT_IN_VERBOSE_MODE > WifiStateMachine.NUM_LOG_RECS_NORMAL);
+ mWsm.enableVerboseLogging(1);
+ for (int i = 0; i < LOG_REC_LIMIT_IN_VERBOSE_MODE * 2; i++) {
+ mWsm.sendMessage(WifiStateMachine.CMD_BOOT_COMPLETED);
+ }
+ mLooper.dispatchAll();
+ assertEquals(LOG_REC_LIMIT_IN_VERBOSE_MODE, mWsm.getLogRecSize());
+ }
+
+ /**
+ * Verifies that moving from verbose mode to normal mode resets the buffer, and limits new
+ * records to a small number of entries.
+ */
+ @Test
+ public void disablingVerboseLoggingClearsRecordsAndDecreasesLogRecSize() {
+ mWsm.enableVerboseLogging(1);
+ for (int i = 0; i < LOG_REC_LIMIT_IN_VERBOSE_MODE; i++) {
+ mWsm.sendMessage(WifiStateMachine.CMD_BOOT_COMPLETED);
+ }
+ mLooper.dispatchAll();
+ assertEquals(LOG_REC_LIMIT_IN_VERBOSE_MODE, mWsm.getLogRecSize());
+
+ mWsm.enableVerboseLogging(0);
+ assertEquals(0, mWsm.getLogRecSize());
+ for (int i = 0; i < LOG_REC_LIMIT_IN_VERBOSE_MODE; i++) {
+ mWsm.sendMessage(WifiStateMachine.CMD_BOOT_COMPLETED);
+ }
+ mLooper.dispatchAll();
+ assertEquals(WifiStateMachine.NUM_LOG_RECS_NORMAL, mWsm.getLogRecSize());
+ }
+
}