Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/CollapsedStatusBarViewModelImplTest.kt +57 −87 Original line number Diff line number Diff line Loading @@ -19,77 +19,59 @@ package com.android.systemui.statusbar.pipeline.shared.ui.viewmodel import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import androidx.test.filters.SmallTest import com.android.systemui.CoroutineTestScopeModule import com.android.systemui.SysUITestComponent import com.android.systemui.SysUITestModule import com.android.systemui.SysuiTestCase import com.android.systemui.biometrics.domain.BiometricsDomainLayerModule import com.android.systemui.collectLastValue import com.android.systemui.collectValues import com.android.systemui.communal.dagger.CommunalModule import com.android.systemui.dagger.SysUISingleton import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectValues import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.domain.interactor.keyguardTransitionInteractor 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.Kosmos import com.android.systemui.kosmos.applicationCoroutineScope import com.android.systemui.kosmos.testDispatcher import com.android.systemui.kosmos.testScope import com.android.systemui.log.assertLogsWtf import com.android.systemui.runTest import com.android.systemui.statusbar.data.model.StatusBarMode import com.android.systemui.statusbar.data.repository.FakeStatusBarModeRepository import com.android.systemui.statusbar.data.repository.FakeStatusBarModeRepository.Companion.DISPLAY_ID import com.android.systemui.statusbar.data.repository.fakeStatusBarModeRepository 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.activeNotificationListRepository import com.android.systemui.statusbar.notification.domain.interactor.activeNotificationsInteractor import com.android.systemui.statusbar.notification.shared.ActiveNotificationModel import com.android.systemui.statusbar.notification.shared.NotificationsLiveDataStoreRefactor import com.android.systemui.statusbar.phone.domain.interactor.lightsOutInteractor import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.emptyFlow import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.UnconfinedTestDispatcher import kotlinx.coroutines.test.runTest import org.junit.Test @SmallTest @OptIn(ExperimentalCoroutinesApi::class) class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { private val kosmos = Kosmos().apply { testDispatcher = UnconfinedTestDispatcher() } @SysUISingleton @Component( modules = [ SysUITestModule::class, CommunalModule::class, BiometricsDomainLayerModule::class, ] ) interface TestComponent : SysUITestComponent<CollapsedStatusBarViewModelImpl> { val statusBarModeRepository: FakeStatusBarModeRepository val activeNotificationListRepository: ActiveNotificationListRepository val keyguardTransitionRepository: FakeKeyguardTransitionRepository @Component.Factory interface Factory { fun create( @BindsInstance test: SysuiTestCase, testScope: CoroutineTestScopeModule, ): TestComponent } } private val testScope = kosmos.testScope @OptIn(ExperimentalCoroutinesApi::class) private val testComponent: TestComponent = DaggerCollapsedStatusBarViewModelImplTest_TestComponent.factory() .create( test = this, testScope = CoroutineTestScopeModule(TestScope(UnconfinedTestDispatcher())), private val statusBarModeRepository = kosmos.fakeStatusBarModeRepository private val activeNotificationListRepository = kosmos.activeNotificationListRepository private val keyguardTransitionRepository = kosmos.fakeKeyguardTransitionRepository private val underTest = CollapsedStatusBarViewModelImpl( kosmos.lightsOutInteractor, kosmos.activeNotificationsInteractor, kosmos.keyguardTransitionInteractor, kosmos.applicationCoroutineScope, ) @Test fun isTransitioningFromLockscreenToOccluded_started_isTrue() = testComponent.runTest { val job = underTest.isTransitioningFromLockscreenToOccluded.launchIn(testScope) testScope.runTest { val latest by collectLastValue(underTest.isTransitioningFromLockscreenToOccluded) keyguardTransitionRepository.sendTransitionStep( TransitionStep( Loading @@ -100,15 +82,13 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { ) ) assertThat(underTest.isTransitioningFromLockscreenToOccluded.value).isTrue() job.cancel() assertThat(latest).isTrue() } @Test fun isTransitioningFromLockscreenToOccluded_running_isTrue() = testComponent.runTest { val job = underTest.isTransitioningFromLockscreenToOccluded.launchIn(testScope) testScope.runTest { val latest by collectLastValue(underTest.isTransitioningFromLockscreenToOccluded) keyguardTransitionRepository.sendTransitionStep( TransitionStep( Loading @@ -119,15 +99,13 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { ) ) assertThat(underTest.isTransitioningFromLockscreenToOccluded.value).isTrue() job.cancel() assertThat(latest).isTrue() } @Test fun isTransitioningFromLockscreenToOccluded_finished_isFalse() = testComponent.runTest { val job = underTest.isTransitioningFromLockscreenToOccluded.launchIn(testScope) testScope.runTest { val latest by collectLastValue(underTest.isTransitioningFromLockscreenToOccluded) keyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.LOCKSCREEN, Loading @@ -135,15 +113,13 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { testScope.testScheduler, ) assertThat(underTest.isTransitioningFromLockscreenToOccluded.value).isFalse() job.cancel() assertThat(latest).isFalse() } @Test fun isTransitioningFromLockscreenToOccluded_canceled_isFalse() = testComponent.runTest { val job = underTest.isTransitioningFromLockscreenToOccluded.launchIn(testScope) testScope.runTest { val latest by collectLastValue(underTest.isTransitioningFromLockscreenToOccluded) keyguardTransitionRepository.sendTransitionStep( TransitionStep( Loading @@ -154,15 +130,13 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { ) ) assertThat(underTest.isTransitioningFromLockscreenToOccluded.value).isFalse() job.cancel() assertThat(latest).isFalse() } @Test fun isTransitioningFromLockscreenToOccluded_irrelevantTransition_isFalse() = testComponent.runTest { val job = underTest.isTransitioningFromLockscreenToOccluded.launchIn(testScope) testScope.runTest { val latest by collectLastValue(underTest.isTransitioningFromLockscreenToOccluded) keyguardTransitionRepository.sendTransitionStep( TransitionStep( Loading @@ -173,15 +147,13 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { ) ) assertThat(underTest.isTransitioningFromLockscreenToOccluded.value).isFalse() job.cancel() assertThat(latest).isFalse() } @Test fun isTransitioningFromLockscreenToOccluded_followsRepoUpdates() = testComponent.runTest { val job = underTest.isTransitioningFromLockscreenToOccluded.launchIn(testScope) testScope.runTest { val latest by collectLastValue(underTest.isTransitioningFromLockscreenToOccluded) keyguardTransitionRepository.sendTransitionStep( TransitionStep( Loading @@ -192,7 +164,7 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { ) ) assertThat(underTest.isTransitioningFromLockscreenToOccluded.value).isTrue() assertThat(latest).isTrue() // WHEN the repo updates the transition to finished keyguardTransitionRepository.sendTransitionStep( Loading @@ -205,14 +177,12 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { ) // THEN our manager also updates assertThat(underTest.isTransitioningFromLockscreenToOccluded.value).isFalse() job.cancel() assertThat(latest).isFalse() } @Test fun transitionFromLockscreenToDreamStartedEvent_started_emitted() = testComponent.runTest { testScope.runTest { val emissions by collectValues(underTest.transitionFromLockscreenToDreamStartedEvent) keyguardTransitionRepository.sendTransitionStep( Loading @@ -229,7 +199,7 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { @Test fun transitionFromLockscreenToDreamStartedEvent_startedMultiple_emittedMultiple() = testComponent.runTest { testScope.runTest { val emissions by collectValues(underTest.transitionFromLockscreenToDreamStartedEvent) keyguardTransitionRepository.sendTransitionStep( Loading Loading @@ -264,7 +234,7 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { @Test fun transitionFromLockscreenToDreamStartedEvent_startedThenRunning_emittedOnlyOne() = testComponent.runTest { testScope.runTest { val emissions by collectValues(underTest.transitionFromLockscreenToDreamStartedEvent) keyguardTransitionRepository.sendTransitionStep( Loading Loading @@ -313,7 +283,7 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { @Test fun transitionFromLockscreenToDreamStartedEvent_irrelevantTransition_notEmitted() = testComponent.runTest { testScope.runTest { val emissions by collectValues(underTest.transitionFromLockscreenToDreamStartedEvent) keyguardTransitionRepository.sendTransitionStep( Loading @@ -330,7 +300,7 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { @Test fun transitionFromLockscreenToDreamStartedEvent_irrelevantTransitionState_notEmitted() = testComponent.runTest { testScope.runTest { val emissions by collectValues(underTest.transitionFromLockscreenToDreamStartedEvent) keyguardTransitionRepository.sendTransitionStep( Loading @@ -351,7 +321,7 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { @Test @EnableFlags(NotificationsLiveDataStoreRefactor.FLAG_NAME) fun areNotificationsLightsOut_lowProfileWithNotifications_true() = testComponent.runTest { testScope.runTest { statusBarModeRepository.defaultDisplay.statusBarMode.value = StatusBarMode.LIGHTS_OUT_TRANSPARENT activeNotificationListRepository.activeNotifications.value = Loading @@ -365,7 +335,7 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { @Test @EnableFlags(NotificationsLiveDataStoreRefactor.FLAG_NAME) fun areNotificationsLightsOut_lowProfileWithoutNotifications_false() = testComponent.runTest { testScope.runTest { statusBarModeRepository.defaultDisplay.statusBarMode.value = StatusBarMode.LIGHTS_OUT_TRANSPARENT activeNotificationListRepository.activeNotifications.value = Loading @@ -379,7 +349,7 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { @Test @EnableFlags(NotificationsLiveDataStoreRefactor.FLAG_NAME) fun areNotificationsLightsOut_defaultStatusBarModeWithoutNotifications_false() = testComponent.runTest { testScope.runTest { statusBarModeRepository.defaultDisplay.statusBarMode.value = StatusBarMode.TRANSPARENT activeNotificationListRepository.activeNotifications.value = activeNotificationsStore(emptyList()) Loading @@ -392,7 +362,7 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { @Test @EnableFlags(NotificationsLiveDataStoreRefactor.FLAG_NAME) fun areNotificationsLightsOut_defaultStatusBarModeWithNotifications_false() = testComponent.runTest { testScope.runTest { statusBarModeRepository.defaultDisplay.statusBarMode.value = StatusBarMode.TRANSPARENT activeNotificationListRepository.activeNotifications.value = activeNotificationsStore(testNotifications) Loading @@ -405,7 +375,7 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { @Test @DisableFlags(NotificationsLiveDataStoreRefactor.FLAG_NAME) fun areNotificationsLightsOut_requiresFlagEnabled() = testComponent.runTest { testScope.runTest { assertLogsWtf { val flow = underTest.areNotificationsLightsOut(DISPLAY_ID) assertThat(flow).isEqualTo(emptyFlow<Boolean>()) Loading packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/data/repository/StatusBarModeRepositoryKosmos.kt 0 → 100644 +23 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 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.data.repository import com.android.systemui.kosmos.Kosmos val Kosmos.statusBarModeRepository: StatusBarModeRepositoryStore by Kosmos.Fixture { fakeStatusBarModeRepository } val Kosmos.fakeStatusBarModeRepository by Kosmos.Fixture { FakeStatusBarModeRepository() } packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/phone/domain/interactor/LightsOutInteractorKosmos.kt 0 → 100644 +22 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 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.phone.domain.interactor import com.android.systemui.kosmos.Kosmos import com.android.systemui.statusbar.data.repository.statusBarModeRepository val Kosmos.lightsOutInteractor by Kosmos.Fixture { LightsOutInteractor(statusBarModeRepository) } Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/CollapsedStatusBarViewModelImplTest.kt +57 −87 Original line number Diff line number Diff line Loading @@ -19,77 +19,59 @@ package com.android.systemui.statusbar.pipeline.shared.ui.viewmodel import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import androidx.test.filters.SmallTest import com.android.systemui.CoroutineTestScopeModule import com.android.systemui.SysUITestComponent import com.android.systemui.SysUITestModule import com.android.systemui.SysuiTestCase import com.android.systemui.biometrics.domain.BiometricsDomainLayerModule import com.android.systemui.collectLastValue import com.android.systemui.collectValues import com.android.systemui.communal.dagger.CommunalModule import com.android.systemui.dagger.SysUISingleton import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectValues import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.domain.interactor.keyguardTransitionInteractor 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.Kosmos import com.android.systemui.kosmos.applicationCoroutineScope import com.android.systemui.kosmos.testDispatcher import com.android.systemui.kosmos.testScope import com.android.systemui.log.assertLogsWtf import com.android.systemui.runTest import com.android.systemui.statusbar.data.model.StatusBarMode import com.android.systemui.statusbar.data.repository.FakeStatusBarModeRepository import com.android.systemui.statusbar.data.repository.FakeStatusBarModeRepository.Companion.DISPLAY_ID import com.android.systemui.statusbar.data.repository.fakeStatusBarModeRepository 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.activeNotificationListRepository import com.android.systemui.statusbar.notification.domain.interactor.activeNotificationsInteractor import com.android.systemui.statusbar.notification.shared.ActiveNotificationModel import com.android.systemui.statusbar.notification.shared.NotificationsLiveDataStoreRefactor import com.android.systemui.statusbar.phone.domain.interactor.lightsOutInteractor import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.emptyFlow import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.UnconfinedTestDispatcher import kotlinx.coroutines.test.runTest import org.junit.Test @SmallTest @OptIn(ExperimentalCoroutinesApi::class) class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { private val kosmos = Kosmos().apply { testDispatcher = UnconfinedTestDispatcher() } @SysUISingleton @Component( modules = [ SysUITestModule::class, CommunalModule::class, BiometricsDomainLayerModule::class, ] ) interface TestComponent : SysUITestComponent<CollapsedStatusBarViewModelImpl> { val statusBarModeRepository: FakeStatusBarModeRepository val activeNotificationListRepository: ActiveNotificationListRepository val keyguardTransitionRepository: FakeKeyguardTransitionRepository @Component.Factory interface Factory { fun create( @BindsInstance test: SysuiTestCase, testScope: CoroutineTestScopeModule, ): TestComponent } } private val testScope = kosmos.testScope @OptIn(ExperimentalCoroutinesApi::class) private val testComponent: TestComponent = DaggerCollapsedStatusBarViewModelImplTest_TestComponent.factory() .create( test = this, testScope = CoroutineTestScopeModule(TestScope(UnconfinedTestDispatcher())), private val statusBarModeRepository = kosmos.fakeStatusBarModeRepository private val activeNotificationListRepository = kosmos.activeNotificationListRepository private val keyguardTransitionRepository = kosmos.fakeKeyguardTransitionRepository private val underTest = CollapsedStatusBarViewModelImpl( kosmos.lightsOutInteractor, kosmos.activeNotificationsInteractor, kosmos.keyguardTransitionInteractor, kosmos.applicationCoroutineScope, ) @Test fun isTransitioningFromLockscreenToOccluded_started_isTrue() = testComponent.runTest { val job = underTest.isTransitioningFromLockscreenToOccluded.launchIn(testScope) testScope.runTest { val latest by collectLastValue(underTest.isTransitioningFromLockscreenToOccluded) keyguardTransitionRepository.sendTransitionStep( TransitionStep( Loading @@ -100,15 +82,13 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { ) ) assertThat(underTest.isTransitioningFromLockscreenToOccluded.value).isTrue() job.cancel() assertThat(latest).isTrue() } @Test fun isTransitioningFromLockscreenToOccluded_running_isTrue() = testComponent.runTest { val job = underTest.isTransitioningFromLockscreenToOccluded.launchIn(testScope) testScope.runTest { val latest by collectLastValue(underTest.isTransitioningFromLockscreenToOccluded) keyguardTransitionRepository.sendTransitionStep( TransitionStep( Loading @@ -119,15 +99,13 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { ) ) assertThat(underTest.isTransitioningFromLockscreenToOccluded.value).isTrue() job.cancel() assertThat(latest).isTrue() } @Test fun isTransitioningFromLockscreenToOccluded_finished_isFalse() = testComponent.runTest { val job = underTest.isTransitioningFromLockscreenToOccluded.launchIn(testScope) testScope.runTest { val latest by collectLastValue(underTest.isTransitioningFromLockscreenToOccluded) keyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.LOCKSCREEN, Loading @@ -135,15 +113,13 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { testScope.testScheduler, ) assertThat(underTest.isTransitioningFromLockscreenToOccluded.value).isFalse() job.cancel() assertThat(latest).isFalse() } @Test fun isTransitioningFromLockscreenToOccluded_canceled_isFalse() = testComponent.runTest { val job = underTest.isTransitioningFromLockscreenToOccluded.launchIn(testScope) testScope.runTest { val latest by collectLastValue(underTest.isTransitioningFromLockscreenToOccluded) keyguardTransitionRepository.sendTransitionStep( TransitionStep( Loading @@ -154,15 +130,13 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { ) ) assertThat(underTest.isTransitioningFromLockscreenToOccluded.value).isFalse() job.cancel() assertThat(latest).isFalse() } @Test fun isTransitioningFromLockscreenToOccluded_irrelevantTransition_isFalse() = testComponent.runTest { val job = underTest.isTransitioningFromLockscreenToOccluded.launchIn(testScope) testScope.runTest { val latest by collectLastValue(underTest.isTransitioningFromLockscreenToOccluded) keyguardTransitionRepository.sendTransitionStep( TransitionStep( Loading @@ -173,15 +147,13 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { ) ) assertThat(underTest.isTransitioningFromLockscreenToOccluded.value).isFalse() job.cancel() assertThat(latest).isFalse() } @Test fun isTransitioningFromLockscreenToOccluded_followsRepoUpdates() = testComponent.runTest { val job = underTest.isTransitioningFromLockscreenToOccluded.launchIn(testScope) testScope.runTest { val latest by collectLastValue(underTest.isTransitioningFromLockscreenToOccluded) keyguardTransitionRepository.sendTransitionStep( TransitionStep( Loading @@ -192,7 +164,7 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { ) ) assertThat(underTest.isTransitioningFromLockscreenToOccluded.value).isTrue() assertThat(latest).isTrue() // WHEN the repo updates the transition to finished keyguardTransitionRepository.sendTransitionStep( Loading @@ -205,14 +177,12 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { ) // THEN our manager also updates assertThat(underTest.isTransitioningFromLockscreenToOccluded.value).isFalse() job.cancel() assertThat(latest).isFalse() } @Test fun transitionFromLockscreenToDreamStartedEvent_started_emitted() = testComponent.runTest { testScope.runTest { val emissions by collectValues(underTest.transitionFromLockscreenToDreamStartedEvent) keyguardTransitionRepository.sendTransitionStep( Loading @@ -229,7 +199,7 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { @Test fun transitionFromLockscreenToDreamStartedEvent_startedMultiple_emittedMultiple() = testComponent.runTest { testScope.runTest { val emissions by collectValues(underTest.transitionFromLockscreenToDreamStartedEvent) keyguardTransitionRepository.sendTransitionStep( Loading Loading @@ -264,7 +234,7 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { @Test fun transitionFromLockscreenToDreamStartedEvent_startedThenRunning_emittedOnlyOne() = testComponent.runTest { testScope.runTest { val emissions by collectValues(underTest.transitionFromLockscreenToDreamStartedEvent) keyguardTransitionRepository.sendTransitionStep( Loading Loading @@ -313,7 +283,7 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { @Test fun transitionFromLockscreenToDreamStartedEvent_irrelevantTransition_notEmitted() = testComponent.runTest { testScope.runTest { val emissions by collectValues(underTest.transitionFromLockscreenToDreamStartedEvent) keyguardTransitionRepository.sendTransitionStep( Loading @@ -330,7 +300,7 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { @Test fun transitionFromLockscreenToDreamStartedEvent_irrelevantTransitionState_notEmitted() = testComponent.runTest { testScope.runTest { val emissions by collectValues(underTest.transitionFromLockscreenToDreamStartedEvent) keyguardTransitionRepository.sendTransitionStep( Loading @@ -351,7 +321,7 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { @Test @EnableFlags(NotificationsLiveDataStoreRefactor.FLAG_NAME) fun areNotificationsLightsOut_lowProfileWithNotifications_true() = testComponent.runTest { testScope.runTest { statusBarModeRepository.defaultDisplay.statusBarMode.value = StatusBarMode.LIGHTS_OUT_TRANSPARENT activeNotificationListRepository.activeNotifications.value = Loading @@ -365,7 +335,7 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { @Test @EnableFlags(NotificationsLiveDataStoreRefactor.FLAG_NAME) fun areNotificationsLightsOut_lowProfileWithoutNotifications_false() = testComponent.runTest { testScope.runTest { statusBarModeRepository.defaultDisplay.statusBarMode.value = StatusBarMode.LIGHTS_OUT_TRANSPARENT activeNotificationListRepository.activeNotifications.value = Loading @@ -379,7 +349,7 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { @Test @EnableFlags(NotificationsLiveDataStoreRefactor.FLAG_NAME) fun areNotificationsLightsOut_defaultStatusBarModeWithoutNotifications_false() = testComponent.runTest { testScope.runTest { statusBarModeRepository.defaultDisplay.statusBarMode.value = StatusBarMode.TRANSPARENT activeNotificationListRepository.activeNotifications.value = activeNotificationsStore(emptyList()) Loading @@ -392,7 +362,7 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { @Test @EnableFlags(NotificationsLiveDataStoreRefactor.FLAG_NAME) fun areNotificationsLightsOut_defaultStatusBarModeWithNotifications_false() = testComponent.runTest { testScope.runTest { statusBarModeRepository.defaultDisplay.statusBarMode.value = StatusBarMode.TRANSPARENT activeNotificationListRepository.activeNotifications.value = activeNotificationsStore(testNotifications) Loading @@ -405,7 +375,7 @@ class CollapsedStatusBarViewModelImplTest : SysuiTestCase() { @Test @DisableFlags(NotificationsLiveDataStoreRefactor.FLAG_NAME) fun areNotificationsLightsOut_requiresFlagEnabled() = testComponent.runTest { testScope.runTest { assertLogsWtf { val flow = underTest.areNotificationsLightsOut(DISPLAY_ID) assertThat(flow).isEqualTo(emptyFlow<Boolean>()) Loading
packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/data/repository/StatusBarModeRepositoryKosmos.kt 0 → 100644 +23 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 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.data.repository import com.android.systemui.kosmos.Kosmos val Kosmos.statusBarModeRepository: StatusBarModeRepositoryStore by Kosmos.Fixture { fakeStatusBarModeRepository } val Kosmos.fakeStatusBarModeRepository by Kosmos.Fixture { FakeStatusBarModeRepository() }
packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/phone/domain/interactor/LightsOutInteractorKosmos.kt 0 → 100644 +22 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 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.phone.domain.interactor import com.android.systemui.kosmos.Kosmos import com.android.systemui.statusbar.data.repository.statusBarModeRepository val Kosmos.lightsOutInteractor by Kosmos.Fixture { LightsOutInteractor(statusBarModeRepository) }