Loading core/tests/notificationtests/src/android/app/NotificationStressTest.java +7 −5 Original line number Original line Diff line number Diff line Loading @@ -40,9 +40,9 @@ public class NotificationStressTest extends InstrumentationTestCase { private static final int NUM_ITERATIONS = 200; private static final int NUM_ITERATIONS = 200; private static final int NUM_ITERATIONS_2 = 30; private static final int NUM_ITERATIONS_2 = 30; private static final int LONG_TIMEOUT = 2000; private static final int LONG_TIMEOUT = 2000; // 50 notifications per app: defined as Variable MAX_PACKAGE_NOTIFICATIONS in // 49 notifications per app: defined as Variable MAX_PACKAGE_NOTIFICATIONS in // NotificationManagerService.java // NotificationManagerService.java private static final int MAX_NOTIFCATIONS = 50; private static final int MAX_NOTIFCATIONS = 49; private static final int[] ICONS = new int[] { private static final int[] ICONS = new int[] { android.R.drawable.stat_notify_call_mute, android.R.drawable.stat_notify_call_mute, android.R.drawable.stat_notify_chat, android.R.drawable.stat_notify_chat, Loading Loading @@ -76,9 +76,10 @@ public class NotificationStressTest extends InstrumentationTestCase { @Override @Override protected void tearDown() throws Exception { protected void tearDown() throws Exception { super.tearDown(); mDevice.unfreezeRotation(); mDevice.unfreezeRotation(); mNotificationManager.cancelAll(); mNotificationManager.cancelAll(); mDevice.waitForIdle(); super.tearDown(); } } @RepetitiveTest(numIterations = NUM_ITERATIONS) @RepetitiveTest(numIterations = NUM_ITERATIONS) Loading @@ -97,7 +98,7 @@ public class NotificationStressTest extends InstrumentationTestCase { for (int j = 0; j < MAX_NOTIFCATIONS; j++) { for (int j = 0; j < MAX_NOTIFCATIONS; j++) { sendNotification(mNotifyId++, "testNotificationStressNotify"); sendNotification(mNotifyId++, "testNotificationStressNotify"); } } Thread.sleep(500); Thread.sleep(LONG_TIMEOUT); assertTrue(mNotificationManager.getActiveNotifications().length == MAX_NOTIFCATIONS); assertTrue(mNotificationManager.getActiveNotifications().length == MAX_NOTIFCATIONS); for (int j = 0; j < MAX_NOTIFCATIONS; j++) { for (int j = 0; j < MAX_NOTIFCATIONS; j++) { mNotificationManager.cancel(--mNotifyId); mNotificationManager.cancel(--mNotifyId); Loading @@ -124,7 +125,8 @@ public class NotificationStressTest extends InstrumentationTestCase { .setPriority(Notification.PRIORITY_HIGH) .setPriority(Notification.PRIORITY_HIGH) .build(); .build(); mNotificationManager.notify(id, notification); mNotificationManager.notify(id, notification); SystemClock.sleep(10); //update rate limit is 50 notifications/second. SystemClock.sleep(20); } } private boolean isLockScreen() { private boolean isLockScreen() { Loading Loading
core/tests/notificationtests/src/android/app/NotificationStressTest.java +7 −5 Original line number Original line Diff line number Diff line Loading @@ -40,9 +40,9 @@ public class NotificationStressTest extends InstrumentationTestCase { private static final int NUM_ITERATIONS = 200; private static final int NUM_ITERATIONS = 200; private static final int NUM_ITERATIONS_2 = 30; private static final int NUM_ITERATIONS_2 = 30; private static final int LONG_TIMEOUT = 2000; private static final int LONG_TIMEOUT = 2000; // 50 notifications per app: defined as Variable MAX_PACKAGE_NOTIFICATIONS in // 49 notifications per app: defined as Variable MAX_PACKAGE_NOTIFICATIONS in // NotificationManagerService.java // NotificationManagerService.java private static final int MAX_NOTIFCATIONS = 50; private static final int MAX_NOTIFCATIONS = 49; private static final int[] ICONS = new int[] { private static final int[] ICONS = new int[] { android.R.drawable.stat_notify_call_mute, android.R.drawable.stat_notify_call_mute, android.R.drawable.stat_notify_chat, android.R.drawable.stat_notify_chat, Loading Loading @@ -76,9 +76,10 @@ public class NotificationStressTest extends InstrumentationTestCase { @Override @Override protected void tearDown() throws Exception { protected void tearDown() throws Exception { super.tearDown(); mDevice.unfreezeRotation(); mDevice.unfreezeRotation(); mNotificationManager.cancelAll(); mNotificationManager.cancelAll(); mDevice.waitForIdle(); super.tearDown(); } } @RepetitiveTest(numIterations = NUM_ITERATIONS) @RepetitiveTest(numIterations = NUM_ITERATIONS) Loading @@ -97,7 +98,7 @@ public class NotificationStressTest extends InstrumentationTestCase { for (int j = 0; j < MAX_NOTIFCATIONS; j++) { for (int j = 0; j < MAX_NOTIFCATIONS; j++) { sendNotification(mNotifyId++, "testNotificationStressNotify"); sendNotification(mNotifyId++, "testNotificationStressNotify"); } } Thread.sleep(500); Thread.sleep(LONG_TIMEOUT); assertTrue(mNotificationManager.getActiveNotifications().length == MAX_NOTIFCATIONS); assertTrue(mNotificationManager.getActiveNotifications().length == MAX_NOTIFCATIONS); for (int j = 0; j < MAX_NOTIFCATIONS; j++) { for (int j = 0; j < MAX_NOTIFCATIONS; j++) { mNotificationManager.cancel(--mNotifyId); mNotificationManager.cancel(--mNotifyId); Loading @@ -124,7 +125,8 @@ public class NotificationStressTest extends InstrumentationTestCase { .setPriority(Notification.PRIORITY_HIGH) .setPriority(Notification.PRIORITY_HIGH) .build(); .build(); mNotificationManager.notify(id, notification); mNotificationManager.notify(id, notification); SystemClock.sleep(10); //update rate limit is 50 notifications/second. SystemClock.sleep(20); } } private boolean isLockScreen() { private boolean isLockScreen() { Loading