Loading packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/LegacyMediaDataManagerImplTest.kt +33 −0 Original line number Diff line number Diff line Loading @@ -235,6 +235,7 @@ class LegacyMediaDataManagerImplTest(flags: FlagsParameterization) : SysuiTestCa modifyNotification(context).also { it.setSmallIcon(android.R.drawable.ic_media_pause) it.setStyle(MediaStyle().apply { setMediaSession(session.sessionToken) }) it.setContentIntent(getNewPendingIntent()) } build() } Loading Loading @@ -2156,6 +2157,28 @@ class LegacyMediaDataManagerImplTest(flags: FlagsParameterization) : SysuiTestCa verify(kosmos.mediaLogger, never()).logDuplicateMediaNotification(eq(KEY)) } @Test @EnableFlags(Flags.FLAG_MEDIA_CONTROLS_POSTS_OPTIMIZATION) fun postDifferentIntentNotifications_CallsListeners() { addNotificationAndLoad() reset(listener) mediaNotification = mediaNotification.also { it.notification.contentIntent = getNewPendingIntent() } mediaDataManager.onNotificationAdded(KEY, mediaNotification) testScope.assertRunAllReady(foreground = 1, background = 1) verify(listener) .onMediaDataLoaded( eq(KEY), eq(KEY), capture(mediaDataCaptor), eq(true), eq(0), eq(false), ) verify(kosmos.mediaLogger, never()).logDuplicateMediaNotification(eq(KEY)) } private fun TestScope.assertRunAllReady(foreground: Int = 0, background: Int = 0) { runCurrent() if (Flags.mediaLoadMetadataViaMediaDataLoader()) { Loading Loading @@ -2235,4 +2258,14 @@ class LegacyMediaDataManagerImplTest(flags: FlagsParameterization) : SysuiTestCa backgroundExecutor.runAllReady() foregroundExecutor.runAllReady() } private fun getNewPendingIntent(): PendingIntent { val intent = Intent().setAction(null) return PendingIntent.getBroadcast( mContext, 1, intent, PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE, ) } } packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/MediaDataProcessorTest.kt +39 −0 Original line number Diff line number Diff line Loading @@ -251,6 +251,7 @@ class MediaDataProcessorTest(flags: FlagsParameterization) : SysuiTestCase() { verify(mediaTimeoutListener).stateCallback = capture(stateCallbackCaptor) verify(mediaTimeoutListener).sessionCallback = capture(sessionCallbackCaptor) session = MediaSession(context, "MediaDataProcessorTestSession") mediaNotification = SbnBuilder().run { setUser(UserHandle(USER_ID)) Loading @@ -258,6 +259,7 @@ class MediaDataProcessorTest(flags: FlagsParameterization) : SysuiTestCase() { modifyNotification(context).also { it.setSmallIcon(android.R.drawable.ic_media_pause) it.setStyle(MediaStyle().apply { setMediaSession(session.sessionToken) }) it.setContentIntent(getNewPendingIntent()) } build() } Loading Loading @@ -2250,6 +2252,33 @@ class MediaDataProcessorTest(flags: FlagsParameterization) : SysuiTestCase() { verify(kosmos.mediaLogger, never()).logDuplicateMediaNotification(eq(KEY)) } @Test @EnableFlags(Flags.FLAG_MEDIA_CONTROLS_POSTS_OPTIMIZATION) fun postDifferentIntentNotifications_CallsListeners() { whenever(notificationLockscreenUserManager.isCurrentProfile(USER_ID)).thenReturn(true) whenever(notificationLockscreenUserManager.isProfileAvailable(USER_ID)).thenReturn(true) mediaDataProcessor.addInternalListener(mediaDataFilter) mediaDataFilter.mediaDataProcessor = mediaDataProcessor addNotificationAndLoad() reset(listener) mediaNotification = mediaNotification.also { it.notification.contentIntent = getNewPendingIntent() } mediaDataProcessor.onNotificationAdded(KEY, mediaNotification) testScope.assertRunAllReady(foreground = 1, background = 1) verify(listener) .onMediaDataLoaded( eq(KEY), eq(KEY), capture(mediaDataCaptor), eq(true), eq(0), eq(false), ) verify(kosmos.mediaLogger, never()).logDuplicateMediaNotification(eq(KEY)) } private fun TestScope.assertRunAllReady(foreground: Int = 0, background: Int = 0) { runCurrent() if (Flags.mediaLoadMetadataViaMediaDataLoader()) { Loading Loading @@ -2329,4 +2358,14 @@ class MediaDataProcessorTest(flags: FlagsParameterization) : SysuiTestCase() { runCurrent() advanceUntilIdle() } private fun getNewPendingIntent(): PendingIntent { val intent = Intent().setAction(null) return PendingIntent.getBroadcast( mContext, 1, intent, PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE, ) } } Loading
packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/LegacyMediaDataManagerImplTest.kt +33 −0 Original line number Diff line number Diff line Loading @@ -235,6 +235,7 @@ class LegacyMediaDataManagerImplTest(flags: FlagsParameterization) : SysuiTestCa modifyNotification(context).also { it.setSmallIcon(android.R.drawable.ic_media_pause) it.setStyle(MediaStyle().apply { setMediaSession(session.sessionToken) }) it.setContentIntent(getNewPendingIntent()) } build() } Loading Loading @@ -2156,6 +2157,28 @@ class LegacyMediaDataManagerImplTest(flags: FlagsParameterization) : SysuiTestCa verify(kosmos.mediaLogger, never()).logDuplicateMediaNotification(eq(KEY)) } @Test @EnableFlags(Flags.FLAG_MEDIA_CONTROLS_POSTS_OPTIMIZATION) fun postDifferentIntentNotifications_CallsListeners() { addNotificationAndLoad() reset(listener) mediaNotification = mediaNotification.also { it.notification.contentIntent = getNewPendingIntent() } mediaDataManager.onNotificationAdded(KEY, mediaNotification) testScope.assertRunAllReady(foreground = 1, background = 1) verify(listener) .onMediaDataLoaded( eq(KEY), eq(KEY), capture(mediaDataCaptor), eq(true), eq(0), eq(false), ) verify(kosmos.mediaLogger, never()).logDuplicateMediaNotification(eq(KEY)) } private fun TestScope.assertRunAllReady(foreground: Int = 0, background: Int = 0) { runCurrent() if (Flags.mediaLoadMetadataViaMediaDataLoader()) { Loading Loading @@ -2235,4 +2258,14 @@ class LegacyMediaDataManagerImplTest(flags: FlagsParameterization) : SysuiTestCa backgroundExecutor.runAllReady() foregroundExecutor.runAllReady() } private fun getNewPendingIntent(): PendingIntent { val intent = Intent().setAction(null) return PendingIntent.getBroadcast( mContext, 1, intent, PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE, ) } }
packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/MediaDataProcessorTest.kt +39 −0 Original line number Diff line number Diff line Loading @@ -251,6 +251,7 @@ class MediaDataProcessorTest(flags: FlagsParameterization) : SysuiTestCase() { verify(mediaTimeoutListener).stateCallback = capture(stateCallbackCaptor) verify(mediaTimeoutListener).sessionCallback = capture(sessionCallbackCaptor) session = MediaSession(context, "MediaDataProcessorTestSession") mediaNotification = SbnBuilder().run { setUser(UserHandle(USER_ID)) Loading @@ -258,6 +259,7 @@ class MediaDataProcessorTest(flags: FlagsParameterization) : SysuiTestCase() { modifyNotification(context).also { it.setSmallIcon(android.R.drawable.ic_media_pause) it.setStyle(MediaStyle().apply { setMediaSession(session.sessionToken) }) it.setContentIntent(getNewPendingIntent()) } build() } Loading Loading @@ -2250,6 +2252,33 @@ class MediaDataProcessorTest(flags: FlagsParameterization) : SysuiTestCase() { verify(kosmos.mediaLogger, never()).logDuplicateMediaNotification(eq(KEY)) } @Test @EnableFlags(Flags.FLAG_MEDIA_CONTROLS_POSTS_OPTIMIZATION) fun postDifferentIntentNotifications_CallsListeners() { whenever(notificationLockscreenUserManager.isCurrentProfile(USER_ID)).thenReturn(true) whenever(notificationLockscreenUserManager.isProfileAvailable(USER_ID)).thenReturn(true) mediaDataProcessor.addInternalListener(mediaDataFilter) mediaDataFilter.mediaDataProcessor = mediaDataProcessor addNotificationAndLoad() reset(listener) mediaNotification = mediaNotification.also { it.notification.contentIntent = getNewPendingIntent() } mediaDataProcessor.onNotificationAdded(KEY, mediaNotification) testScope.assertRunAllReady(foreground = 1, background = 1) verify(listener) .onMediaDataLoaded( eq(KEY), eq(KEY), capture(mediaDataCaptor), eq(true), eq(0), eq(false), ) verify(kosmos.mediaLogger, never()).logDuplicateMediaNotification(eq(KEY)) } private fun TestScope.assertRunAllReady(foreground: Int = 0, background: Int = 0) { runCurrent() if (Flags.mediaLoadMetadataViaMediaDataLoader()) { Loading Loading @@ -2329,4 +2358,14 @@ class MediaDataProcessorTest(flags: FlagsParameterization) : SysuiTestCase() { runCurrent() advanceUntilIdle() } private fun getNewPendingIntent(): PendingIntent { val intent = Intent().setAction(null) return PendingIntent.getBroadcast( mContext, 1, intent, PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE, ) } }