From 131d38bdea87bbfd0dc44665db863924ab1af9c1 Mon Sep 17 00:00:00 2001 From: Evan Laird Date: Wed, 24 Jun 2020 23:40:30 -0400 Subject: [PATCH] Sleep in between calls to NoMan service in test NotificationManagerService has a non-mockable relationship to System.currentTimeMillis and this test assumes that calls into the service will not happen in the same millisecond. The fix here is to sleep for 1ms in between calls to ensure that the clock advances. Test: atest --rerun-until-failure 100 NotificationManagerServiceTest Bug: 155331470 Change-Id: Ica6b26a3d72295b0be52c6b1579dde30447ddeaf --- .../server/notification/NotificationManagerServiceTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java index ef4d5db2f32f1..16aa87b3e59cf 100755 --- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java @@ -1339,14 +1339,15 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { } @Test - @Ignore public void testPostCancelPostNotifiesListeners() throws Exception { // WHEN a notification is posted final StatusBarNotification sbn = generateNotificationRecord(null).getSbn(); mBinderService.enqueueNotificationWithTag(PKG, PKG, "tag", sbn.getId(), sbn.getNotification(), sbn.getUserId()); + Thread.sleep(1); // make sure the system clock advances before the next step // THEN it is canceled mBinderService.cancelNotificationWithTag(PKG, PKG, "tag", sbn.getId(), sbn.getUserId()); + Thread.sleep(1); // here too // THEN it is posted again (before the cancel has a chance to finish) mBinderService.enqueueNotificationWithTag(PKG, PKG, "tag", sbn.getId(), sbn.getNotification(), sbn.getUserId());