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

Commit 9480c4e7 authored by Matt Pietal's avatar Matt Pietal
Browse files

Update tests for currentTransitionInfo

The current transtition info state is modified
under a flag. Update scene tests for it.

Test: atest SceneContainerStartableTest
Bug: 375630293
Flag: com.android.systemui.transition_race_condition
Change-Id: I01cfef9e1e1f295cdebd07ee150282a033675e15
parent f93e6ba1
Loading
Loading
Loading
Loading
+52 −0
Original line number Diff line number Diff line
@@ -651,6 +651,7 @@ class SceneContainerStartableTest : SysuiTestCase() {
        }

    @Test
    @DisableFlags(Flags.FLAG_TRANSITION_RACE_CONDITION)
    fun switchToAOD_whenAvailable_whenDeviceSleepsLocked() =
        testScope.runTest {
            kosmos.lockscreenSceneTransitionInteractor.start()
@@ -680,6 +681,7 @@ class SceneContainerStartableTest : SysuiTestCase() {
        }

    @Test
    @DisableFlags(Flags.FLAG_TRANSITION_RACE_CONDITION)
    fun switchToDozing_whenAodUnavailable_whenDeviceSleepsLocked() =
        testScope.runTest {
            kosmos.lockscreenSceneTransitionInteractor.start()
@@ -700,6 +702,56 @@ class SceneContainerStartableTest : SysuiTestCase() {
            assertThat(currentTransitionInfo?.to).isEqualTo(KeyguardState.DOZING)
        }

    @Test
    @EnableFlags(Flags.FLAG_TRANSITION_RACE_CONDITION)
    fun switchToAOD_whenAvailable_whenDeviceSleepsLocked_transitionFlagEnabled() =
        testScope.runTest {
            kosmos.lockscreenSceneTransitionInteractor.start()
            val asleepState by collectLastValue(kosmos.keyguardInteractor.asleepKeyguardState)
            val transitionState =
                prepareState(isDeviceUnlocked = false, initialSceneKey = Scenes.Shade)
            kosmos.keyguardRepository.setAodAvailable(true)
            runCurrent()
            assertThat(asleepState).isEqualTo(KeyguardState.AOD)
            underTest.start()
            powerInteractor.setAsleepForTest()
            runCurrent()
            transitionState.value =
                ObservableTransitionState.Transition(
                    fromScene = Scenes.Shade,
                    toScene = Scenes.Lockscreen,
                    currentScene = flowOf(Scenes.Lockscreen),
                    progress = flowOf(0.5f),
                    isInitiatedByUserInput = true,
                    isUserInputOngoing = flowOf(false),
                )
            runCurrent()

            assertThat(kosmos.keyguardTransitionRepository.currentTransitionInfo.to)
                .isEqualTo(KeyguardState.AOD)
        }

    @Test
    @EnableFlags(Flags.FLAG_TRANSITION_RACE_CONDITION)
    fun switchToDozing_whenAodUnavailable_whenDeviceSleepsLocked_transitionFlagEnabled() =
        testScope.runTest {
            kosmos.lockscreenSceneTransitionInteractor.start()
            val asleepState by collectLastValue(kosmos.keyguardInteractor.asleepKeyguardState)
            val transitionState =
                prepareState(isDeviceUnlocked = false, initialSceneKey = Scenes.Shade)
            kosmos.keyguardRepository.setAodAvailable(false)
            runCurrent()
            assertThat(asleepState).isEqualTo(KeyguardState.DOZING)
            underTest.start()
            powerInteractor.setAsleepForTest()
            runCurrent()
            transitionState.value = Transition(from = Scenes.Shade, to = Scenes.Lockscreen)
            runCurrent()

            assertThat(kosmos.keyguardTransitionRepository.currentTransitionInfo.to)
                .isEqualTo(KeyguardState.DOZING)
        }

    @Test
    fun switchToGoneWhenDoubleTapPowerGestureIsTriggeredFromGone() =
        testScope.runTest {