Loading packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalSceneTransitionInteractorTest.kt +83 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import com.android.systemui.keyguard.data.repository.keyguardTransitionRepositor import com.android.systemui.keyguard.data.repository.realKeyguardTransitionRepository import com.android.systemui.keyguard.shared.model.DozeStateModel import com.android.systemui.keyguard.shared.model.DozeTransitionModel import com.android.systemui.keyguard.shared.model.KeyguardState.ALTERNATE_BOUNCER import com.android.systemui.keyguard.shared.model.KeyguardState.DREAMING import com.android.systemui.keyguard.shared.model.KeyguardState.GLANCEABLE_HUB import com.android.systemui.keyguard.shared.model.KeyguardState.GONE Loading Loading @@ -834,4 +835,86 @@ class CommunalSceneTransitionInteractorTest : SysuiTestCase() { ) ) } /** * KTF: LOCKSCREEN -> ALTERNATE_BOUNCER starts but then STL: GLANCEABLE_HUB -> BLANK interrupts. * * Verifies that we correctly cancel the previous KTF state before starting the glanceable hub * transition. */ @Test fun transition_to_blank_after_ktf_started_another_transition() = testScope.runTest { // Another transition has already started to the alternate bouncer. keyguardTransitionRepository.startTransition( TransitionInfo( from = LOCKSCREEN, to = ALTERNATE_BOUNCER, animator = null, ownerName = "external", modeOnCanceled = TransitionModeOnCanceled.RESET ), ) val allSteps by collectValues(keyguardTransitionRepository.transitions) // Keep track of existing size to drop any pre-existing steps that we don't // care about. val numToDrop = allSteps.size sceneTransitions.value = hubToBlank runCurrent() progress.emit(0.4f) runCurrent() // We land on blank. sceneTransitions.value = Idle(CommunalScenes.Blank) // We should cancel the previous ALTERNATE_BOUNCER transition and transition back // to the GLANCEABLE_HUB before we can transition away from it. assertThat(allSteps.drop(numToDrop)) .containsExactly( TransitionStep( from = LOCKSCREEN, to = ALTERNATE_BOUNCER, transitionState = CANCELED, value = 0f, ownerName = "external", ), TransitionStep( from = ALTERNATE_BOUNCER, to = GLANCEABLE_HUB, transitionState = STARTED, value = 1f, ownerName = ownerName, ), TransitionStep( from = ALTERNATE_BOUNCER, to = GLANCEABLE_HUB, transitionState = FINISHED, value = 1f, ownerName = ownerName, ), TransitionStep( from = GLANCEABLE_HUB, to = LOCKSCREEN, transitionState = STARTED, value = 0f, ownerName = ownerName, ), TransitionStep( from = GLANCEABLE_HUB, to = LOCKSCREEN, transitionState = RUNNING, value = 0.4f, ownerName = ownerName, ), TransitionStep( from = GLANCEABLE_HUB, to = LOCKSCREEN, transitionState = FINISHED, value = 1f, ownerName = ownerName, ), ) .inOrder() } } packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt +0 −89 Original line number Diff line number Diff line Loading @@ -1966,47 +1966,6 @@ class KeyguardTransitionScenariosTest(flags: FlagsParameterization?) : SysuiTest coroutineContext.cancelChildren() } @Test @DisableSceneContainer @EnableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR) fun glanceableHubToLockscreen_communalKtfRefactor() = testScope.runTest { // GIVEN a prior transition has run to GLANCEABLE_HUB communalSceneInteractor.changeScene(CommunalScenes.Communal, "test") runCurrent() clearInvocations(transitionRepository) // WHEN a transition away from glanceable hub starts val currentScene = CommunalScenes.Communal val targetScene = CommunalScenes.Blank val progress = MutableStateFlow(0f) val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Transition( fromScene = currentScene, toScene = targetScene, currentScene = flowOf(targetScene), progress = progress, isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), ) ) communalSceneInteractor.setTransitionState(transitionState) progress.value = .1f runCurrent() assertThat(transitionRepository) .startedTransition( ownerName = CommunalSceneTransitionInteractor::class.simpleName, from = KeyguardState.GLANCEABLE_HUB, to = KeyguardState.LOCKSCREEN, animatorAssertion = { it.isNull() }, // transition should be manually animated ) coroutineContext.cancelChildren() } @Test @DisableSceneContainer @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR) Loading Loading @@ -2259,54 +2218,6 @@ class KeyguardTransitionScenariosTest(flags: FlagsParameterization?) : SysuiTest coroutineContext.cancelChildren() } @Test @DisableSceneContainer @EnableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR) fun glanceableHubToDreaming_communalKtfRefactor() = testScope.runTest { // GIVEN that we are dreaming and not dozing powerInteractor.setAwakeForTest() keyguardRepository.setDreaming(true) keyguardRepository.setDreamingWithOverlay(true) keyguardRepository.setDozeTransitionModel( DozeTransitionModel(from = DozeStateModel.DOZE, to = DozeStateModel.FINISH) ) advanceTimeBy(600L) // GIVEN a prior transition has run to GLANCEABLE_HUB communalSceneInteractor.changeScene(CommunalScenes.Communal, "test") runCurrent() clearInvocations(transitionRepository) // WHEN a transition away from glanceable hub starts val currentScene = CommunalScenes.Communal val targetScene = CommunalScenes.Blank val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Transition( fromScene = currentScene, toScene = targetScene, currentScene = flowOf(targetScene), progress = flowOf(0f, 0.1f), isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), ) ) communalSceneInteractor.setTransitionState(transitionState) runCurrent() assertThat(transitionRepository) .startedTransition( ownerName = CommunalSceneTransitionInteractor::class.simpleName, from = KeyguardState.GLANCEABLE_HUB, to = KeyguardState.DREAMING, animatorAssertion = { it.isNull() }, // transition should be manually animated ) coroutineContext.cancelChildren() } @Test @BrokenWithSceneContainer(339465026) @EnableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR) Loading packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalSceneTransitionInteractor.kt +5 −9 Original line number Diff line number Diff line Loading @@ -223,19 +223,15 @@ constructor( // KTF for this case and just collect the new progress instead. collectProgress(transition) } else if (transition.toScene == CommunalScenes.Communal) { if (currentTransitionId != null) { if (currentToState == KeyguardState.GLANCEABLE_HUB) { transitionKtfTo(transitionInteractor.getStartedFromState()) } } startTransitionToGlanceableHub() collectProgress(transition) } else if (transition.toScene == CommunalScenes.Blank) { if (currentTransitionId != null) { // Another transition started before this one is completed. Transition to the // GLANCEABLE_HUB state so that we can properly transition away from it. transitionKtfTo(KeyguardState.GLANCEABLE_HUB) } startTransitionFromGlanceableHub() collectProgress(transition) } Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalSceneTransitionInteractorTest.kt +83 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import com.android.systemui.keyguard.data.repository.keyguardTransitionRepositor import com.android.systemui.keyguard.data.repository.realKeyguardTransitionRepository import com.android.systemui.keyguard.shared.model.DozeStateModel import com.android.systemui.keyguard.shared.model.DozeTransitionModel import com.android.systemui.keyguard.shared.model.KeyguardState.ALTERNATE_BOUNCER import com.android.systemui.keyguard.shared.model.KeyguardState.DREAMING import com.android.systemui.keyguard.shared.model.KeyguardState.GLANCEABLE_HUB import com.android.systemui.keyguard.shared.model.KeyguardState.GONE Loading Loading @@ -834,4 +835,86 @@ class CommunalSceneTransitionInteractorTest : SysuiTestCase() { ) ) } /** * KTF: LOCKSCREEN -> ALTERNATE_BOUNCER starts but then STL: GLANCEABLE_HUB -> BLANK interrupts. * * Verifies that we correctly cancel the previous KTF state before starting the glanceable hub * transition. */ @Test fun transition_to_blank_after_ktf_started_another_transition() = testScope.runTest { // Another transition has already started to the alternate bouncer. keyguardTransitionRepository.startTransition( TransitionInfo( from = LOCKSCREEN, to = ALTERNATE_BOUNCER, animator = null, ownerName = "external", modeOnCanceled = TransitionModeOnCanceled.RESET ), ) val allSteps by collectValues(keyguardTransitionRepository.transitions) // Keep track of existing size to drop any pre-existing steps that we don't // care about. val numToDrop = allSteps.size sceneTransitions.value = hubToBlank runCurrent() progress.emit(0.4f) runCurrent() // We land on blank. sceneTransitions.value = Idle(CommunalScenes.Blank) // We should cancel the previous ALTERNATE_BOUNCER transition and transition back // to the GLANCEABLE_HUB before we can transition away from it. assertThat(allSteps.drop(numToDrop)) .containsExactly( TransitionStep( from = LOCKSCREEN, to = ALTERNATE_BOUNCER, transitionState = CANCELED, value = 0f, ownerName = "external", ), TransitionStep( from = ALTERNATE_BOUNCER, to = GLANCEABLE_HUB, transitionState = STARTED, value = 1f, ownerName = ownerName, ), TransitionStep( from = ALTERNATE_BOUNCER, to = GLANCEABLE_HUB, transitionState = FINISHED, value = 1f, ownerName = ownerName, ), TransitionStep( from = GLANCEABLE_HUB, to = LOCKSCREEN, transitionState = STARTED, value = 0f, ownerName = ownerName, ), TransitionStep( from = GLANCEABLE_HUB, to = LOCKSCREEN, transitionState = RUNNING, value = 0.4f, ownerName = ownerName, ), TransitionStep( from = GLANCEABLE_HUB, to = LOCKSCREEN, transitionState = FINISHED, value = 1f, ownerName = ownerName, ), ) .inOrder() } }
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt +0 −89 Original line number Diff line number Diff line Loading @@ -1966,47 +1966,6 @@ class KeyguardTransitionScenariosTest(flags: FlagsParameterization?) : SysuiTest coroutineContext.cancelChildren() } @Test @DisableSceneContainer @EnableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR) fun glanceableHubToLockscreen_communalKtfRefactor() = testScope.runTest { // GIVEN a prior transition has run to GLANCEABLE_HUB communalSceneInteractor.changeScene(CommunalScenes.Communal, "test") runCurrent() clearInvocations(transitionRepository) // WHEN a transition away from glanceable hub starts val currentScene = CommunalScenes.Communal val targetScene = CommunalScenes.Blank val progress = MutableStateFlow(0f) val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Transition( fromScene = currentScene, toScene = targetScene, currentScene = flowOf(targetScene), progress = progress, isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), ) ) communalSceneInteractor.setTransitionState(transitionState) progress.value = .1f runCurrent() assertThat(transitionRepository) .startedTransition( ownerName = CommunalSceneTransitionInteractor::class.simpleName, from = KeyguardState.GLANCEABLE_HUB, to = KeyguardState.LOCKSCREEN, animatorAssertion = { it.isNull() }, // transition should be manually animated ) coroutineContext.cancelChildren() } @Test @DisableSceneContainer @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR) Loading Loading @@ -2259,54 +2218,6 @@ class KeyguardTransitionScenariosTest(flags: FlagsParameterization?) : SysuiTest coroutineContext.cancelChildren() } @Test @DisableSceneContainer @EnableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR) fun glanceableHubToDreaming_communalKtfRefactor() = testScope.runTest { // GIVEN that we are dreaming and not dozing powerInteractor.setAwakeForTest() keyguardRepository.setDreaming(true) keyguardRepository.setDreamingWithOverlay(true) keyguardRepository.setDozeTransitionModel( DozeTransitionModel(from = DozeStateModel.DOZE, to = DozeStateModel.FINISH) ) advanceTimeBy(600L) // GIVEN a prior transition has run to GLANCEABLE_HUB communalSceneInteractor.changeScene(CommunalScenes.Communal, "test") runCurrent() clearInvocations(transitionRepository) // WHEN a transition away from glanceable hub starts val currentScene = CommunalScenes.Communal val targetScene = CommunalScenes.Blank val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Transition( fromScene = currentScene, toScene = targetScene, currentScene = flowOf(targetScene), progress = flowOf(0f, 0.1f), isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), ) ) communalSceneInteractor.setTransitionState(transitionState) runCurrent() assertThat(transitionRepository) .startedTransition( ownerName = CommunalSceneTransitionInteractor::class.simpleName, from = KeyguardState.GLANCEABLE_HUB, to = KeyguardState.DREAMING, animatorAssertion = { it.isNull() }, // transition should be manually animated ) coroutineContext.cancelChildren() } @Test @BrokenWithSceneContainer(339465026) @EnableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR) Loading
packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalSceneTransitionInteractor.kt +5 −9 Original line number Diff line number Diff line Loading @@ -223,19 +223,15 @@ constructor( // KTF for this case and just collect the new progress instead. collectProgress(transition) } else if (transition.toScene == CommunalScenes.Communal) { if (currentTransitionId != null) { if (currentToState == KeyguardState.GLANCEABLE_HUB) { transitionKtfTo(transitionInteractor.getStartedFromState()) } } startTransitionToGlanceableHub() collectProgress(transition) } else if (transition.toScene == CommunalScenes.Blank) { if (currentTransitionId != null) { // Another transition started before this one is completed. Transition to the // GLANCEABLE_HUB state so that we can properly transition away from it. transitionKtfTo(KeyguardState.GLANCEABLE_HUB) } startTransitionFromGlanceableHub() collectProgress(transition) } Loading