diff options
| author | 2024-01-08 11:02:57 -0500 | |
|---|---|---|
| committer | 2024-01-09 10:51:54 -0500 | |
| commit | 32e13f64b43bbc9494b3a911252a9f3945743d17 (patch) | |
| tree | 65f7bc2758bd3ec28edba07f3dad7ef5e3c4c65d | |
| parent | b23efa4935f961a79409ad2e017aa5a0e743770a (diff) | |
MutableStateFlows in NotifKeyguardViewStateRepo
Fixes: 318098028
Flag: ACONFIG com.android.systemui.notifications_icon_container_refactor TEAMFOOD
Test: atest SystemUITests
Change-Id: I4cb1d638bba856ce49b4ae0743f0864a802c9398
14 files changed, 66 insertions, 238 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelTest.kt index 7c3dc972cfd0..5b88ebe69bfe 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelTest.kt @@ -32,7 +32,7 @@ import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.shared.model.TransitionState import com.android.systemui.keyguard.shared.model.TransitionStep import com.android.systemui.kosmos.testScope -import com.android.systemui.statusbar.notification.data.repository.fakeNotificationsKeyguardViewStateRepository +import com.android.systemui.statusbar.notification.stack.domain.interactor.notificationsKeyguardInteractor import com.android.systemui.statusbar.phone.dozeParameters import com.android.systemui.statusbar.phone.screenOffAnimationController import com.android.systemui.testKosmos @@ -56,8 +56,7 @@ class KeyguardRootViewModelTest : SysuiTestCase() { private val keyguardTransitionRepository = kosmos.fakeKeyguardTransitionRepository private val screenOffAnimationController = kosmos.screenOffAnimationController private val deviceEntryRepository = kosmos.fakeDeviceEntryRepository - private val fakeNotificationsKeyguardViewStateRepository = - kosmos.fakeNotificationsKeyguardViewStateRepository + private val notificationsKeyguardInteractor = kosmos.notificationsKeyguardInteractor private val dozeParameters = kosmos.dozeParameters private val underTest = kosmos.keyguardRootViewModel @@ -118,7 +117,7 @@ class KeyguardRootViewModelTest : SysuiTestCase() { testScope.runTest { val isVisible by collectLastValue(underTest.isNotifIconContainerVisible) runCurrent() - fakeNotificationsKeyguardViewStateRepository.setPulseExpanding(true) + notificationsKeyguardInteractor.setPulseExpanding(true) deviceEntryRepository.setBypassEnabled(false) runCurrent() @@ -130,9 +129,9 @@ class KeyguardRootViewModelTest : SysuiTestCase() { testScope.runTest { val isVisible by collectLastValue(underTest.isNotifIconContainerVisible) runCurrent() - fakeNotificationsKeyguardViewStateRepository.setPulseExpanding(false) + notificationsKeyguardInteractor.setPulseExpanding(false) deviceEntryRepository.setBypassEnabled(true) - fakeNotificationsKeyguardViewStateRepository.setNotificationsFullyHidden(true) + notificationsKeyguardInteractor.setNotificationsFullyHidden(true) runCurrent() assertThat(isVisible?.value).isTrue() @@ -144,10 +143,10 @@ class KeyguardRootViewModelTest : SysuiTestCase() { testScope.runTest { val isVisible by collectLastValue(underTest.isNotifIconContainerVisible) runCurrent() - fakeNotificationsKeyguardViewStateRepository.setPulseExpanding(false) + notificationsKeyguardInteractor.setPulseExpanding(false) deviceEntryRepository.setBypassEnabled(false) whenever(dozeParameters.alwaysOn).thenReturn(false) - fakeNotificationsKeyguardViewStateRepository.setNotificationsFullyHidden(true) + notificationsKeyguardInteractor.setNotificationsFullyHidden(true) runCurrent() assertThat(isVisible?.value).isTrue() @@ -159,11 +158,11 @@ class KeyguardRootViewModelTest : SysuiTestCase() { testScope.runTest { val isVisible by collectLastValue(underTest.isNotifIconContainerVisible) runCurrent() - fakeNotificationsKeyguardViewStateRepository.setPulseExpanding(false) + notificationsKeyguardInteractor.setPulseExpanding(false) deviceEntryRepository.setBypassEnabled(false) whenever(dozeParameters.alwaysOn).thenReturn(true) whenever(dozeParameters.displayNeedsBlanking).thenReturn(true) - fakeNotificationsKeyguardViewStateRepository.setNotificationsFullyHidden(true) + notificationsKeyguardInteractor.setNotificationsFullyHidden(true) runCurrent() assertThat(isVisible?.value).isTrue() @@ -175,11 +174,11 @@ class KeyguardRootViewModelTest : SysuiTestCase() { testScope.runTest { val isVisible by collectLastValue(underTest.isNotifIconContainerVisible) runCurrent() - fakeNotificationsKeyguardViewStateRepository.setPulseExpanding(false) + notificationsKeyguardInteractor.setPulseExpanding(false) deviceEntryRepository.setBypassEnabled(false) whenever(dozeParameters.alwaysOn).thenReturn(true) whenever(dozeParameters.displayNeedsBlanking).thenReturn(false) - fakeNotificationsKeyguardViewStateRepository.setNotificationsFullyHidden(true) + notificationsKeyguardInteractor.setNotificationsFullyHidden(true) runCurrent() assertThat(isVisible?.value).isTrue() @@ -191,11 +190,11 @@ class KeyguardRootViewModelTest : SysuiTestCase() { testScope.runTest { val isVisible by collectLastValue(underTest.isNotifIconContainerVisible) runCurrent() - fakeNotificationsKeyguardViewStateRepository.setPulseExpanding(false) + notificationsKeyguardInteractor.setPulseExpanding(false) deviceEntryRepository.setBypassEnabled(false) whenever(dozeParameters.alwaysOn).thenReturn(true) whenever(dozeParameters.displayNeedsBlanking).thenReturn(false) - fakeNotificationsKeyguardViewStateRepository.setNotificationsFullyHidden(true) + notificationsKeyguardInteractor.setNotificationsFullyHidden(true) runCurrent() assertThat(isVisible?.isAnimating).isEqualTo(true) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationWakeUpCoordinator.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationWakeUpCoordinator.kt index 0c67279c1660..3f2c818399d1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationWakeUpCoordinator.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationWakeUpCoordinator.kt @@ -31,6 +31,7 @@ import com.android.systemui.shade.ShadeExpansionListener import com.android.systemui.shade.ShadeViewController import com.android.systemui.statusbar.StatusBarState import com.android.systemui.statusbar.notification.collection.NotificationEntry +import com.android.systemui.statusbar.notification.domain.interactor.NotificationsKeyguardInteractor import com.android.systemui.statusbar.notification.shared.NotificationIconContainerRefactor import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController import com.android.systemui.statusbar.notification.stack.StackStateAnimator @@ -58,6 +59,7 @@ constructor( private val dozeParameters: DozeParameters, private val screenOffAnimationController: ScreenOffAnimationController, private val logger: NotificationWakeUpCoordinatorLogger, + private val notifsKeyguardInteractor: NotificationsKeyguardInteractor, ) : OnHeadsUpChangedListener, StatusBarStateController.StateListener, @@ -144,6 +146,7 @@ constructor( for (listener in wakeUpListeners) { listener.onFullyHiddenChanged(value) } + notifsKeyguardInteractor.setNotificationsFullyHidden(value) } } @@ -216,6 +219,7 @@ constructor( for (listener in wakeUpListeners) { listener.onPulseExpandingChanged(pulseExpanding) } + notifsKeyguardInteractor.setPulseExpanding(pulseExpanding) } } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/data/NotificationDataLayerModule.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/data/NotificationDataLayerModule.kt index 5435fb5449cd..2cac0002f013 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/data/NotificationDataLayerModule.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/data/NotificationDataLayerModule.kt @@ -15,8 +15,6 @@ */ package com.android.systemui.statusbar.notification.data -import com.android.systemui.statusbar.notification.data.repository.NotificationsKeyguardStateRepositoryModule import dagger.Module -@Module(includes = [NotificationsKeyguardStateRepositoryModule::class]) -interface NotificationDataLayerModule +@Module(includes = []) interface NotificationDataLayerModule diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/data/repository/NotificationsKeyguardViewStateRepository.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/data/repository/NotificationsKeyguardViewStateRepository.kt index 2cc1403a80a5..bd6ea30c44e6 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/data/repository/NotificationsKeyguardViewStateRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/data/repository/NotificationsKeyguardViewStateRepository.kt @@ -15,59 +15,16 @@ */ package com.android.systemui.statusbar.notification.data.repository -import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCallbackFlow import com.android.systemui.dagger.SysUISingleton -import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator -import dagger.Binds -import dagger.Module import javax.inject.Inject -import kotlinx.coroutines.channels.awaitClose -import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.MutableStateFlow /** View-states pertaining to notifications on the keyguard. */ -interface NotificationsKeyguardViewStateRepository { +@SysUISingleton +class NotificationsKeyguardViewStateRepository @Inject constructor() { /** Are notifications fully hidden from view? */ - val areNotificationsFullyHidden: Flow<Boolean> + val areNotificationsFullyHidden = MutableStateFlow(false) /** Is a pulse expansion occurring? */ - val isPulseExpanding: Flow<Boolean> -} - -@Module -interface NotificationsKeyguardStateRepositoryModule { - @Binds - fun bindImpl( - impl: NotificationsKeyguardViewStateRepositoryImpl - ): NotificationsKeyguardViewStateRepository -} - -@SysUISingleton -class NotificationsKeyguardViewStateRepositoryImpl -@Inject -constructor( - wakeUpCoordinator: NotificationWakeUpCoordinator, -) : NotificationsKeyguardViewStateRepository { - override val areNotificationsFullyHidden: Flow<Boolean> = conflatedCallbackFlow { - val listener = - object : NotificationWakeUpCoordinator.WakeUpListener { - override fun onFullyHiddenChanged(isFullyHidden: Boolean) { - trySend(isFullyHidden) - } - } - trySend(wakeUpCoordinator.notificationsFullyHidden) - wakeUpCoordinator.addListener(listener) - awaitClose { wakeUpCoordinator.removeListener(listener) } - } - - override val isPulseExpanding: Flow<Boolean> = conflatedCallbackFlow { - val listener = - object : NotificationWakeUpCoordinator.WakeUpListener { - override fun onPulseExpandingChanged(isPulseExpanding: Boolean) { - trySend(isPulseExpanding) - } - } - trySend(wakeUpCoordinator.isPulseExpanding()) - wakeUpCoordinator.addListener(listener) - awaitClose { wakeUpCoordinator.removeListener(listener) } - } + val isPulseExpanding = MutableStateFlow(false) } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/domain/interactor/NotificationsKeyguardInteractor.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/domain/interactor/NotificationsKeyguardInteractor.kt index 73341dbc4999..a6361cbc9f9c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/domain/interactor/NotificationsKeyguardInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/domain/interactor/NotificationsKeyguardInteractor.kt @@ -15,24 +15,29 @@ */ package com.android.systemui.statusbar.notification.domain.interactor -import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.statusbar.notification.data.repository.NotificationsKeyguardViewStateRepository import javax.inject.Inject -import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flowOn /** Domain logic pertaining to notifications on the keyguard. */ class NotificationsKeyguardInteractor @Inject constructor( - repository: NotificationsKeyguardViewStateRepository, - @Background backgroundDispatcher: CoroutineDispatcher, + private val repository: NotificationsKeyguardViewStateRepository, ) { /** Is a pulse expansion occurring? */ - val isPulseExpanding: Flow<Boolean> = repository.isPulseExpanding.flowOn(backgroundDispatcher) + val isPulseExpanding: Flow<Boolean> = repository.isPulseExpanding /** Are notifications fully hidden from view? */ - val areNotificationsFullyHidden: Flow<Boolean> = - repository.areNotificationsFullyHidden.flowOn(backgroundDispatcher) + val areNotificationsFullyHidden: Flow<Boolean> = repository.areNotificationsFullyHidden + + /** Updates whether notifications are fully hidden from view. */ + fun setNotificationsFullyHidden(fullyHidden: Boolean) { + repository.areNotificationsFullyHidden.value = fullyHidden + } + + /** Updates whether a pulse expansion is occurring. */ + fun setPulseExpanding(pulseExpanding: Boolean) { + repository.isPulseExpanding.value = pulseExpanding + } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java index 313276727caf..a20658197a8d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java @@ -152,7 +152,9 @@ import com.android.systemui.statusbar.notification.ConversationNotificationManag import com.android.systemui.statusbar.notification.DynamicPrivacyController; import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator; import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinatorLogger; +import com.android.systemui.statusbar.notification.data.repository.NotificationsKeyguardViewStateRepository; import com.android.systemui.statusbar.notification.domain.interactor.ActiveNotificationsInteractor; +import com.android.systemui.statusbar.notification.domain.interactor.NotificationsKeyguardInteractor; import com.android.systemui.statusbar.notification.row.NotificationGutsManager; import com.android.systemui.statusbar.notification.stack.AmbientState; import com.android.systemui.statusbar.notification.stack.NotificationListContainer; @@ -586,6 +588,10 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { when(mPrimaryBouncerToGoneTransitionViewModel.getLockscreenAlpha()) .thenReturn(emptyFlow()); + NotificationsKeyguardViewStateRepository notifsKeyguardViewStateRepository = + new NotificationsKeyguardViewStateRepository(); + NotificationsKeyguardInteractor notifsKeyguardInteractor = + new NotificationsKeyguardInteractor(notifsKeyguardViewStateRepository); NotificationWakeUpCoordinator coordinator = new NotificationWakeUpCoordinator( mDumpManager, @@ -596,7 +602,8 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { mKeyguardBypassController, mDozeParameters, mScreenOffAnimationController, - new NotificationWakeUpCoordinatorLogger(logcatLogBuffer())); + new NotificationWakeUpCoordinatorLogger(logcatLogBuffer()), + notifsKeyguardInteractor); mConfigurationController = new ConfigurationControllerImpl(mContext); PulseExpansionHandler expansionHandler = new PulseExpansionHandler( mContext, diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationWakeUpCoordinatorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationWakeUpCoordinatorTest.kt index 438b33d9afbc..039fef9c1df5 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationWakeUpCoordinatorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationWakeUpCoordinatorTest.kt @@ -22,12 +22,14 @@ import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.animation.AnimatorTestRule import com.android.systemui.dump.DumpManager +import com.android.systemui.kosmos.Kosmos import com.android.systemui.log.logcatLogBuffer import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.shade.ShadeViewController.Companion.WAKEUP_ANIMATION_DELAY_MS import com.android.systemui.statusbar.StatusBarState import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController import com.android.systemui.statusbar.notification.stack.StackStateAnimator.ANIMATION_DURATION_WAKEUP +import com.android.systemui.statusbar.notification.stack.domain.interactor.notificationsKeyguardInteractor import com.android.systemui.statusbar.phone.DozeParameters import com.android.systemui.statusbar.phone.KeyguardBypassController import com.android.systemui.statusbar.phone.ScreenOffAnimationController @@ -54,6 +56,8 @@ class NotificationWakeUpCoordinatorTest : SysuiTestCase() { @get:Rule val animatorTestRule = AnimatorTestRule() + private val kosmos = Kosmos() + private val dumpManager: DumpManager = mock() private val headsUpManager: HeadsUpManager = mock() private val statusBarStateController: StatusBarStateController = mock() @@ -100,6 +104,7 @@ class NotificationWakeUpCoordinatorTest : SysuiTestCase() { dozeParameters, screenOffAnimationController, logger, + kosmos.notificationsKeyguardInteractor, ) statusBarStateCallback = withArgCaptor { verify(statusBarStateController).addCallback(capture()) diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/data/repository/NotificationsKeyguardViewStateRepositoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/data/repository/NotificationsKeyguardViewStateRepositoryTest.kt deleted file mode 100644 index 170f651aed91..000000000000 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/data/repository/NotificationsKeyguardViewStateRepositoryTest.kt +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2023 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.statusbar.notification.data.repository - -import androidx.test.filters.SmallTest -import com.android.systemui.SysUITestComponent -import com.android.systemui.SysUITestModule -import com.android.systemui.SysuiTestCase -import com.android.systemui.collectLastValue -import com.android.systemui.dagger.SysUISingleton -import com.android.systemui.runCurrent -import com.android.systemui.runTest -import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator -import com.android.systemui.util.mockito.whenever -import com.android.systemui.util.mockito.withArgCaptor -import com.google.common.truth.Truth.assertThat -import dagger.BindsInstance -import dagger.Component -import org.junit.Test -import org.mockito.Mockito.verify - -@SmallTest -class NotificationsKeyguardViewStateRepositoryTest : SysuiTestCase() { - - @SysUISingleton - @Component(modules = [SysUITestModule::class]) - interface TestComponent : SysUITestComponent<NotificationsKeyguardViewStateRepositoryImpl> { - - val mockWakeUpCoordinator: NotificationWakeUpCoordinator - - @Component.Factory - interface Factory { - fun create( - @BindsInstance test: SysuiTestCase, - ): TestComponent - } - } - - private val testComponent: TestComponent = - DaggerNotificationsKeyguardViewStateRepositoryTest_TestComponent.factory() - .create(test = this) - - @Test - fun areNotifsFullyHidden_reflectsWakeUpCoordinator() = - testComponent.runTest { - whenever(mockWakeUpCoordinator.notificationsFullyHidden).thenReturn(false) - val notifsFullyHidden by collectLastValue(underTest.areNotificationsFullyHidden) - runCurrent() - - assertThat(notifsFullyHidden).isFalse() - - withArgCaptor { verify(mockWakeUpCoordinator).addListener(capture()) } - .onFullyHiddenChanged(true) - runCurrent() - - assertThat(notifsFullyHidden).isTrue() - } - - @Test - fun isPulseExpanding_reflectsWakeUpCoordinator() = - testComponent.runTest { - whenever(mockWakeUpCoordinator.isPulseExpanding()).thenReturn(false) - val isPulseExpanding by collectLastValue(underTest.isPulseExpanding) - runCurrent() - - assertThat(isPulseExpanding).isFalse() - - withArgCaptor { verify(mockWakeUpCoordinator).addListener(capture()) } - .onPulseExpandingChanged(true) - runCurrent() - - assertThat(isPulseExpanding).isTrue() - } -} diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/domain/interactor/NotificationsKeyguardInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/domain/interactor/NotificationsKeyguardInteractorTest.kt index bb3113a72e92..3593f5b4963e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/domain/interactor/NotificationsKeyguardInteractorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/domain/interactor/NotificationsKeyguardInteractorTest.kt @@ -21,7 +21,6 @@ import com.android.systemui.collectLastValue import com.android.systemui.dagger.SysUISingleton import com.android.systemui.runCurrent import com.android.systemui.runTest -import com.android.systemui.statusbar.notification.data.repository.FakeNotificationsKeyguardViewStateRepository import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component @@ -33,9 +32,6 @@ class NotificationsKeyguardInteractorTest : SysuiTestCase() { @SysUISingleton @Component(modules = [SysUITestModule::class]) interface TestComponent : SysUITestComponent<NotificationsKeyguardInteractor> { - - val repository: FakeNotificationsKeyguardViewStateRepository - @Component.Factory interface Factory { fun create(@BindsInstance test: SysuiTestCase): TestComponent @@ -48,13 +44,13 @@ class NotificationsKeyguardInteractorTest : SysuiTestCase() { @Test fun areNotifsFullyHidden_reflectsRepository() = testComponent.runTest { - repository.setNotificationsFullyHidden(false) + underTest.setNotificationsFullyHidden(false) val notifsFullyHidden by collectLastValue(underTest.areNotificationsFullyHidden) runCurrent() assertThat(notifsFullyHidden).isFalse() - repository.setNotificationsFullyHidden(true) + underTest.setNotificationsFullyHidden(true) runCurrent() assertThat(notifsFullyHidden).isTrue() @@ -63,13 +59,13 @@ class NotificationsKeyguardInteractorTest : SysuiTestCase() { @Test fun isPulseExpanding_reflectsRepository() = testComponent.runTest { - repository.setPulseExpanding(false) + underTest.setPulseExpanding(false) val isPulseExpanding by collectLastValue(underTest.isPulseExpanding) runCurrent() assertThat(isPulseExpanding).isFalse() - repository.setPulseExpanding(true) + underTest.setPulseExpanding(true) runCurrent() assertThat(isPulseExpanding).isTrue() diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/icon/domain/interactor/NotificationIconsInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/icon/domain/interactor/NotificationIconsInteractorTest.kt index 47feccf4bdcf..7faf5628b40a 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/icon/domain/interactor/NotificationIconsInteractorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/icon/domain/interactor/NotificationIconsInteractorTest.kt @@ -29,8 +29,8 @@ import com.android.systemui.statusbar.data.repository.NotificationListenerSettin import com.android.systemui.statusbar.notification.data.model.activeNotificationModel import com.android.systemui.statusbar.notification.data.repository.ActiveNotificationListRepository import com.android.systemui.statusbar.notification.data.repository.ActiveNotificationsStore -import com.android.systemui.statusbar.notification.data.repository.FakeNotificationsKeyguardViewStateRepository import com.android.systemui.statusbar.notification.domain.interactor.HeadsUpNotificationIconInteractor +import com.android.systemui.statusbar.notification.domain.interactor.NotificationsKeyguardInteractor import com.android.systemui.statusbar.notification.shared.byIsAmbient import com.android.systemui.statusbar.notification.shared.byIsLastMessageFromReply import com.android.systemui.statusbar.notification.shared.byIsPulsing @@ -61,7 +61,7 @@ class NotificationIconsInteractorTest : SysuiTestCase() { interface TestComponent : SysUITestComponent<NotificationIconsInteractor> { val activeNotificationListRepository: ActiveNotificationListRepository - val keyguardViewStateRepository: FakeNotificationsKeyguardViewStateRepository + val notificationsKeyguardInteractor: NotificationsKeyguardInteractor @Component.Factory interface Factory { @@ -136,7 +136,7 @@ class NotificationIconsInteractorTest : SysuiTestCase() { fun filteredEntrySet_noPulsing_notifsNotFullyHidden() = testComponent.runTest { val filteredSet by collectLastValue(underTest.filteredNotifSet(showPulsing = false)) - keyguardViewStateRepository.setNotificationsFullyHidden(false) + notificationsKeyguardInteractor.setNotificationsFullyHidden(false) assertThat(filteredSet).comparingElementsUsing(byIsPulsing).doesNotContain(true) } @@ -144,7 +144,7 @@ class NotificationIconsInteractorTest : SysuiTestCase() { fun filteredEntrySet_noPulsing_notifsFullyHidden() = testComponent.runTest { val filteredSet by collectLastValue(underTest.filteredNotifSet(showPulsing = false)) - keyguardViewStateRepository.setNotificationsFullyHidden(true) + notificationsKeyguardInteractor.setNotificationsFullyHidden(true) assertThat(filteredSet).comparingElementsUsing(byIsPulsing).contains(true) } } @@ -161,7 +161,7 @@ class AlwaysOnDisplayNotificationIconsInteractorTest : SysuiTestCase() { val activeNotificationListRepository: ActiveNotificationListRepository val deviceEntryRepository: FakeDeviceEntryRepository - val keyguardViewStateRepository: FakeNotificationsKeyguardViewStateRepository + val notificationsKeyguardInteractor: NotificationsKeyguardInteractor @Component.Factory interface Factory { @@ -222,7 +222,7 @@ class AlwaysOnDisplayNotificationIconsInteractorTest : SysuiTestCase() { testComponent.runTest { val filteredSet by collectLastValue(underTest.aodNotifs) deviceEntryRepository.setBypassEnabled(false) - keyguardViewStateRepository.setNotificationsFullyHidden(false) + notificationsKeyguardInteractor.setNotificationsFullyHidden(false) assertThat(filteredSet).comparingElementsUsing(byIsPulsing).contains(true) } @@ -231,7 +231,7 @@ class AlwaysOnDisplayNotificationIconsInteractorTest : SysuiTestCase() { testComponent.runTest { val filteredSet by collectLastValue(underTest.aodNotifs) deviceEntryRepository.setBypassEnabled(false) - keyguardViewStateRepository.setNotificationsFullyHidden(true) + notificationsKeyguardInteractor.setNotificationsFullyHidden(true) assertThat(filteredSet).comparingElementsUsing(byIsPulsing).contains(true) } @@ -240,7 +240,7 @@ class AlwaysOnDisplayNotificationIconsInteractorTest : SysuiTestCase() { testComponent.runTest { val filteredSet by collectLastValue(underTest.aodNotifs) deviceEntryRepository.setBypassEnabled(true) - keyguardViewStateRepository.setNotificationsFullyHidden(false) + notificationsKeyguardInteractor.setNotificationsFullyHidden(false) assertThat(filteredSet).comparingElementsUsing(byIsPulsing).doesNotContain(true) } @@ -249,7 +249,7 @@ class AlwaysOnDisplayNotificationIconsInteractorTest : SysuiTestCase() { testComponent.runTest { val filteredSet by collectLastValue(underTest.aodNotifs) deviceEntryRepository.setBypassEnabled(true) - keyguardViewStateRepository.setNotificationsFullyHidden(true) + notificationsKeyguardInteractor.setNotificationsFullyHidden(true) assertThat(filteredSet).comparingElementsUsing(byIsPulsing).contains(true) } } @@ -266,7 +266,7 @@ class StatusBarNotificationIconsInteractorTest : SysuiTestCase() { val activeNotificationListRepository: ActiveNotificationListRepository val headsUpIconsInteractor: HeadsUpNotificationIconInteractor - val keyguardViewStateRepository: FakeNotificationsKeyguardViewStateRepository + val notificationsKeyguardInteractor: NotificationsKeyguardInteractor val notificationListenerSettingsRepository: NotificationListenerSettingsRepository @Component.Factory diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/data/FakeStatusBarNotificationsDataLayerModule.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/data/FakeStatusBarNotificationsDataLayerModule.kt index 788e3aa9c41a..1ffc9f4e30b4 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/data/FakeStatusBarNotificationsDataLayerModule.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/data/FakeStatusBarNotificationsDataLayerModule.kt @@ -15,8 +15,6 @@ */ package com.android.systemui.statusbar.notification.data -import com.android.systemui.statusbar.notification.data.repository.FakeNotificationsKeyguardStateRepositoryModule import dagger.Module -@Module(includes = [FakeNotificationsKeyguardStateRepositoryModule::class]) -object FakeStatusBarNotificationsDataLayerModule +@Module(includes = []) object FakeStatusBarNotificationsDataLayerModule diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/data/repository/FakeNotificationsKeyguardViewStateRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/data/repository/FakeNotificationsKeyguardViewStateRepository.kt deleted file mode 100644 index 5d3cb4db9c7e..000000000000 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/data/repository/FakeNotificationsKeyguardViewStateRepository.kt +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2023 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.android.systemui.statusbar.notification.data.repository - -import com.android.systemui.dagger.SysUISingleton -import dagger.Binds -import dagger.Module -import javax.inject.Inject -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.MutableStateFlow - -@SysUISingleton -class FakeNotificationsKeyguardViewStateRepository @Inject constructor() : - NotificationsKeyguardViewStateRepository { - private val _notificationsFullyHidden = MutableStateFlow(false) - override val areNotificationsFullyHidden: Flow<Boolean> = _notificationsFullyHidden - - private val _isPulseExpanding = MutableStateFlow(false) - override val isPulseExpanding: Flow<Boolean> = _isPulseExpanding - - fun setNotificationsFullyHidden(fullyHidden: Boolean) { - _notificationsFullyHidden.value = fullyHidden - } - - fun setPulseExpanding(expanding: Boolean) { - _isPulseExpanding.value = expanding - } -} - -@Module -interface FakeNotificationsKeyguardStateRepositoryModule { - @Binds - fun bindFake( - fake: FakeNotificationsKeyguardViewStateRepository - ): NotificationsKeyguardViewStateRepository -} diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/data/repository/NotificationsKeyguardViewStateRepositoryKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/data/repository/NotificationsKeyguardViewStateRepositoryKosmos.kt index f2b9da413c22..df7fd94d19b9 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/data/repository/NotificationsKeyguardViewStateRepositoryKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/data/repository/NotificationsKeyguardViewStateRepositoryKosmos.kt @@ -18,7 +18,5 @@ package com.android.systemui.statusbar.notification.data.repository import com.android.systemui.kosmos.Kosmos -var Kosmos.notificationsKeyguardViewStateRepository: NotificationsKeyguardViewStateRepository by - Kosmos.Fixture { fakeNotificationsKeyguardViewStateRepository } -val Kosmos.fakeNotificationsKeyguardViewStateRepository by - Kosmos.Fixture { FakeNotificationsKeyguardViewStateRepository() } +val Kosmos.notificationsKeyguardViewStateRepository: NotificationsKeyguardViewStateRepository by + Kosmos.Fixture { NotificationsKeyguardViewStateRepository() } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/domain/interactor/NotificationsKeyguardInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/domain/interactor/NotificationsKeyguardInteractorKosmos.kt index 432464e86c3f..61a38b864c40 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/domain/interactor/NotificationsKeyguardInteractorKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/domain/interactor/NotificationsKeyguardInteractorKosmos.kt @@ -18,13 +18,11 @@ package com.android.systemui.statusbar.notification.stack.domain.interactor import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.Kosmos.Fixture -import com.android.systemui.kosmos.testDispatcher import com.android.systemui.statusbar.notification.data.repository.notificationsKeyguardViewStateRepository import com.android.systemui.statusbar.notification.domain.interactor.NotificationsKeyguardInteractor val Kosmos.notificationsKeyguardInteractor by Fixture { NotificationsKeyguardInteractor( repository = notificationsKeyguardViewStateRepository, - backgroundDispatcher = testDispatcher, ) } |