Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 55725128 authored by Bennie Ouyang's avatar Bennie Ouyang Committed by android-build-merger
Browse files

Merge \"Fixed notificaiton Stress Test\" into nyc-dev

am: 2f59ee10

Change-Id: I4629e78b47f23624638955d1f7bdabfb8cb86b4b
parents 354cd888 2f59ee10
Loading
Loading
Loading
Loading
+7 −5
Original line number Original line Diff line number Diff line
@@ -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,
@@ -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)
@@ -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);
@@ -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() {