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

Commit dd3d5d86 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi
Browse files

NotificationManagerServiceTest: fix notification playback test

When mocking AudioManager's interactions to test notification
playback, also mock AudioManager.shouldNotificationPlay

Bug: 321171060
Test: atest com.android.server.notification.NotificationManagerServiceTest#testOnBubbleMetadataChangedToSuppressNotification_soundStopped
Test: atest com.android.server.notification.NotificationManagerServiceTest#testOnBubbleMetadataChangedToSuppressNotification_soundStopped_NAHRefactor

Change-Id: I950c92f25ba07df729cba232c8efb1fe76fc89d6
parent 18347dfd
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -9741,8 +9741,11 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
            throws RemoteException {
        IRingtonePlayer mockPlayer = mock(IRingtonePlayer.class);
        when(mAudioManager.getRingtonePlayer()).thenReturn(mockPlayer);
        // Set up volume to be above 0 for the sound to actually play
        // Set up volume to be above 0, and for AudioManager to signal playback should happen,
        // for the sound to actually play
        when(mAudioManager.getStreamVolume(anyInt())).thenReturn(10);
        when(mAudioManager.shouldNotificationSoundPlay(any(android.media.AudioAttributes.class)))
                .thenReturn(true);
        setUpPrefsForBubbles(PKG, mUid,
                true /* global */,