From 067dd37f5f0382ff9f0da25042a673a5f9254140 Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Tue, 9 Nov 2021 12:40:14 -0500 Subject: [PATCH] Don't register broadcast receivers Real receivers can cause code to run at times that cause test flakiness Test: atest, a lot Fixes: 195403581 Change-Id: I2fb079e86ff51dcab060a88480c7aabc587bb697 --- .../server/notification/NotificationManagerServiceTest.java | 4 ++++ 1 file changed, 4 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 def38a6427a73..7237b243512c2 100755 --- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java @@ -214,6 +214,7 @@ import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.InOrder; import org.mockito.Mock; +import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.mockito.stubbing.Answer; @@ -478,6 +479,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { ArgumentCaptor intentFilterCaptor = ArgumentCaptor.forClass(IntentFilter.class); + Mockito.doReturn(new Intent()).when(mContext).registerReceiverAsUser( + any(), any(), any(), any(), any()); + Mockito.doReturn(new Intent()).when(mContext).registerReceiver(any(), any()); verify(mContext, atLeastOnce()).registerReceiverAsUser(broadcastReceiverCaptor.capture(), any(), intentFilterCaptor.capture(), any(), any()); verify(mContext, atLeastOnce()).registerReceiver(broadcastReceiverCaptor.capture(),