From e4444e087e6778913a41a96398a9fdfa8e5104e1 Mon Sep 17 00:00:00 2001 From: Yuri Lin Date: Tue, 10 May 2022 12:18:17 -0400 Subject: [PATCH] Reset mock NM before each of the tests that checks it The review permission notification tests were sometimes failing otherwise Bug: 225373531 Test: NotificationManagerServiceTest Change-Id: Id35b6b7bd4a1f38886094b698e2c6da0fc702292 --- .../notification/NotificationManagerServiceTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 267a506752319..8854f0e329bae 100755 --- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java @@ -9574,6 +9574,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testMaybeShowReviewPermissionsNotification_unknown() { + reset(mMockNm); + // Set up various possible states of the settings int and confirm whether or not the // notification is shown as expected @@ -9587,6 +9589,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testMaybeShowReviewPermissionsNotification_shouldShow() { + reset(mMockNm); + // If state is SHOULD_SHOW, it ... should show Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.REVIEW_PERMISSIONS_NOTIFICATION_STATE, @@ -9599,6 +9603,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testMaybeShowReviewPermissionsNotification_alreadyShown() { + reset(mMockNm); + // If state is either USER_INTERACTED or DISMISSED, we should not show this on boot Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.REVIEW_PERMISSIONS_NOTIFICATION_STATE, @@ -9615,6 +9621,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testMaybeShowReviewPermissionsNotification_reshown() { + reset(mMockNm); + // If we have re-shown the notification and the user did not subsequently interacted with // it, then make sure we show when trying on boot Settings.Global.putInt(mContext.getContentResolver(), @@ -9628,6 +9636,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testRescheduledReviewPermissionsNotification() { + reset(mMockNm); + // when rescheduled, the notification goes through the NotificationManagerInternal service // this call doesn't need to know anything about previously scheduled state -- if called, // it should send the notification & write the appropriate int to Settings