Loading packages/SystemUI/multivalentTests/src/com/android/systemui/communal/CommunalSceneStartableTest.kt +0 −302 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import android.provider.Settings import androidx.test.filters.SmallTest import com.android.internal.logging.uiEventLoggerFake import com.android.systemui.Flags.FLAG_COMMUNAL_HUB import com.android.systemui.Flags.FLAG_COMMUNAL_SCENE_KTF_REFACTOR import com.android.systemui.Flags.FLAG_SCENE_CONTAINER import com.android.systemui.SysuiTestCase import com.android.systemui.communal.domain.interactor.communalInteractor Loading @@ -33,26 +32,21 @@ import com.android.systemui.communal.domain.interactor.communalSettingsInteracto import com.android.systemui.communal.domain.interactor.setCommunalAvailable import com.android.systemui.communal.shared.log.CommunalUiEvent import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.communal.shared.model.EditModeState import com.android.systemui.coroutines.collectLastValue import com.android.systemui.dock.dockManager import com.android.systemui.dock.fakeDockManager import com.android.systemui.flags.Flags.COMMUNAL_SERVICE_ENABLED import com.android.systemui.flags.andSceneContainer import com.android.systemui.flags.fakeFeatureFlagsClassic import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor import com.android.systemui.keyguard.domain.interactor.keyguardInteractor import com.android.systemui.keyguard.domain.interactor.keyguardTransitionInteractor import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.kosmos.applicationCoroutineScope import com.android.systemui.kosmos.testDispatcher import com.android.systemui.kosmos.testScope import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.statusbar.notificationShadeWindowController import com.android.systemui.statusbar.phone.centralSurfaces import com.android.systemui.statusbar.phone.centralSurfacesOptional import com.android.systemui.testKosmos import com.android.systemui.util.settings.fakeSettings Loading @@ -64,10 +58,8 @@ import kotlinx.coroutines.test.advanceTimeBy import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Ignore import org.junit.Test import org.junit.runner.RunWith import org.mockito.kotlin.whenever import platform.test.runner.parameterized.ParameterizedAndroidJunit4 import platform.test.runner.parameterized.Parameters Loading Loading @@ -131,272 +123,6 @@ class CommunalSceneStartableTest(flags: FlagsParameterization) : SysuiTestCase() } } @Test @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR, FLAG_SCENE_CONTAINER) fun keyguardGoesAway_whenLaunchingEditMode_doNotForceBlankScene() = with(kosmos) { testScope.runTest { val scene by collectLastValue(communalSceneInteractor.currentScene) communalSceneInteractor.changeScene(CommunalScenes.Communal, "test") assertThat(scene).isEqualTo(CommunalScenes.Communal) communalSceneInteractor.setEditModeState(EditModeState.STARTING) fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.PRIMARY_BOUNCER, to = KeyguardState.GONE, testScope = this, ) assertThat(scene).isEqualTo(CommunalScenes.Communal) } } @Test @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR, FLAG_SCENE_CONTAINER) fun keyguardGoesAway_whenLaunchingWidget_doNotForceBlankScene() = with(kosmos) { testScope.runTest { val scene by collectLastValue(communalSceneInteractor.currentScene) communalSceneInteractor.changeScene(CommunalScenes.Communal, "test") assertThat(scene).isEqualTo(CommunalScenes.Communal) communalSceneInteractor.setIsLaunchingWidget(true) fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.PRIMARY_BOUNCER, to = KeyguardState.GONE, testScope = this, ) assertThat(scene).isEqualTo(CommunalScenes.Communal) } } @Test @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR, FLAG_SCENE_CONTAINER) fun keyguardGoesAway_whenNotLaunchingWidget_forceBlankScene() = with(kosmos) { testScope.runTest { val scene by collectLastValue(communalSceneInteractor.currentScene) communalSceneInteractor.changeScene(CommunalScenes.Communal, "test") assertThat(scene).isEqualTo(CommunalScenes.Communal) communalSceneInteractor.setIsLaunchingWidget(false) fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.PRIMARY_BOUNCER, to = KeyguardState.GONE, testScope = this, ) assertThat(scene).isEqualTo(CommunalScenes.Blank) } } @Test @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR, FLAG_SCENE_CONTAINER) fun keyguardGoesAway_whenInEditMode_doesNotChangeScene() = with(kosmos) { testScope.runTest { val scene by collectLastValue(communalSceneInteractor.currentScene) communalSceneInteractor.changeScene(CommunalScenes.Communal, "test") assertThat(scene).isEqualTo(CommunalScenes.Communal) communalInteractor.setEditModeOpen(true) fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.ALTERNATE_BOUNCER, to = KeyguardState.GONE, testScope = this, ) // Scene change will be handled in EditWidgetsActivity not here assertThat(scene).isEqualTo(CommunalScenes.Communal) } } @Ignore("Ignored until custom animations are implemented in b/322787129") @Test @DisableFlags(FLAG_SCENE_CONTAINER) fun deviceDocked_forceCommunalScene() = with(kosmos) { testScope.runTest { val scene by collectLastValue(communalSceneInteractor.currentScene) assertThat(scene).isEqualTo(CommunalScenes.Blank) updateDocked(true) fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.GONE, to = KeyguardState.LOCKSCREEN, testScope = this, ) assertThat(scene).isEqualTo(CommunalScenes.Communal) } } @Test @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR, FLAG_SCENE_CONTAINER) fun occluded_forceBlankScene() = with(kosmos) { testScope.runTest { whenever(centralSurfaces.isLaunchingActivityOverLockscreen).thenReturn(false) val scene by collectLastValue(communalSceneInteractor.currentScene) communalSceneInteractor.changeScene(CommunalScenes.Communal, "test") assertThat(scene).isEqualTo(CommunalScenes.Communal) updateDocked(true) fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.GLANCEABLE_HUB, to = KeyguardState.OCCLUDED, testScope = this, ) assertThat(scene).isEqualTo(CommunalScenes.Blank) } } @Test @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR, FLAG_SCENE_CONTAINER) fun occluded_doesNotForceBlankSceneIfLaunchingActivityOverLockscreen() = with(kosmos) { testScope.runTest { whenever(centralSurfaces.isLaunchingActivityOverLockscreen).thenReturn(true) val scene by collectLastValue(communalSceneInteractor.currentScene) communalSceneInteractor.changeScene(CommunalScenes.Communal, "test") assertThat(scene).isEqualTo(CommunalScenes.Communal) updateDocked(true) fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.GLANCEABLE_HUB, to = KeyguardState.OCCLUDED, testScope = this, ) assertThat(scene).isEqualTo(CommunalScenes.Communal) } } @Test @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR, FLAG_SCENE_CONTAINER) fun deviceDocked_doesNotForceCommunalIfTransitioningFromCommunal() = with(kosmos) { testScope.runTest { val scene by collectLastValue(communalSceneInteractor.currentScene) assertThat(scene).isEqualTo(CommunalScenes.Blank) updateDocked(true) fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.GLANCEABLE_HUB, to = KeyguardState.LOCKSCREEN, testScope = this, ) assertThat(scene).isEqualTo(CommunalScenes.Blank) } } @Test @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR, FLAG_SCENE_CONTAINER) fun deviceAsleep_forceBlankSceneAfterTimeout() = with(kosmos) { testScope.runTest { val scene by collectLastValue(communalSceneInteractor.currentScene) communalSceneInteractor.changeScene(CommunalScenes.Communal, "test") assertThat(scene).isEqualTo(CommunalScenes.Communal) fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.GLANCEABLE_HUB, to = KeyguardState.OFF, testScope = this, ) assertThat(scene).isEqualTo(CommunalScenes.Communal) advanceTimeBy(CommunalSceneStartable.AWAKE_DEBOUNCE_DELAY) assertThat(scene).isEqualTo(CommunalScenes.Blank) } } @Test @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR, FLAG_SCENE_CONTAINER) fun deviceAsleep_wakesUpBeforeTimeout_noChangeInScene() = with(kosmos) { testScope.runTest { val scene by collectLastValue(communalSceneInteractor.currentScene) communalSceneInteractor.changeScene(CommunalScenes.Communal, "test") assertThat(scene).isEqualTo(CommunalScenes.Communal) fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.GLANCEABLE_HUB, to = KeyguardState.OFF, testScope = this, ) assertThat(scene).isEqualTo(CommunalScenes.Communal) advanceTimeBy(CommunalSceneStartable.AWAKE_DEBOUNCE_DELAY / 2) assertThat(scene).isEqualTo(CommunalScenes.Communal) fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.OFF, to = KeyguardState.GLANCEABLE_HUB, testScope = this, ) advanceTimeBy(CommunalSceneStartable.AWAKE_DEBOUNCE_DELAY) assertThat(scene).isEqualTo(CommunalScenes.Communal) } } @Ignore("Ignored until custom animations are implemented in b/322787129") @Test @DisableFlags(FLAG_SCENE_CONTAINER) fun dockingOnLockscreen_forcesCommunal() = with(kosmos) { testScope.runTest { communalSceneInteractor.changeScene(CommunalScenes.Blank, "test") val scene by collectLastValue(communalSceneInteractor.currentScene) // device is docked while on the lockscreen fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.GLANCEABLE_HUB, to = KeyguardState.LOCKSCREEN, testScope = this, ) updateDocked(true) assertThat(scene).isEqualTo(CommunalScenes.Blank) advanceTimeBy(CommunalSceneStartable.DOCK_DEBOUNCE_DELAY) assertThat(scene).isEqualTo(CommunalScenes.Communal) } } @Ignore("Ignored until custom animations are implemented in b/322787129") @Test @DisableFlags(FLAG_SCENE_CONTAINER) fun dockingOnLockscreen_doesNotForceCommunalIfDreamStarts() = with(kosmos) { testScope.runTest { communalSceneInteractor.changeScene(CommunalScenes.Blank, "test") val scene by collectLastValue(communalSceneInteractor.currentScene) // device is docked while on the lockscreen fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.GLANCEABLE_HUB, to = KeyguardState.LOCKSCREEN, testScope = this, ) updateDocked(true) assertThat(scene).isEqualTo(CommunalScenes.Blank) advanceTimeBy(CommunalSceneStartable.DOCK_DEBOUNCE_DELAY / 2) assertThat(scene).isEqualTo(CommunalScenes.Blank) // dream starts shortly after docking fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.LOCKSCREEN, to = KeyguardState.DREAMING, testScope = this, ) advanceTimeBy(CommunalSceneStartable.DOCK_DEBOUNCE_DELAY) assertThat(scene).isEqualTo(CommunalScenes.Blank) } } @Test @DisableFlags(FLAG_SCENE_CONTAINER) fun hubTimeout_whenDreaming_goesToBlank() = Loading Loading @@ -711,34 +437,6 @@ class CommunalSceneStartableTest(flags: FlagsParameterization) : SysuiTestCase() } } @Test @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR, FLAG_SCENE_CONTAINER) fun transitionFromDozingToGlanceableHub_forcesCommunal() = with(kosmos) { testScope.runTest { val scene by collectLastValue(communalSceneInteractor.currentScene) communalSceneInteractor.changeScene(CommunalScenes.Blank, "test") assertThat(scene).isEqualTo(CommunalScenes.Blank) fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.DOZING, to = KeyguardState.GLANCEABLE_HUB, testScope = this, ) assertThat(scene).isEqualTo(CommunalScenes.Communal) } } private fun TestScope.updateDocked(docked: Boolean) = with(kosmos) { runCurrent() fakeDockManager.setIsDocked(docked) // TODO(b/322787129): uncomment once custom animations are in place // fakeDockManager.setDockEvent(DockManager.STATE_DOCKED) runCurrent() } private fun TestScope.updateDreaming(dreaming: Boolean) = with(kosmos) { fakeKeyguardRepository.setDreaming(dreaming) Loading packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalSceneTransitionInteractorTest.kt +1 −2 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import androidx.test.filters.SmallTest import com.android.compose.animation.scene.ObservableTransitionState import com.android.compose.animation.scene.ObservableTransitionState.Idle import com.android.systemui.Flags.FLAG_COMMUNAL_HUB import com.android.systemui.Flags.FLAG_COMMUNAL_SCENE_KTF_REFACTOR import com.android.systemui.SysuiTestCase import com.android.systemui.communal.data.repository.communalSceneRepository import com.android.systemui.communal.shared.model.CommunalScenes Loading Loading @@ -64,7 +63,7 @@ import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) @EnableFlags(FLAG_COMMUNAL_HUB, FLAG_COMMUNAL_SCENE_KTF_REFACTOR) @EnableFlags(FLAG_COMMUNAL_HUB) @DisableSceneContainer class CommunalSceneTransitionInteractorTest : SysuiTestCase() { Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/FromDozingTransitionInteractorTest.kt +1 −40 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ import android.service.dream.dreamManager import androidx.test.filters.SmallTest import com.android.compose.animation.scene.ObservableTransitionState import com.android.systemui.Flags.FLAG_COMMUNAL_HUB import com.android.systemui.Flags.FLAG_COMMUNAL_SCENE_KTF_REFACTOR import com.android.systemui.Flags.FLAG_GLANCEABLE_HUB_V2 import com.android.systemui.Flags.FLAG_KEYGUARD_WM_STATE_REFACTOR import com.android.systemui.Flags.FLAG_SCENE_CONTAINER Loading @@ -39,7 +38,6 @@ import com.android.systemui.communal.data.repository.fakeCommunalSceneRepository import com.android.systemui.communal.domain.interactor.setCommunalAvailable import com.android.systemui.communal.domain.interactor.setCommunalV2ConfigEnabled import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.coroutines.collectLastValue import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepositorySpy import com.android.systemui.keyguard.data.repository.keyguardOcclusionRepository Loading Loading @@ -70,7 +68,6 @@ import junit.framework.Assert.assertEquals import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.advanceTimeBy import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Test import org.junit.runner.RunWith Loading Loading @@ -103,10 +100,7 @@ class FromDozingTransitionInteractorTest(flags: FlagsParameterization?) : SysuiT @JvmStatic @Parameters(name = "{0}") fun getParams(): List<FlagsParameterization> { return FlagsParameterization.allCombinationsOf( FLAG_COMMUNAL_SCENE_KTF_REFACTOR, FLAG_GLANCEABLE_HUB_V2, ) return FlagsParameterization.allCombinationsOf(FLAG_GLANCEABLE_HUB_V2) } } Loading Loading @@ -174,22 +168,6 @@ class FromDozingTransitionInteractorTest(flags: FlagsParameterization?) : SysuiT @Test @EnableFlags(FLAG_KEYGUARD_WM_STATE_REFACTOR) @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR, FLAG_GLANCEABLE_HUB_V2) fun testTransitionToLockscreen_onWake_canDream_glanceableHubAvailable() = kosmos.runTest { whenever(dreamManager.canStartDreaming(anyBoolean())).thenReturn(true) setCommunalAvailable(true) powerInteractor.setAwakeForTest() // If dreaming is possible and communal is available, then we should transition to // GLANCEABLE_HUB when waking up due to power button press. assertThat(transitionRepository) .startedTransition(from = KeyguardState.DOZING, to = KeyguardState.GLANCEABLE_HUB) } @Test @EnableFlags(FLAG_KEYGUARD_WM_STATE_REFACTOR, FLAG_COMMUNAL_SCENE_KTF_REFACTOR) fun testTransitionToLockscreen_onWake_canDream_ktfRefactor() = kosmos.runTest { setCommunalAvailable(true) Loading Loading @@ -242,25 +220,8 @@ class FromDozingTransitionInteractorTest(flags: FlagsParameterization?) : SysuiT .startedTransition(from = KeyguardState.DOZING, to = KeyguardState.LOCKSCREEN) } @Test @EnableFlags(FLAG_KEYGUARD_WM_STATE_REFACTOR) @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR) fun testTransitionToGlanceableHub_onWakeup_ifIdleOnCommunal_noOccludingActivity() = kosmos.runTest { fakeCommunalSceneRepository.setTransitionState( flowOf(ObservableTransitionState.Idle(CommunalScenes.Communal)) ) powerInteractor.setAwakeForTest() // Under default conditions, we should transition to LOCKSCREEN when waking up. assertThat(transitionRepository) .startedTransition(from = KeyguardState.DOZING, to = KeyguardState.GLANCEABLE_HUB) } @Test @DisableFlags(FLAG_KEYGUARD_WM_STATE_REFACTOR, FLAG_SCENE_CONTAINER) @EnableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR) fun testTransitionToGlanceableHub_onWakeup_ifAvailable() = kosmos.runTest { setCommunalAvailable(true) Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/FromDreamingTransitionInteractorTest.kt +1 −6 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import android.provider.Settings import android.service.dream.dreamManager import androidx.test.filters.SmallTest import com.android.systemui.Flags import com.android.systemui.Flags.FLAG_COMMUNAL_SCENE_KTF_REFACTOR import com.android.systemui.Flags.FLAG_GLANCEABLE_HUB_V2 import com.android.systemui.Flags.glanceableHubV2 import com.android.systemui.SysuiTestCase Loading Loading @@ -74,10 +73,7 @@ class FromDreamingTransitionInteractorTest(flags: FlagsParameterization?) : Sysu @JvmStatic @Parameters(name = "{0}") fun getParams(): List<FlagsParameterization> { return FlagsParameterization.allCombinationsOf( FLAG_COMMUNAL_SCENE_KTF_REFACTOR, FLAG_GLANCEABLE_HUB_V2, ) return FlagsParameterization.allCombinationsOf(FLAG_GLANCEABLE_HUB_V2) .andSceneContainer() } } Loading Loading @@ -202,7 +198,6 @@ class FromDreamingTransitionInteractorTest(flags: FlagsParameterization?) : Sysu } @Test @EnableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR) @DisableFlags(Flags.FLAG_SCENE_CONTAINER) fun testTransitionToGlanceableHubOnWake() = kosmos.runTest { Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/FromOccludedTransitionInteractorTest.kt +0 −23 Original line number Diff line number Diff line Loading @@ -32,16 +32,11 @@ package com.android.systemui.keyguard.domain.interactor import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.compose.animation.scene.ObservableTransitionState import com.android.systemui.Flags import com.android.systemui.Flags.FLAG_COMMUNAL_SCENE_KTF_REFACTOR import com.android.systemui.SysuiTestCase import com.android.systemui.communal.data.repository.fakeCommunalSceneRepository import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepositorySpy import com.android.systemui.keyguard.data.repository.keyguardOcclusionRepository import com.android.systemui.keyguard.data.repository.keyguardTransitionRepository Loading @@ -51,7 +46,6 @@ import com.android.systemui.kosmos.testScope import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAwakeForTest import com.android.systemui.power.domain.interactor.powerInteractor import com.android.systemui.testKosmos import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest Loading Loading @@ -101,21 +95,4 @@ class FromOccludedTransitionInteractorTest : SysuiTestCase() { assertThat(transitionRepository) .startedTransition(from = KeyguardState.OCCLUDED, to = KeyguardState.LOCKSCREEN) } @Test @EnableFlags(Flags.FLAG_KEYGUARD_WM_STATE_REFACTOR) @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR) fun testShowWhenLockedActivity_noLongerOnTop_transitionsToGlanceableHub_ifIdleOnCommunal() = testScope.runTest { kosmos.fakeCommunalSceneRepository.setTransitionState( flowOf(ObservableTransitionState.Idle(CommunalScenes.Communal)) ) runCurrent() kosmos.keyguardOcclusionRepository.setShowWhenLockedActivityInfo(onTop = false) runCurrent() assertThat(transitionRepository) .startedTransition(from = KeyguardState.OCCLUDED, to = KeyguardState.GLANCEABLE_HUB) } } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/communal/CommunalSceneStartableTest.kt +0 −302 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import android.provider.Settings import androidx.test.filters.SmallTest import com.android.internal.logging.uiEventLoggerFake import com.android.systemui.Flags.FLAG_COMMUNAL_HUB import com.android.systemui.Flags.FLAG_COMMUNAL_SCENE_KTF_REFACTOR import com.android.systemui.Flags.FLAG_SCENE_CONTAINER import com.android.systemui.SysuiTestCase import com.android.systemui.communal.domain.interactor.communalInteractor Loading @@ -33,26 +32,21 @@ import com.android.systemui.communal.domain.interactor.communalSettingsInteracto import com.android.systemui.communal.domain.interactor.setCommunalAvailable import com.android.systemui.communal.shared.log.CommunalUiEvent import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.communal.shared.model.EditModeState import com.android.systemui.coroutines.collectLastValue import com.android.systemui.dock.dockManager import com.android.systemui.dock.fakeDockManager import com.android.systemui.flags.Flags.COMMUNAL_SERVICE_ENABLED import com.android.systemui.flags.andSceneContainer import com.android.systemui.flags.fakeFeatureFlagsClassic import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor import com.android.systemui.keyguard.domain.interactor.keyguardInteractor import com.android.systemui.keyguard.domain.interactor.keyguardTransitionInteractor import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.kosmos.applicationCoroutineScope import com.android.systemui.kosmos.testDispatcher import com.android.systemui.kosmos.testScope import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.statusbar.notificationShadeWindowController import com.android.systemui.statusbar.phone.centralSurfaces import com.android.systemui.statusbar.phone.centralSurfacesOptional import com.android.systemui.testKosmos import com.android.systemui.util.settings.fakeSettings Loading @@ -64,10 +58,8 @@ import kotlinx.coroutines.test.advanceTimeBy import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Ignore import org.junit.Test import org.junit.runner.RunWith import org.mockito.kotlin.whenever import platform.test.runner.parameterized.ParameterizedAndroidJunit4 import platform.test.runner.parameterized.Parameters Loading Loading @@ -131,272 +123,6 @@ class CommunalSceneStartableTest(flags: FlagsParameterization) : SysuiTestCase() } } @Test @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR, FLAG_SCENE_CONTAINER) fun keyguardGoesAway_whenLaunchingEditMode_doNotForceBlankScene() = with(kosmos) { testScope.runTest { val scene by collectLastValue(communalSceneInteractor.currentScene) communalSceneInteractor.changeScene(CommunalScenes.Communal, "test") assertThat(scene).isEqualTo(CommunalScenes.Communal) communalSceneInteractor.setEditModeState(EditModeState.STARTING) fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.PRIMARY_BOUNCER, to = KeyguardState.GONE, testScope = this, ) assertThat(scene).isEqualTo(CommunalScenes.Communal) } } @Test @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR, FLAG_SCENE_CONTAINER) fun keyguardGoesAway_whenLaunchingWidget_doNotForceBlankScene() = with(kosmos) { testScope.runTest { val scene by collectLastValue(communalSceneInteractor.currentScene) communalSceneInteractor.changeScene(CommunalScenes.Communal, "test") assertThat(scene).isEqualTo(CommunalScenes.Communal) communalSceneInteractor.setIsLaunchingWidget(true) fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.PRIMARY_BOUNCER, to = KeyguardState.GONE, testScope = this, ) assertThat(scene).isEqualTo(CommunalScenes.Communal) } } @Test @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR, FLAG_SCENE_CONTAINER) fun keyguardGoesAway_whenNotLaunchingWidget_forceBlankScene() = with(kosmos) { testScope.runTest { val scene by collectLastValue(communalSceneInteractor.currentScene) communalSceneInteractor.changeScene(CommunalScenes.Communal, "test") assertThat(scene).isEqualTo(CommunalScenes.Communal) communalSceneInteractor.setIsLaunchingWidget(false) fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.PRIMARY_BOUNCER, to = KeyguardState.GONE, testScope = this, ) assertThat(scene).isEqualTo(CommunalScenes.Blank) } } @Test @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR, FLAG_SCENE_CONTAINER) fun keyguardGoesAway_whenInEditMode_doesNotChangeScene() = with(kosmos) { testScope.runTest { val scene by collectLastValue(communalSceneInteractor.currentScene) communalSceneInteractor.changeScene(CommunalScenes.Communal, "test") assertThat(scene).isEqualTo(CommunalScenes.Communal) communalInteractor.setEditModeOpen(true) fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.ALTERNATE_BOUNCER, to = KeyguardState.GONE, testScope = this, ) // Scene change will be handled in EditWidgetsActivity not here assertThat(scene).isEqualTo(CommunalScenes.Communal) } } @Ignore("Ignored until custom animations are implemented in b/322787129") @Test @DisableFlags(FLAG_SCENE_CONTAINER) fun deviceDocked_forceCommunalScene() = with(kosmos) { testScope.runTest { val scene by collectLastValue(communalSceneInteractor.currentScene) assertThat(scene).isEqualTo(CommunalScenes.Blank) updateDocked(true) fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.GONE, to = KeyguardState.LOCKSCREEN, testScope = this, ) assertThat(scene).isEqualTo(CommunalScenes.Communal) } } @Test @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR, FLAG_SCENE_CONTAINER) fun occluded_forceBlankScene() = with(kosmos) { testScope.runTest { whenever(centralSurfaces.isLaunchingActivityOverLockscreen).thenReturn(false) val scene by collectLastValue(communalSceneInteractor.currentScene) communalSceneInteractor.changeScene(CommunalScenes.Communal, "test") assertThat(scene).isEqualTo(CommunalScenes.Communal) updateDocked(true) fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.GLANCEABLE_HUB, to = KeyguardState.OCCLUDED, testScope = this, ) assertThat(scene).isEqualTo(CommunalScenes.Blank) } } @Test @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR, FLAG_SCENE_CONTAINER) fun occluded_doesNotForceBlankSceneIfLaunchingActivityOverLockscreen() = with(kosmos) { testScope.runTest { whenever(centralSurfaces.isLaunchingActivityOverLockscreen).thenReturn(true) val scene by collectLastValue(communalSceneInteractor.currentScene) communalSceneInteractor.changeScene(CommunalScenes.Communal, "test") assertThat(scene).isEqualTo(CommunalScenes.Communal) updateDocked(true) fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.GLANCEABLE_HUB, to = KeyguardState.OCCLUDED, testScope = this, ) assertThat(scene).isEqualTo(CommunalScenes.Communal) } } @Test @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR, FLAG_SCENE_CONTAINER) fun deviceDocked_doesNotForceCommunalIfTransitioningFromCommunal() = with(kosmos) { testScope.runTest { val scene by collectLastValue(communalSceneInteractor.currentScene) assertThat(scene).isEqualTo(CommunalScenes.Blank) updateDocked(true) fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.GLANCEABLE_HUB, to = KeyguardState.LOCKSCREEN, testScope = this, ) assertThat(scene).isEqualTo(CommunalScenes.Blank) } } @Test @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR, FLAG_SCENE_CONTAINER) fun deviceAsleep_forceBlankSceneAfterTimeout() = with(kosmos) { testScope.runTest { val scene by collectLastValue(communalSceneInteractor.currentScene) communalSceneInteractor.changeScene(CommunalScenes.Communal, "test") assertThat(scene).isEqualTo(CommunalScenes.Communal) fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.GLANCEABLE_HUB, to = KeyguardState.OFF, testScope = this, ) assertThat(scene).isEqualTo(CommunalScenes.Communal) advanceTimeBy(CommunalSceneStartable.AWAKE_DEBOUNCE_DELAY) assertThat(scene).isEqualTo(CommunalScenes.Blank) } } @Test @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR, FLAG_SCENE_CONTAINER) fun deviceAsleep_wakesUpBeforeTimeout_noChangeInScene() = with(kosmos) { testScope.runTest { val scene by collectLastValue(communalSceneInteractor.currentScene) communalSceneInteractor.changeScene(CommunalScenes.Communal, "test") assertThat(scene).isEqualTo(CommunalScenes.Communal) fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.GLANCEABLE_HUB, to = KeyguardState.OFF, testScope = this, ) assertThat(scene).isEqualTo(CommunalScenes.Communal) advanceTimeBy(CommunalSceneStartable.AWAKE_DEBOUNCE_DELAY / 2) assertThat(scene).isEqualTo(CommunalScenes.Communal) fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.OFF, to = KeyguardState.GLANCEABLE_HUB, testScope = this, ) advanceTimeBy(CommunalSceneStartable.AWAKE_DEBOUNCE_DELAY) assertThat(scene).isEqualTo(CommunalScenes.Communal) } } @Ignore("Ignored until custom animations are implemented in b/322787129") @Test @DisableFlags(FLAG_SCENE_CONTAINER) fun dockingOnLockscreen_forcesCommunal() = with(kosmos) { testScope.runTest { communalSceneInteractor.changeScene(CommunalScenes.Blank, "test") val scene by collectLastValue(communalSceneInteractor.currentScene) // device is docked while on the lockscreen fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.GLANCEABLE_HUB, to = KeyguardState.LOCKSCREEN, testScope = this, ) updateDocked(true) assertThat(scene).isEqualTo(CommunalScenes.Blank) advanceTimeBy(CommunalSceneStartable.DOCK_DEBOUNCE_DELAY) assertThat(scene).isEqualTo(CommunalScenes.Communal) } } @Ignore("Ignored until custom animations are implemented in b/322787129") @Test @DisableFlags(FLAG_SCENE_CONTAINER) fun dockingOnLockscreen_doesNotForceCommunalIfDreamStarts() = with(kosmos) { testScope.runTest { communalSceneInteractor.changeScene(CommunalScenes.Blank, "test") val scene by collectLastValue(communalSceneInteractor.currentScene) // device is docked while on the lockscreen fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.GLANCEABLE_HUB, to = KeyguardState.LOCKSCREEN, testScope = this, ) updateDocked(true) assertThat(scene).isEqualTo(CommunalScenes.Blank) advanceTimeBy(CommunalSceneStartable.DOCK_DEBOUNCE_DELAY / 2) assertThat(scene).isEqualTo(CommunalScenes.Blank) // dream starts shortly after docking fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.LOCKSCREEN, to = KeyguardState.DREAMING, testScope = this, ) advanceTimeBy(CommunalSceneStartable.DOCK_DEBOUNCE_DELAY) assertThat(scene).isEqualTo(CommunalScenes.Blank) } } @Test @DisableFlags(FLAG_SCENE_CONTAINER) fun hubTimeout_whenDreaming_goesToBlank() = Loading Loading @@ -711,34 +437,6 @@ class CommunalSceneStartableTest(flags: FlagsParameterization) : SysuiTestCase() } } @Test @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR, FLAG_SCENE_CONTAINER) fun transitionFromDozingToGlanceableHub_forcesCommunal() = with(kosmos) { testScope.runTest { val scene by collectLastValue(communalSceneInteractor.currentScene) communalSceneInteractor.changeScene(CommunalScenes.Blank, "test") assertThat(scene).isEqualTo(CommunalScenes.Blank) fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.DOZING, to = KeyguardState.GLANCEABLE_HUB, testScope = this, ) assertThat(scene).isEqualTo(CommunalScenes.Communal) } } private fun TestScope.updateDocked(docked: Boolean) = with(kosmos) { runCurrent() fakeDockManager.setIsDocked(docked) // TODO(b/322787129): uncomment once custom animations are in place // fakeDockManager.setDockEvent(DockManager.STATE_DOCKED) runCurrent() } private fun TestScope.updateDreaming(dreaming: Boolean) = with(kosmos) { fakeKeyguardRepository.setDreaming(dreaming) Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalSceneTransitionInteractorTest.kt +1 −2 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import androidx.test.filters.SmallTest import com.android.compose.animation.scene.ObservableTransitionState import com.android.compose.animation.scene.ObservableTransitionState.Idle import com.android.systemui.Flags.FLAG_COMMUNAL_HUB import com.android.systemui.Flags.FLAG_COMMUNAL_SCENE_KTF_REFACTOR import com.android.systemui.SysuiTestCase import com.android.systemui.communal.data.repository.communalSceneRepository import com.android.systemui.communal.shared.model.CommunalScenes Loading Loading @@ -64,7 +63,7 @@ import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) @EnableFlags(FLAG_COMMUNAL_HUB, FLAG_COMMUNAL_SCENE_KTF_REFACTOR) @EnableFlags(FLAG_COMMUNAL_HUB) @DisableSceneContainer class CommunalSceneTransitionInteractorTest : SysuiTestCase() { Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/FromDozingTransitionInteractorTest.kt +1 −40 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ import android.service.dream.dreamManager import androidx.test.filters.SmallTest import com.android.compose.animation.scene.ObservableTransitionState import com.android.systemui.Flags.FLAG_COMMUNAL_HUB import com.android.systemui.Flags.FLAG_COMMUNAL_SCENE_KTF_REFACTOR import com.android.systemui.Flags.FLAG_GLANCEABLE_HUB_V2 import com.android.systemui.Flags.FLAG_KEYGUARD_WM_STATE_REFACTOR import com.android.systemui.Flags.FLAG_SCENE_CONTAINER Loading @@ -39,7 +38,6 @@ import com.android.systemui.communal.data.repository.fakeCommunalSceneRepository import com.android.systemui.communal.domain.interactor.setCommunalAvailable import com.android.systemui.communal.domain.interactor.setCommunalV2ConfigEnabled import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.coroutines.collectLastValue import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepositorySpy import com.android.systemui.keyguard.data.repository.keyguardOcclusionRepository Loading Loading @@ -70,7 +68,6 @@ import junit.framework.Assert.assertEquals import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.advanceTimeBy import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Test import org.junit.runner.RunWith Loading Loading @@ -103,10 +100,7 @@ class FromDozingTransitionInteractorTest(flags: FlagsParameterization?) : SysuiT @JvmStatic @Parameters(name = "{0}") fun getParams(): List<FlagsParameterization> { return FlagsParameterization.allCombinationsOf( FLAG_COMMUNAL_SCENE_KTF_REFACTOR, FLAG_GLANCEABLE_HUB_V2, ) return FlagsParameterization.allCombinationsOf(FLAG_GLANCEABLE_HUB_V2) } } Loading Loading @@ -174,22 +168,6 @@ class FromDozingTransitionInteractorTest(flags: FlagsParameterization?) : SysuiT @Test @EnableFlags(FLAG_KEYGUARD_WM_STATE_REFACTOR) @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR, FLAG_GLANCEABLE_HUB_V2) fun testTransitionToLockscreen_onWake_canDream_glanceableHubAvailable() = kosmos.runTest { whenever(dreamManager.canStartDreaming(anyBoolean())).thenReturn(true) setCommunalAvailable(true) powerInteractor.setAwakeForTest() // If dreaming is possible and communal is available, then we should transition to // GLANCEABLE_HUB when waking up due to power button press. assertThat(transitionRepository) .startedTransition(from = KeyguardState.DOZING, to = KeyguardState.GLANCEABLE_HUB) } @Test @EnableFlags(FLAG_KEYGUARD_WM_STATE_REFACTOR, FLAG_COMMUNAL_SCENE_KTF_REFACTOR) fun testTransitionToLockscreen_onWake_canDream_ktfRefactor() = kosmos.runTest { setCommunalAvailable(true) Loading Loading @@ -242,25 +220,8 @@ class FromDozingTransitionInteractorTest(flags: FlagsParameterization?) : SysuiT .startedTransition(from = KeyguardState.DOZING, to = KeyguardState.LOCKSCREEN) } @Test @EnableFlags(FLAG_KEYGUARD_WM_STATE_REFACTOR) @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR) fun testTransitionToGlanceableHub_onWakeup_ifIdleOnCommunal_noOccludingActivity() = kosmos.runTest { fakeCommunalSceneRepository.setTransitionState( flowOf(ObservableTransitionState.Idle(CommunalScenes.Communal)) ) powerInteractor.setAwakeForTest() // Under default conditions, we should transition to LOCKSCREEN when waking up. assertThat(transitionRepository) .startedTransition(from = KeyguardState.DOZING, to = KeyguardState.GLANCEABLE_HUB) } @Test @DisableFlags(FLAG_KEYGUARD_WM_STATE_REFACTOR, FLAG_SCENE_CONTAINER) @EnableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR) fun testTransitionToGlanceableHub_onWakeup_ifAvailable() = kosmos.runTest { setCommunalAvailable(true) Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/FromDreamingTransitionInteractorTest.kt +1 −6 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import android.provider.Settings import android.service.dream.dreamManager import androidx.test.filters.SmallTest import com.android.systemui.Flags import com.android.systemui.Flags.FLAG_COMMUNAL_SCENE_KTF_REFACTOR import com.android.systemui.Flags.FLAG_GLANCEABLE_HUB_V2 import com.android.systemui.Flags.glanceableHubV2 import com.android.systemui.SysuiTestCase Loading Loading @@ -74,10 +73,7 @@ class FromDreamingTransitionInteractorTest(flags: FlagsParameterization?) : Sysu @JvmStatic @Parameters(name = "{0}") fun getParams(): List<FlagsParameterization> { return FlagsParameterization.allCombinationsOf( FLAG_COMMUNAL_SCENE_KTF_REFACTOR, FLAG_GLANCEABLE_HUB_V2, ) return FlagsParameterization.allCombinationsOf(FLAG_GLANCEABLE_HUB_V2) .andSceneContainer() } } Loading Loading @@ -202,7 +198,6 @@ class FromDreamingTransitionInteractorTest(flags: FlagsParameterization?) : Sysu } @Test @EnableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR) @DisableFlags(Flags.FLAG_SCENE_CONTAINER) fun testTransitionToGlanceableHubOnWake() = kosmos.runTest { Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/FromOccludedTransitionInteractorTest.kt +0 −23 Original line number Diff line number Diff line Loading @@ -32,16 +32,11 @@ package com.android.systemui.keyguard.domain.interactor import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.compose.animation.scene.ObservableTransitionState import com.android.systemui.Flags import com.android.systemui.Flags.FLAG_COMMUNAL_SCENE_KTF_REFACTOR import com.android.systemui.SysuiTestCase import com.android.systemui.communal.data.repository.fakeCommunalSceneRepository import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepositorySpy import com.android.systemui.keyguard.data.repository.keyguardOcclusionRepository import com.android.systemui.keyguard.data.repository.keyguardTransitionRepository Loading @@ -51,7 +46,6 @@ import com.android.systemui.kosmos.testScope import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAwakeForTest import com.android.systemui.power.domain.interactor.powerInteractor import com.android.systemui.testKosmos import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest Loading Loading @@ -101,21 +95,4 @@ class FromOccludedTransitionInteractorTest : SysuiTestCase() { assertThat(transitionRepository) .startedTransition(from = KeyguardState.OCCLUDED, to = KeyguardState.LOCKSCREEN) } @Test @EnableFlags(Flags.FLAG_KEYGUARD_WM_STATE_REFACTOR) @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR) fun testShowWhenLockedActivity_noLongerOnTop_transitionsToGlanceableHub_ifIdleOnCommunal() = testScope.runTest { kosmos.fakeCommunalSceneRepository.setTransitionState( flowOf(ObservableTransitionState.Idle(CommunalScenes.Communal)) ) runCurrent() kosmos.keyguardOcclusionRepository.setShowWhenLockedActivityInfo(onTop = false) runCurrent() assertThat(transitionRepository) .startedTransition(from = KeyguardState.OCCLUDED, to = KeyguardState.GLANCEABLE_HUB) } }