Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationListViewModelTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -506,7 +506,7 @@ class NotificationListViewModelTest(flags: FlagsParameterization) : SysuiTestCas @EnableSceneContainer fun pinnedHeadsUpRows_filtersForPinnedItems() = testScope.runTest { val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRows) val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRowKeys) // WHEN there are no pinned rows val rows = Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/domain/interactor/HeadsUpNotificationInteractor.kt +26 −9 Original line number Diff line number Diff line Loading @@ -39,10 +39,10 @@ class HeadsUpNotificationInteractor @Inject constructor( private val headsUpRepository: HeadsUpRepository, private val faceAuthInteractor: DeviceEntryFaceAuthInteractor, private val keyguardTransitionInteractor: KeyguardTransitionInteractor, private val notificationsKeyguardInteractor: NotificationsKeyguardInteractor, private val shadeInteractor: ShadeInteractor, faceAuthInteractor: DeviceEntryFaceAuthInteractor, keyguardTransitionInteractor: KeyguardTransitionInteractor, notificationsKeyguardInteractor: NotificationsKeyguardInteractor, shadeInteractor: ShadeInteractor, ) { /** The top-ranked heads up row, regardless of pinned state */ Loading @@ -56,8 +56,7 @@ constructor( } .distinctUntilChanged() /** Set of currently pinned top-level heads up rows to be displayed. */ val pinnedHeadsUpRows: Flow<Set<HeadsUpRowKey>> by lazy { private val activeHeadsUpRows: Flow<Set<Pair<HeadsUpRowKey, Boolean>>> by lazy { if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) { flowOf(emptySet()) } else { Loading @@ -67,9 +66,7 @@ constructor( repositories.map { repo -> repo.isPinned.map { isPinned -> repo to isPinned } } combine(toCombine) { pairs -> pairs.filter { (_, isPinned) -> isPinned }.map { (repo, _) -> repo }.toSet() } combine(toCombine) { pairs -> pairs.toSet() } } else { // if the set is empty, there are no flows to combine flowOf(emptySet()) Loading @@ -78,6 +75,26 @@ constructor( } } /** Set of currently active top-level heads up rows to be displayed. */ val activeHeadsUpRowKeys: Flow<Set<HeadsUpRowKey>> by lazy { if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) { flowOf(emptySet()) } else { activeHeadsUpRows.map { it.map { (repo, _) -> repo }.toSet() } } } /** Set of currently pinned top-level heads up rows to be displayed. */ val pinnedHeadsUpRowKeys: Flow<Set<HeadsUpRowKey>> by lazy { if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) { flowOf(emptySet()) } else { activeHeadsUpRows.map { it.filter { (_, isPinned) -> isPinned }.map { (repo, _) -> repo }.toSet() } } } /** Are there any pinned heads up rows to display? */ val hasPinnedRows: Flow<Boolean> by lazy { if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) { Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationListViewModel.kt +14 −2 Original line number Diff line number Diff line Loading @@ -356,11 +356,23 @@ constructor( } } val pinnedHeadsUpRows: Flow<Set<HeadsUpRowKey>> by lazy { val activeHeadsUpRowKeys: Flow<Set<HeadsUpRowKey>> by lazy { if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) { flowOf(emptySet()) } else { headsUpNotificationInteractor.pinnedHeadsUpRows.dumpWhileCollecting("pinnedHeadsUpRows") headsUpNotificationInteractor.activeHeadsUpRowKeys.dumpWhileCollecting( "pinnedHeadsUpRows" ) } } val pinnedHeadsUpRowKeys: Flow<Set<HeadsUpRowKey>> by lazy { if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) { flowOf(emptySet()) } else { headsUpNotificationInteractor.pinnedHeadsUpRowKeys.dumpWhileCollecting( "pinnedHeadsUpRows" ) } } Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/ui/viewbinder/HeadsUpNotificationViewBinder.kt +9 −5 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import javax.inject.Inject import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.launch class HeadsUpNotificationViewBinder Loading @@ -35,18 +36,21 @@ constructor(private val viewModel: NotificationListViewModel) { coroutineScope { launch { var previousKeys = emptySet<HeadsUpRowKey>() viewModel.pinnedHeadsUpRows combine(viewModel.pinnedHeadsUpRowKeys, viewModel.activeHeadsUpRowKeys, ::Pair) .sample(viewModel.headsUpAnimationsEnabled, ::Pair) .collect { (newKeys, animationsEnabled) -> val added = newKeys - previousKeys val removed = previousKeys - newKeys previousKeys = newKeys val pinned = newKeys.first val all = newKeys.second val added = all.union(pinned) - previousKeys val removed = previousKeys - pinned previousKeys = pinned Pair(added, removed) if (animationsEnabled) { added.forEach { key -> parentView.generateHeadsUpAnimation( obtainView(key), /* isHeadsUp = */ true /* isHeadsUp = */ true, ) } removed.forEach { key -> Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/domain/interactor/HeadsUpNotificationInteractorTest.kt +116 −7 Original line number Diff line number Diff line Loading @@ -145,10 +145,18 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() { assertThat(hasPinnedRows).isFalse() } @Test fun activeRows_noRows_isEmpty() = testScope.runTest { val activeHeadsUpRows by collectLastValue(underTest.activeHeadsUpRowKeys) assertThat(activeHeadsUpRows).isEmpty() } @Test fun pinnedRows_noRows_isEmpty() = testScope.runTest { val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRows) val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRowKeys) assertThat(pinnedHeadsUpRows).isEmpty() } Loading @@ -156,7 +164,7 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() { @Test fun pinnedRows_noPinnedRows_isEmpty() = testScope.runTest { val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRows) val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRowKeys) // WHEN no rows are pinned headsUpRepository.setNotifications( fakeHeadsUpRowRepository("key 0"), Loading @@ -169,10 +177,28 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() { assertThat(pinnedHeadsUpRows).isEmpty() } @Test fun activeRows_noPinnedRows_containsAllRows() = testScope.runTest { val activeHeadsUpRows by collectLastValue(underTest.activeHeadsUpRowKeys) // WHEN no rows are pinned val rows = arrayListOf( fakeHeadsUpRowRepository("key 0"), fakeHeadsUpRowRepository("key 1"), fakeHeadsUpRowRepository("key 2"), ) headsUpRepository.setNotifications(rows) runCurrent() // THEN all rows are present assertThat(activeHeadsUpRows).containsExactly(rows[0], rows[1], rows[2]) } @Test fun pinnedRows_hasPinnedRows_containsPinnedRows() = testScope.runTest { val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRows) val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRowKeys) // WHEN some rows are pinned val rows = arrayListOf( Loading @@ -187,10 +213,28 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() { assertThat(pinnedHeadsUpRows).containsExactly(rows[0], rows[1]) } @Test fun pinnedRows_hasPinnedRows_containsAllRows() = testScope.runTest { val activeHeadsUpRows by collectLastValue(underTest.activeHeadsUpRowKeys) // WHEN no rows are pinned val rows = arrayListOf( fakeHeadsUpRowRepository("key 0", isPinned = true), fakeHeadsUpRowRepository("key 1", isPinned = true), fakeHeadsUpRowRepository("key 2"), ) headsUpRepository.setNotifications(rows) runCurrent() // THEN all rows are present assertThat(activeHeadsUpRows).containsExactly(rows[0], rows[1], rows[2]) } @Test fun pinnedRows_rowGetsPinned_containsPinnedRows() = testScope.runTest { val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRows) val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRowKeys) // GIVEN some rows are pinned val rows = arrayListOf( Loading @@ -209,10 +253,35 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() { assertThat(pinnedHeadsUpRows).containsExactly(rows[0], rows[1], rows[2]) } @Test fun activeRows_rowGetsPinned_containsAllRows() = testScope.runTest { val activeHeadsUpRows by collectLastValue(underTest.activeHeadsUpRowKeys) // GIVEN some rows are pinned val rows = arrayListOf( fakeHeadsUpRowRepository("key 0", isPinned = true), fakeHeadsUpRowRepository("key 1", isPinned = true), fakeHeadsUpRowRepository("key 2"), ) headsUpRepository.setNotifications(rows) runCurrent() // THEN all rows are present assertThat(activeHeadsUpRows).containsExactly(rows[0], rows[1], rows[2]) // WHEN all rows gets pinned rows[2].isPinned.value = true runCurrent() // THEN no change assertThat(activeHeadsUpRows).containsExactly(rows[0], rows[1], rows[2]) } @Test fun pinnedRows_allRowsPinned_containsAllRows() = testScope.runTest { val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRows) val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRowKeys) // WHEN all rows are pinned val rows = arrayListOf( Loading @@ -227,10 +296,28 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() { assertThat(pinnedHeadsUpRows).containsExactly(rows[0], rows[1], rows[2]) } @Test fun activeRows_allRowsPinned_containsAllRows() = testScope.runTest { val activeHeadsUpRows by collectLastValue(underTest.activeHeadsUpRowKeys) // WHEN all rows are pinned val rows = arrayListOf( fakeHeadsUpRowRepository("key 0", isPinned = true), fakeHeadsUpRowRepository("key 1", isPinned = true), fakeHeadsUpRowRepository("key 2", isPinned = true), ) headsUpRepository.setNotifications(rows) runCurrent() // THEN no rows are filtered assertThat(activeHeadsUpRows).containsExactly(rows[0], rows[1], rows[2]) } @Test fun pinnedRows_rowGetsUnPinned_containsPinnedRows() = testScope.runTest { val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRows) val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRowKeys) // GIVEN all rows are pinned val rows = arrayListOf( Loading @@ -249,10 +336,32 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() { assertThat(pinnedHeadsUpRows).containsExactly(rows[1], rows[2]) } @Test fun activeRows_rowGetsUnPinned_containsAllRows() = testScope.runTest { val activeHeadsUpRows by collectLastValue(underTest.activeHeadsUpRowKeys) // GIVEN all rows are pinned val rows = arrayListOf( fakeHeadsUpRowRepository("key 0", isPinned = true), fakeHeadsUpRowRepository("key 1", isPinned = true), fakeHeadsUpRowRepository("key 2", isPinned = true), ) headsUpRepository.setNotifications(rows) runCurrent() // WHEN a row gets unpinned rows[0].isPinned.value = false runCurrent() // THEN all rows are still present assertThat(activeHeadsUpRows).containsExactly(rows[0], rows[1], rows[2]) } @Test fun pinnedRows_rowGetsPinnedAndUnPinned_containsTheSameInstance() = testScope.runTest { val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRows) val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRowKeys) val rows = arrayListOf( Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationListViewModelTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -506,7 +506,7 @@ class NotificationListViewModelTest(flags: FlagsParameterization) : SysuiTestCas @EnableSceneContainer fun pinnedHeadsUpRows_filtersForPinnedItems() = testScope.runTest { val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRows) val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRowKeys) // WHEN there are no pinned rows val rows = Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/domain/interactor/HeadsUpNotificationInteractor.kt +26 −9 Original line number Diff line number Diff line Loading @@ -39,10 +39,10 @@ class HeadsUpNotificationInteractor @Inject constructor( private val headsUpRepository: HeadsUpRepository, private val faceAuthInteractor: DeviceEntryFaceAuthInteractor, private val keyguardTransitionInteractor: KeyguardTransitionInteractor, private val notificationsKeyguardInteractor: NotificationsKeyguardInteractor, private val shadeInteractor: ShadeInteractor, faceAuthInteractor: DeviceEntryFaceAuthInteractor, keyguardTransitionInteractor: KeyguardTransitionInteractor, notificationsKeyguardInteractor: NotificationsKeyguardInteractor, shadeInteractor: ShadeInteractor, ) { /** The top-ranked heads up row, regardless of pinned state */ Loading @@ -56,8 +56,7 @@ constructor( } .distinctUntilChanged() /** Set of currently pinned top-level heads up rows to be displayed. */ val pinnedHeadsUpRows: Flow<Set<HeadsUpRowKey>> by lazy { private val activeHeadsUpRows: Flow<Set<Pair<HeadsUpRowKey, Boolean>>> by lazy { if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) { flowOf(emptySet()) } else { Loading @@ -67,9 +66,7 @@ constructor( repositories.map { repo -> repo.isPinned.map { isPinned -> repo to isPinned } } combine(toCombine) { pairs -> pairs.filter { (_, isPinned) -> isPinned }.map { (repo, _) -> repo }.toSet() } combine(toCombine) { pairs -> pairs.toSet() } } else { // if the set is empty, there are no flows to combine flowOf(emptySet()) Loading @@ -78,6 +75,26 @@ constructor( } } /** Set of currently active top-level heads up rows to be displayed. */ val activeHeadsUpRowKeys: Flow<Set<HeadsUpRowKey>> by lazy { if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) { flowOf(emptySet()) } else { activeHeadsUpRows.map { it.map { (repo, _) -> repo }.toSet() } } } /** Set of currently pinned top-level heads up rows to be displayed. */ val pinnedHeadsUpRowKeys: Flow<Set<HeadsUpRowKey>> by lazy { if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) { flowOf(emptySet()) } else { activeHeadsUpRows.map { it.filter { (_, isPinned) -> isPinned }.map { (repo, _) -> repo }.toSet() } } } /** Are there any pinned heads up rows to display? */ val hasPinnedRows: Flow<Boolean> by lazy { if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) { Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationListViewModel.kt +14 −2 Original line number Diff line number Diff line Loading @@ -356,11 +356,23 @@ constructor( } } val pinnedHeadsUpRows: Flow<Set<HeadsUpRowKey>> by lazy { val activeHeadsUpRowKeys: Flow<Set<HeadsUpRowKey>> by lazy { if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) { flowOf(emptySet()) } else { headsUpNotificationInteractor.pinnedHeadsUpRows.dumpWhileCollecting("pinnedHeadsUpRows") headsUpNotificationInteractor.activeHeadsUpRowKeys.dumpWhileCollecting( "pinnedHeadsUpRows" ) } } val pinnedHeadsUpRowKeys: Flow<Set<HeadsUpRowKey>> by lazy { if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) { flowOf(emptySet()) } else { headsUpNotificationInteractor.pinnedHeadsUpRowKeys.dumpWhileCollecting( "pinnedHeadsUpRows" ) } } Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/ui/viewbinder/HeadsUpNotificationViewBinder.kt +9 −5 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import javax.inject.Inject import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.launch class HeadsUpNotificationViewBinder Loading @@ -35,18 +36,21 @@ constructor(private val viewModel: NotificationListViewModel) { coroutineScope { launch { var previousKeys = emptySet<HeadsUpRowKey>() viewModel.pinnedHeadsUpRows combine(viewModel.pinnedHeadsUpRowKeys, viewModel.activeHeadsUpRowKeys, ::Pair) .sample(viewModel.headsUpAnimationsEnabled, ::Pair) .collect { (newKeys, animationsEnabled) -> val added = newKeys - previousKeys val removed = previousKeys - newKeys previousKeys = newKeys val pinned = newKeys.first val all = newKeys.second val added = all.union(pinned) - previousKeys val removed = previousKeys - pinned previousKeys = pinned Pair(added, removed) if (animationsEnabled) { added.forEach { key -> parentView.generateHeadsUpAnimation( obtainView(key), /* isHeadsUp = */ true /* isHeadsUp = */ true, ) } removed.forEach { key -> Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/domain/interactor/HeadsUpNotificationInteractorTest.kt +116 −7 Original line number Diff line number Diff line Loading @@ -145,10 +145,18 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() { assertThat(hasPinnedRows).isFalse() } @Test fun activeRows_noRows_isEmpty() = testScope.runTest { val activeHeadsUpRows by collectLastValue(underTest.activeHeadsUpRowKeys) assertThat(activeHeadsUpRows).isEmpty() } @Test fun pinnedRows_noRows_isEmpty() = testScope.runTest { val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRows) val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRowKeys) assertThat(pinnedHeadsUpRows).isEmpty() } Loading @@ -156,7 +164,7 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() { @Test fun pinnedRows_noPinnedRows_isEmpty() = testScope.runTest { val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRows) val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRowKeys) // WHEN no rows are pinned headsUpRepository.setNotifications( fakeHeadsUpRowRepository("key 0"), Loading @@ -169,10 +177,28 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() { assertThat(pinnedHeadsUpRows).isEmpty() } @Test fun activeRows_noPinnedRows_containsAllRows() = testScope.runTest { val activeHeadsUpRows by collectLastValue(underTest.activeHeadsUpRowKeys) // WHEN no rows are pinned val rows = arrayListOf( fakeHeadsUpRowRepository("key 0"), fakeHeadsUpRowRepository("key 1"), fakeHeadsUpRowRepository("key 2"), ) headsUpRepository.setNotifications(rows) runCurrent() // THEN all rows are present assertThat(activeHeadsUpRows).containsExactly(rows[0], rows[1], rows[2]) } @Test fun pinnedRows_hasPinnedRows_containsPinnedRows() = testScope.runTest { val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRows) val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRowKeys) // WHEN some rows are pinned val rows = arrayListOf( Loading @@ -187,10 +213,28 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() { assertThat(pinnedHeadsUpRows).containsExactly(rows[0], rows[1]) } @Test fun pinnedRows_hasPinnedRows_containsAllRows() = testScope.runTest { val activeHeadsUpRows by collectLastValue(underTest.activeHeadsUpRowKeys) // WHEN no rows are pinned val rows = arrayListOf( fakeHeadsUpRowRepository("key 0", isPinned = true), fakeHeadsUpRowRepository("key 1", isPinned = true), fakeHeadsUpRowRepository("key 2"), ) headsUpRepository.setNotifications(rows) runCurrent() // THEN all rows are present assertThat(activeHeadsUpRows).containsExactly(rows[0], rows[1], rows[2]) } @Test fun pinnedRows_rowGetsPinned_containsPinnedRows() = testScope.runTest { val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRows) val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRowKeys) // GIVEN some rows are pinned val rows = arrayListOf( Loading @@ -209,10 +253,35 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() { assertThat(pinnedHeadsUpRows).containsExactly(rows[0], rows[1], rows[2]) } @Test fun activeRows_rowGetsPinned_containsAllRows() = testScope.runTest { val activeHeadsUpRows by collectLastValue(underTest.activeHeadsUpRowKeys) // GIVEN some rows are pinned val rows = arrayListOf( fakeHeadsUpRowRepository("key 0", isPinned = true), fakeHeadsUpRowRepository("key 1", isPinned = true), fakeHeadsUpRowRepository("key 2"), ) headsUpRepository.setNotifications(rows) runCurrent() // THEN all rows are present assertThat(activeHeadsUpRows).containsExactly(rows[0], rows[1], rows[2]) // WHEN all rows gets pinned rows[2].isPinned.value = true runCurrent() // THEN no change assertThat(activeHeadsUpRows).containsExactly(rows[0], rows[1], rows[2]) } @Test fun pinnedRows_allRowsPinned_containsAllRows() = testScope.runTest { val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRows) val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRowKeys) // WHEN all rows are pinned val rows = arrayListOf( Loading @@ -227,10 +296,28 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() { assertThat(pinnedHeadsUpRows).containsExactly(rows[0], rows[1], rows[2]) } @Test fun activeRows_allRowsPinned_containsAllRows() = testScope.runTest { val activeHeadsUpRows by collectLastValue(underTest.activeHeadsUpRowKeys) // WHEN all rows are pinned val rows = arrayListOf( fakeHeadsUpRowRepository("key 0", isPinned = true), fakeHeadsUpRowRepository("key 1", isPinned = true), fakeHeadsUpRowRepository("key 2", isPinned = true), ) headsUpRepository.setNotifications(rows) runCurrent() // THEN no rows are filtered assertThat(activeHeadsUpRows).containsExactly(rows[0], rows[1], rows[2]) } @Test fun pinnedRows_rowGetsUnPinned_containsPinnedRows() = testScope.runTest { val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRows) val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRowKeys) // GIVEN all rows are pinned val rows = arrayListOf( Loading @@ -249,10 +336,32 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() { assertThat(pinnedHeadsUpRows).containsExactly(rows[1], rows[2]) } @Test fun activeRows_rowGetsUnPinned_containsAllRows() = testScope.runTest { val activeHeadsUpRows by collectLastValue(underTest.activeHeadsUpRowKeys) // GIVEN all rows are pinned val rows = arrayListOf( fakeHeadsUpRowRepository("key 0", isPinned = true), fakeHeadsUpRowRepository("key 1", isPinned = true), fakeHeadsUpRowRepository("key 2", isPinned = true), ) headsUpRepository.setNotifications(rows) runCurrent() // WHEN a row gets unpinned rows[0].isPinned.value = false runCurrent() // THEN all rows are still present assertThat(activeHeadsUpRows).containsExactly(rows[0], rows[1], rows[2]) } @Test fun pinnedRows_rowGetsPinnedAndUnPinned_containsTheSameInstance() = testScope.runTest { val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRows) val pinnedHeadsUpRows by collectLastValue(underTest.pinnedHeadsUpRowKeys) val rows = arrayListOf( Loading