Loading packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalInteractorTest.kt +8 −108 Original line number Diff line number Diff line Loading @@ -42,7 +42,6 @@ import com.android.systemui.communal.data.model.CommunalSmartspaceTimer import com.android.systemui.communal.data.model.SuppressionReason import com.android.systemui.communal.data.repository.fakeCommunalMediaRepository import com.android.systemui.communal.data.repository.fakeCommunalPrefsRepository import com.android.systemui.communal.data.repository.fakeCommunalSceneRepository import com.android.systemui.communal.data.repository.fakeCommunalSmartspaceRepository import com.android.systemui.communal.data.repository.fakeCommunalTutorialRepository import com.android.systemui.communal.data.repository.fakeCommunalWidgetRepository Loading @@ -51,6 +50,7 @@ import com.android.systemui.communal.domain.model.CommunalTransitionProgressMode import com.android.systemui.communal.shared.model.CommunalContentSize import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.communal.shared.model.EditModeState import com.android.systemui.flags.DisableSceneContainer import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.flags.Flags import com.android.systemui.flags.fakeFeatureFlagsClassic Loading Loading @@ -379,29 +379,7 @@ class CommunalInteractorTest(flags: FlagsParameterization) : SysuiTestCase() { assertThat(ctaTileContent).isEmpty() } @Test fun listensToSceneChange() = kosmos.runTest { kosmos.setCommunalAvailable(true) val desiredScene by collectLastValue(underTest.desiredScene) assertThat(desiredScene).isEqualTo(CommunalScenes.Blank) val targetScene = CommunalScenes.Communal fakeCommunalSceneRepository.changeScene(targetScene) assertThat(desiredScene).isEqualTo(targetScene) } @Test fun updatesScene() = kosmos.runTest { val targetScene = CommunalScenes.Communal underTest.changeScene(targetScene, "test") val desiredScene by collectLastValue(fakeCommunalSceneRepository.currentScene) assertThat(desiredScene).isEqualTo(targetScene) } @DisableSceneContainer @Test fun transitionProgress_onTargetScene_fullProgress() = kosmos.runTest { Loading @@ -420,6 +398,7 @@ class CommunalInteractorTest(flags: FlagsParameterization) : SysuiTestCase() { .isEqualTo(CommunalTransitionProgressModel.Idle(targetScene)) } @DisableSceneContainer @Test fun transitionProgress_notOnTargetScene_noProgress() = kosmos.runTest { Loading @@ -439,6 +418,7 @@ class CommunalInteractorTest(flags: FlagsParameterization) : SysuiTestCase() { .isEqualTo(CommunalTransitionProgressModel.Idle(currentScene)) } @DisableSceneContainer @Test fun transitionProgress_transitioningToTrackedScene() = kosmos.runTest { Loading Loading @@ -487,6 +467,7 @@ class CommunalInteractorTest(flags: FlagsParameterization) : SysuiTestCase() { .isEqualTo(CommunalTransitionProgressModel.Idle(targetScene)) } @DisableSceneContainer @Test fun transitionProgress_transitioningAwayFromTrackedScene() = kosmos.runTest { Loading Loading @@ -550,6 +531,7 @@ class CommunalInteractorTest(flags: FlagsParameterization) : SysuiTestCase() { assertThat(isCommunalShowing).isEqualTo(true) } @DisableSceneContainer @Test fun isCommunalShowing_whenSceneContainerDisabled() = kosmos.runTest { Loading @@ -572,8 +554,8 @@ class CommunalInteractorTest(flags: FlagsParameterization) : SysuiTestCase() { assertThat(isCommunalShowing).isFalse() } @Test @EnableSceneContainer @Test fun isCommunalShowing_whenSceneContainerEnabled() = kosmos.runTest { // Verify default is false Loading @@ -589,8 +571,8 @@ class CommunalInteractorTest(flags: FlagsParameterization) : SysuiTestCase() { assertThat(isCommunalShowing).isFalse() } @Test @EnableSceneContainer @Test fun isCommunalShowing_whenSceneContainerEnabledAndChangeToLegacyScene() = kosmos.runTest { // Verify default is false Loading @@ -606,88 +588,6 @@ class CommunalInteractorTest(flags: FlagsParameterization) : SysuiTestCase() { assertThat(isCommunalShowing).isFalse() } @Test fun isIdleOnCommunal() = kosmos.runTest { val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Idle(CommunalScenes.Blank) ) fakeCommunalSceneRepository.setTransitionState(transitionState) // isIdleOnCommunal is false when not on communal. val isIdleOnCommunal by collectLastValue(underTest.isIdleOnCommunal) assertThat(isIdleOnCommunal).isEqualTo(false) // Transition to communal. transitionState.value = ObservableTransitionState.Idle(CommunalScenes.Communal) // isIdleOnCommunal is now true since we're on communal. assertThat(isIdleOnCommunal).isEqualTo(true) // Start transition away from communal. transitionState.value = ObservableTransitionState.Transition( fromScene = CommunalScenes.Communal, toScene = CommunalScenes.Blank, currentScene = flowOf(CommunalScenes.Blank), progress = flowOf(0f), isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), ) // isIdleOnCommunal turns false as soon as transition away starts. assertThat(isIdleOnCommunal).isEqualTo(false) } @Test fun isCommunalVisible() = kosmos.runTest { val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Idle(CommunalScenes.Blank) ) fakeCommunalSceneRepository.setTransitionState(transitionState) // isCommunalVisible is false when not on communal. val isCommunalVisible by collectLastValue(underTest.isCommunalVisible) assertThat(isCommunalVisible).isEqualTo(false) // Start transition to communal. transitionState.value = ObservableTransitionState.Transition( fromScene = CommunalScenes.Blank, toScene = CommunalScenes.Communal, currentScene = flowOf(CommunalScenes.Communal), progress = flowOf(0f), isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), ) // isCommunalVisible is true once transition starts. assertThat(isCommunalVisible).isEqualTo(true) // Finish transition to communal transitionState.value = ObservableTransitionState.Idle(CommunalScenes.Communal) // isCommunalVisible is true since we're on communal. assertThat(isCommunalVisible).isEqualTo(true) // Start transition away from communal. transitionState.value = ObservableTransitionState.Transition( fromScene = CommunalScenes.Communal, toScene = CommunalScenes.Blank, currentScene = flowOf(CommunalScenes.Blank), progress = flowOf(1.0f), isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), ) // isCommunalVisible is still true as the false as soon as transition away runs. assertThat(isCommunalVisible).isEqualTo(true) } @Test fun testShowWidgetEditorStartsActivity() = kosmos.runTest { Loading packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalSceneInteractorTest.kt +20 −22 Original line number Diff line number Diff line Loading @@ -18,12 +18,9 @@ package com.android.systemui.communal.domain.interactor import android.content.res.Configuration.ORIENTATION_LANDSCAPE import android.content.res.Configuration.ORIENTATION_PORTRAIT import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import android.platform.test.flag.junit.FlagsParameterization import androidx.test.filters.SmallTest import com.android.compose.animation.scene.ObservableTransitionState import com.android.systemui.Flags.FLAG_SCENE_CONTAINER import com.android.systemui.SysuiTestCase import com.android.systemui.animation.ActivityTransitionAnimator import com.android.systemui.communal.data.repository.communalSceneRepository Loading @@ -31,9 +28,10 @@ import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor.O import com.android.systemui.communal.domain.model.CommunalTransitionProgressModel import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.DisableSceneContainer import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.flags.andSceneContainer import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.testScope import com.android.systemui.scene.initialSceneKey import com.android.systemui.scene.shared.model.Scenes Loading Loading @@ -82,7 +80,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( private val underTest by lazy { kosmos.communalSceneInteractor } private val keyguardStateController: KeyguardStateController = kosmos.keyguardStateController @DisableFlags(FLAG_SCENE_CONTAINER) @DisableSceneContainer @Test fun changeScene() = testScope.runTest { Loading @@ -93,7 +91,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( assertThat(currentScene).isEqualTo(CommunalScenes.Communal) } @DisableFlags(FLAG_SCENE_CONTAINER) @DisableSceneContainer @Test fun changeScene_callsSceneStateProcessor() = testScope.runTest { Loading @@ -109,7 +107,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( verify(callback).onSceneAboutToChange(CommunalScenes.Communal, null) } @DisableFlags(FLAG_SCENE_CONTAINER) @DisableSceneContainer @Test fun changeScene_doesNotCallSceneStateProcessorForDuplicateState_ifKeyguardStateIsNull() = testScope.runTest { Loading @@ -125,7 +123,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( verify(callback, never()).onSceneAboutToChange(any(), anyOrNull()) } @DisableFlags(FLAG_SCENE_CONTAINER) @DisableSceneContainer @Test fun changeScene_callSceneStateProcessorForDuplicateScene_ifBlankSceneWithKeyguardState() = testScope.runTest { Loading @@ -145,7 +143,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( verify(callback).onSceneAboutToChange(CommunalScenes.Blank, KeyguardState.GONE) } @DisableFlags(FLAG_SCENE_CONTAINER) @DisableSceneContainer @Test fun snapToScene() = testScope.runTest { Loading @@ -156,7 +154,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( assertThat(currentScene).isEqualTo(CommunalScenes.Communal) } @DisableFlags(FLAG_SCENE_CONTAINER) @DisableSceneContainer @Test fun snapToSceneWithDelay() = testScope.runTest { Loading @@ -172,7 +170,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( assertThat(currentScene).isEqualTo(CommunalScenes.Communal) } @DisableFlags(FLAG_SCENE_CONTAINER) @DisableSceneContainer @Test fun transitionProgress_fullProgress() = testScope.runTest { Loading @@ -191,7 +189,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( .isEqualTo(CommunalTransitionProgressModel.Idle(CommunalScenes.Communal)) } @DisableFlags(FLAG_SCENE_CONTAINER) @DisableSceneContainer @Test fun transitionProgress_transitioningAwayFromTrackedScene() = testScope.runTest { Loading Loading @@ -232,7 +230,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( .isEqualTo(CommunalTransitionProgressModel.Idle(CommunalScenes.Communal)) } @DisableFlags(FLAG_SCENE_CONTAINER) @DisableSceneContainer @Test fun transitionProgress_transitioningToTrackedScene() = testScope.runTest { Loading Loading @@ -270,7 +268,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( .isEqualTo(CommunalTransitionProgressModel.Idle(CommunalScenes.Communal)) } @DisableFlags(FLAG_SCENE_CONTAINER) @DisableSceneContainer @Test fun isIdleOnCommunal() = testScope.runTest { Loading Loading @@ -298,7 +296,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( assertThat(isIdleOnCommunal).isEqualTo(false) } @DisableFlags(FLAG_SCENE_CONTAINER) @DisableSceneContainer @Test fun isTransitioningToOrIdleOnCommunal() = testScope.runTest { Loading Loading @@ -340,7 +338,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( assertThat(isTransitioningToOrIdleOnCommunal).isEqualTo(false) } @DisableFlags(FLAG_SCENE_CONTAINER) @DisableSceneContainer @Test fun isCommunalVisible() = testScope.runTest { Loading Loading @@ -381,7 +379,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( assertThat(isCommunalVisible).isEqualTo(true) } @EnableFlags(FLAG_SCENE_CONTAINER) @EnableSceneContainer @Test fun changeScene_legacyCommunalScene_mapToStfScene() = testScope.runTest { Loading @@ -403,7 +401,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( assertThat(currentScene).isEqualTo(Scenes.Lockscreen) } @EnableFlags(FLAG_SCENE_CONTAINER) @EnableSceneContainer @Test fun changeScene_stfScenes() = testScope.runTest { Loading @@ -425,7 +423,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( assertThat(currentScene).isEqualTo(Scenes.Lockscreen) } @EnableFlags(FLAG_SCENE_CONTAINER) @EnableSceneContainer @Test fun snapToScene_legacyCommunalScene_mapToStfScene() = testScope.runTest { Loading @@ -447,7 +445,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( assertThat(currentScene).isEqualTo(Scenes.Lockscreen) } @EnableFlags(FLAG_SCENE_CONTAINER) @EnableSceneContainer @Test fun snapToScene_stfScenes() = testScope.runTest { Loading @@ -469,7 +467,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( assertThat(currentScene).isEqualTo(Scenes.Lockscreen) } @EnableFlags(FLAG_SCENE_CONTAINER) @EnableSceneContainer @Test fun isIdleOnCommunal_sceneContainerEnabled() = testScope.runTest { Loading Loading @@ -514,7 +512,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( assertThat(isIdleOnCommunal).isEqualTo(false) } @EnableFlags(FLAG_SCENE_CONTAINER) @EnableSceneContainer @Test fun isCommunalVisible_sceneContainerEnabled() = testScope.runTest { Loading packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/WidgetTrampolineInteractorTest.kt +34 −12 Original line number Diff line number Diff line Loading @@ -19,11 +19,13 @@ package com.android.systemui.communal.domain.interactor import android.app.ActivityManager.RunningTaskInfo import android.app.usage.UsageEvents import android.content.pm.UserInfo import android.platform.test.flag.junit.FlagsParameterization import android.service.dream.dreamManager import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.usagestats.data.repository.fakeUsageStatsRepository import com.android.systemui.flags.DisableSceneContainer import com.android.systemui.flags.andSceneContainer import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.shared.model.TransitionState Loading Loading @@ -54,22 +56,24 @@ import org.mockito.kotlin.mock import org.mockito.kotlin.never import org.mockito.kotlin.times import org.mockito.kotlin.verify import platform.test.runner.parameterized.ParameterizedAndroidJunit4 import platform.test.runner.parameterized.Parameters @SmallTest @RunWith(AndroidJUnit4::class) class WidgetTrampolineInteractorTest : SysuiTestCase() { @RunWith(ParameterizedAndroidJunit4::class) class WidgetTrampolineInteractorTest(flags: FlagsParameterization) : SysuiTestCase() { private val kosmos = testKosmos() private val testScope = kosmos.testScope private val activityStarter = kosmos.activityStarter private val usageStatsRepository = kosmos.fakeUsageStatsRepository private val taskStackChangeListeners = kosmos.taskStackChangeListeners private val keyguardTransitionRepository = kosmos.fakeKeyguardTransitionRepository private val userTracker = kosmos.fakeUserTracker private val systemClock = kosmos.fakeSystemClock private val activityStarter by lazy { kosmos.activityStarter } private val usageStatsRepository by lazy { kosmos.fakeUsageStatsRepository } private val taskStackChangeListeners by lazy { kosmos.taskStackChangeListeners } private val keyguardTransitionRepository by lazy { kosmos.fakeKeyguardTransitionRepository } private val userTracker by lazy { kosmos.fakeUserTracker } private val systemClock by lazy { kosmos.fakeSystemClock } private val underTest = kosmos.widgetTrampolineInteractor private val underTest by lazy { kosmos.widgetTrampolineInteractor } @Before fun setUp() { Loading @@ -77,6 +81,7 @@ class WidgetTrampolineInteractorTest : SysuiTestCase() { systemClock.setCurrentTimeMillis(testScope.currentTime) } @DisableSceneContainer @Test fun testNewTaskStartsWhileOnHub_triggersUnlock() = testScope.runTest { Loading @@ -90,6 +95,7 @@ class WidgetTrampolineInteractorTest : SysuiTestCase() { verify(activityStarter).dismissKeyguardThenExecute(any(), anyOrNull(), any()) } @DisableSceneContainer @Test fun testNewTaskStartsWhileOnHub_stopsDream() = testScope.runTest { Loading @@ -111,6 +117,7 @@ class WidgetTrampolineInteractorTest : SysuiTestCase() { } } @DisableSceneContainer @Test fun testNewTaskStartsAfterExitingHub_doesNotTriggerUnlock() = testScope.runTest { Loading @@ -124,6 +131,7 @@ class WidgetTrampolineInteractorTest : SysuiTestCase() { verify(activityStarter, never()).dismissKeyguardThenExecute(any(), anyOrNull(), any()) } @DisableSceneContainer @Test fun testNewTaskStartsAfterTimeout_doesNotTriggerUnlock() = testScope.runTest { Loading @@ -137,6 +145,7 @@ class WidgetTrampolineInteractorTest : SysuiTestCase() { verify(activityStarter, never()).dismissKeyguardThenExecute(any(), anyOrNull(), any()) } @DisableSceneContainer @Test fun testActivityResumedWhileOnHub_triggersUnlock() = testScope.runTest { Loading @@ -150,6 +159,7 @@ class WidgetTrampolineInteractorTest : SysuiTestCase() { verify(activityStarter).dismissKeyguardThenExecute(any(), anyOrNull(), any()) } @DisableSceneContainer @Test fun testActivityResumedAfterExitingHub_doesNotTriggerUnlock() = testScope.runTest { Loading @@ -164,6 +174,7 @@ class WidgetTrampolineInteractorTest : SysuiTestCase() { verify(activityStarter, never()).dismissKeyguardThenExecute(any(), anyOrNull(), any()) } @DisableSceneContainer @Test fun testActivityDestroyed_doesNotTriggerUnlock() = testScope.runTest { Loading @@ -177,6 +188,7 @@ class WidgetTrampolineInteractorTest : SysuiTestCase() { verify(activityStarter, never()).dismissKeyguardThenExecute(any(), anyOrNull(), any()) } @DisableSceneContainer @Test fun testMultipleActivityEvents_triggersUnlockOnlyOnce() = testScope.runTest { Loading Loading @@ -236,7 +248,17 @@ class WidgetTrampolineInteractorTest : SysuiTestCase() { runCurrent() } private companion object { val MAIN_USER: UserInfo = UserInfo(0, "primary", UserInfo.FLAG_MAIN) init { mSetFlagsRule.setFlagsParameterization(flags) } companion object { private val MAIN_USER: UserInfo = UserInfo(0, "primary", UserInfo.FLAG_MAIN) @JvmStatic @Parameters(name = "{0}") fun getParams(): List<FlagsParameterization> { return FlagsParameterization.allCombinationsOf().andSceneContainer() } } } packages/SystemUI/multivalentTests/src/com/android/systemui/communal/widgets/CommunalTransitionAnimatorControllerTest.kt +68 −4 Original line number Diff line number Diff line Loading @@ -23,9 +23,12 @@ import com.android.systemui.animation.ActivityTransitionAnimator import com.android.systemui.communal.domain.interactor.communalSceneInteractor import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.DisableSceneContainer import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.kosmos.testScope import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.testKosmos import com.google.common.truth.Truth import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.advanceTimeBy import kotlinx.coroutines.test.runTest import org.junit.Assert.assertFalse Loading Loading @@ -67,6 +70,7 @@ class CommunalTransitionAnimatorControllerTest : SysuiTestCase() { } } @DisableSceneContainer @Test fun animationCancelled_launchingWidgetStateIsCleared() { with(kosmos) { Loading @@ -75,7 +79,7 @@ class CommunalTransitionAnimatorControllerTest : SysuiTestCase() { val scene by collectLastValue(communalSceneInteractor.currentScene) communalSceneInteractor.changeScene(CommunalScenes.Communal, "test") Truth.assertThat(scene).isEqualTo(CommunalScenes.Communal) assertThat(scene).isEqualTo(CommunalScenes.Communal) communalSceneInteractor.setIsLaunchingWidget(true) assertTrue(launching!!) Loading @@ -94,6 +98,35 @@ class CommunalTransitionAnimatorControllerTest : SysuiTestCase() { } } @EnableSceneContainer @Test fun animationCancelled_sceneContainerEnabled_launchingWidgetStateIsCleared() { with(kosmos) { testScope.runTest { val launching by collectLastValue(communalSceneInteractor.isLaunchingWidget) val scene by collectLastValue(communalSceneInteractor.currentScene) communalSceneInteractor.changeScene(Scenes.Communal, "test") assertThat(scene).isEqualTo(Scenes.Communal) communalSceneInteractor.setIsLaunchingWidget(true) assertTrue(launching!!) underTest.onIntentStarted(willAnimate = true) assertTrue(launching!!) verify(controller).onIntentStarted(willAnimate = true) underTest.onTransitionAnimationStart(isExpandingFullyAbove = true) assertTrue(launching!!) verify(controller).onTransitionAnimationStart(isExpandingFullyAbove = true) underTest.onTransitionAnimationCancelled(newKeyguardOccludedState = true) assertFalse(launching!!) verify(controller).onTransitionAnimationCancelled(newKeyguardOccludedState = true) } } } @DisableSceneContainer @Test fun animationComplete_launchingWidgetStateIsClearedAndSceneIsChanged() { with(kosmos) { Loading @@ -102,7 +135,38 @@ class CommunalTransitionAnimatorControllerTest : SysuiTestCase() { val scene by collectLastValue(communalSceneInteractor.currentScene) communalSceneInteractor.changeScene(CommunalScenes.Communal, "test") Truth.assertThat(scene).isEqualTo(CommunalScenes.Communal) assertThat(scene).isEqualTo(CommunalScenes.Communal) communalSceneInteractor.setIsLaunchingWidget(true) assertTrue(launching!!) underTest.onIntentStarted(willAnimate = true) assertTrue(launching!!) verify(controller).onIntentStarted(willAnimate = true) underTest.onTransitionAnimationStart(isExpandingFullyAbove = true) assertTrue(launching!!) verify(controller).onTransitionAnimationStart(isExpandingFullyAbove = true) testScope.advanceTimeBy(ActivityTransitionAnimator.TIMINGS.totalDuration) underTest.onTransitionAnimationEnd(isExpandingFullyAbove = true) assertFalse(launching!!) assertThat(scene).isEqualTo(CommunalScenes.Blank) verify(controller).onTransitionAnimationEnd(isExpandingFullyAbove = true) } } } @EnableSceneContainer @Test fun animationComplete_sceneContainerEnabled_launchingWidgetStateIsClearedAndSceneIsChanged() { with(kosmos) { testScope.runTest { val launching by collectLastValue(communalSceneInteractor.isLaunchingWidget) val scene by collectLastValue(communalSceneInteractor.currentScene) communalSceneInteractor.changeScene(Scenes.Communal, "test") assertThat(scene).isEqualTo(Scenes.Communal) communalSceneInteractor.setIsLaunchingWidget(true) assertTrue(launching!!) Loading @@ -118,7 +182,7 @@ class CommunalTransitionAnimatorControllerTest : SysuiTestCase() { underTest.onTransitionAnimationEnd(isExpandingFullyAbove = true) assertFalse(launching!!) Truth.assertThat(scene).isEqualTo(CommunalScenes.Blank) assertThat(scene).isEqualTo(Scenes.Lockscreen) verify(controller).onTransitionAnimationEnd(isExpandingFullyAbove = true) } } Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/DreamingToGlanceableHubTransitionViewModelTest.kt +1 −2 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.ui.data.repository.fakeConfigurationRepository import com.android.systemui.coroutines.collectValues import com.android.systemui.flags.DisableSceneContainer import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.shared.model.KeyguardState Loading @@ -42,6 +41,7 @@ import org.mockito.kotlin.mock import org.mockito.kotlin.whenever @SmallTest @DisableSceneContainer @RunWith(AndroidJUnit4::class) class DreamingToGlanceableHubTransitionViewModelTest : SysuiTestCase() { val kosmos = testKosmos() Loading Loading @@ -97,7 +97,6 @@ class DreamingToGlanceableHubTransitionViewModelTest : SysuiTestCase() { } @Test @DisableSceneContainer fun blurBecomesMaxValueImmediately() = kosmos.runTest { val values by collectValues(underTest.windowBlurRadius) Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalInteractorTest.kt +8 −108 Original line number Diff line number Diff line Loading @@ -42,7 +42,6 @@ import com.android.systemui.communal.data.model.CommunalSmartspaceTimer import com.android.systemui.communal.data.model.SuppressionReason import com.android.systemui.communal.data.repository.fakeCommunalMediaRepository import com.android.systemui.communal.data.repository.fakeCommunalPrefsRepository import com.android.systemui.communal.data.repository.fakeCommunalSceneRepository import com.android.systemui.communal.data.repository.fakeCommunalSmartspaceRepository import com.android.systemui.communal.data.repository.fakeCommunalTutorialRepository import com.android.systemui.communal.data.repository.fakeCommunalWidgetRepository Loading @@ -51,6 +50,7 @@ import com.android.systemui.communal.domain.model.CommunalTransitionProgressMode import com.android.systemui.communal.shared.model.CommunalContentSize import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.communal.shared.model.EditModeState import com.android.systemui.flags.DisableSceneContainer import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.flags.Flags import com.android.systemui.flags.fakeFeatureFlagsClassic Loading Loading @@ -379,29 +379,7 @@ class CommunalInteractorTest(flags: FlagsParameterization) : SysuiTestCase() { assertThat(ctaTileContent).isEmpty() } @Test fun listensToSceneChange() = kosmos.runTest { kosmos.setCommunalAvailable(true) val desiredScene by collectLastValue(underTest.desiredScene) assertThat(desiredScene).isEqualTo(CommunalScenes.Blank) val targetScene = CommunalScenes.Communal fakeCommunalSceneRepository.changeScene(targetScene) assertThat(desiredScene).isEqualTo(targetScene) } @Test fun updatesScene() = kosmos.runTest { val targetScene = CommunalScenes.Communal underTest.changeScene(targetScene, "test") val desiredScene by collectLastValue(fakeCommunalSceneRepository.currentScene) assertThat(desiredScene).isEqualTo(targetScene) } @DisableSceneContainer @Test fun transitionProgress_onTargetScene_fullProgress() = kosmos.runTest { Loading @@ -420,6 +398,7 @@ class CommunalInteractorTest(flags: FlagsParameterization) : SysuiTestCase() { .isEqualTo(CommunalTransitionProgressModel.Idle(targetScene)) } @DisableSceneContainer @Test fun transitionProgress_notOnTargetScene_noProgress() = kosmos.runTest { Loading @@ -439,6 +418,7 @@ class CommunalInteractorTest(flags: FlagsParameterization) : SysuiTestCase() { .isEqualTo(CommunalTransitionProgressModel.Idle(currentScene)) } @DisableSceneContainer @Test fun transitionProgress_transitioningToTrackedScene() = kosmos.runTest { Loading Loading @@ -487,6 +467,7 @@ class CommunalInteractorTest(flags: FlagsParameterization) : SysuiTestCase() { .isEqualTo(CommunalTransitionProgressModel.Idle(targetScene)) } @DisableSceneContainer @Test fun transitionProgress_transitioningAwayFromTrackedScene() = kosmos.runTest { Loading Loading @@ -550,6 +531,7 @@ class CommunalInteractorTest(flags: FlagsParameterization) : SysuiTestCase() { assertThat(isCommunalShowing).isEqualTo(true) } @DisableSceneContainer @Test fun isCommunalShowing_whenSceneContainerDisabled() = kosmos.runTest { Loading @@ -572,8 +554,8 @@ class CommunalInteractorTest(flags: FlagsParameterization) : SysuiTestCase() { assertThat(isCommunalShowing).isFalse() } @Test @EnableSceneContainer @Test fun isCommunalShowing_whenSceneContainerEnabled() = kosmos.runTest { // Verify default is false Loading @@ -589,8 +571,8 @@ class CommunalInteractorTest(flags: FlagsParameterization) : SysuiTestCase() { assertThat(isCommunalShowing).isFalse() } @Test @EnableSceneContainer @Test fun isCommunalShowing_whenSceneContainerEnabledAndChangeToLegacyScene() = kosmos.runTest { // Verify default is false Loading @@ -606,88 +588,6 @@ class CommunalInteractorTest(flags: FlagsParameterization) : SysuiTestCase() { assertThat(isCommunalShowing).isFalse() } @Test fun isIdleOnCommunal() = kosmos.runTest { val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Idle(CommunalScenes.Blank) ) fakeCommunalSceneRepository.setTransitionState(transitionState) // isIdleOnCommunal is false when not on communal. val isIdleOnCommunal by collectLastValue(underTest.isIdleOnCommunal) assertThat(isIdleOnCommunal).isEqualTo(false) // Transition to communal. transitionState.value = ObservableTransitionState.Idle(CommunalScenes.Communal) // isIdleOnCommunal is now true since we're on communal. assertThat(isIdleOnCommunal).isEqualTo(true) // Start transition away from communal. transitionState.value = ObservableTransitionState.Transition( fromScene = CommunalScenes.Communal, toScene = CommunalScenes.Blank, currentScene = flowOf(CommunalScenes.Blank), progress = flowOf(0f), isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), ) // isIdleOnCommunal turns false as soon as transition away starts. assertThat(isIdleOnCommunal).isEqualTo(false) } @Test fun isCommunalVisible() = kosmos.runTest { val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Idle(CommunalScenes.Blank) ) fakeCommunalSceneRepository.setTransitionState(transitionState) // isCommunalVisible is false when not on communal. val isCommunalVisible by collectLastValue(underTest.isCommunalVisible) assertThat(isCommunalVisible).isEqualTo(false) // Start transition to communal. transitionState.value = ObservableTransitionState.Transition( fromScene = CommunalScenes.Blank, toScene = CommunalScenes.Communal, currentScene = flowOf(CommunalScenes.Communal), progress = flowOf(0f), isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), ) // isCommunalVisible is true once transition starts. assertThat(isCommunalVisible).isEqualTo(true) // Finish transition to communal transitionState.value = ObservableTransitionState.Idle(CommunalScenes.Communal) // isCommunalVisible is true since we're on communal. assertThat(isCommunalVisible).isEqualTo(true) // Start transition away from communal. transitionState.value = ObservableTransitionState.Transition( fromScene = CommunalScenes.Communal, toScene = CommunalScenes.Blank, currentScene = flowOf(CommunalScenes.Blank), progress = flowOf(1.0f), isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), ) // isCommunalVisible is still true as the false as soon as transition away runs. assertThat(isCommunalVisible).isEqualTo(true) } @Test fun testShowWidgetEditorStartsActivity() = kosmos.runTest { Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalSceneInteractorTest.kt +20 −22 Original line number Diff line number Diff line Loading @@ -18,12 +18,9 @@ package com.android.systemui.communal.domain.interactor import android.content.res.Configuration.ORIENTATION_LANDSCAPE import android.content.res.Configuration.ORIENTATION_PORTRAIT import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import android.platform.test.flag.junit.FlagsParameterization import androidx.test.filters.SmallTest import com.android.compose.animation.scene.ObservableTransitionState import com.android.systemui.Flags.FLAG_SCENE_CONTAINER import com.android.systemui.SysuiTestCase import com.android.systemui.animation.ActivityTransitionAnimator import com.android.systemui.communal.data.repository.communalSceneRepository Loading @@ -31,9 +28,10 @@ import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor.O import com.android.systemui.communal.domain.model.CommunalTransitionProgressModel import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.DisableSceneContainer import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.flags.andSceneContainer import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.testScope import com.android.systemui.scene.initialSceneKey import com.android.systemui.scene.shared.model.Scenes Loading Loading @@ -82,7 +80,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( private val underTest by lazy { kosmos.communalSceneInteractor } private val keyguardStateController: KeyguardStateController = kosmos.keyguardStateController @DisableFlags(FLAG_SCENE_CONTAINER) @DisableSceneContainer @Test fun changeScene() = testScope.runTest { Loading @@ -93,7 +91,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( assertThat(currentScene).isEqualTo(CommunalScenes.Communal) } @DisableFlags(FLAG_SCENE_CONTAINER) @DisableSceneContainer @Test fun changeScene_callsSceneStateProcessor() = testScope.runTest { Loading @@ -109,7 +107,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( verify(callback).onSceneAboutToChange(CommunalScenes.Communal, null) } @DisableFlags(FLAG_SCENE_CONTAINER) @DisableSceneContainer @Test fun changeScene_doesNotCallSceneStateProcessorForDuplicateState_ifKeyguardStateIsNull() = testScope.runTest { Loading @@ -125,7 +123,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( verify(callback, never()).onSceneAboutToChange(any(), anyOrNull()) } @DisableFlags(FLAG_SCENE_CONTAINER) @DisableSceneContainer @Test fun changeScene_callSceneStateProcessorForDuplicateScene_ifBlankSceneWithKeyguardState() = testScope.runTest { Loading @@ -145,7 +143,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( verify(callback).onSceneAboutToChange(CommunalScenes.Blank, KeyguardState.GONE) } @DisableFlags(FLAG_SCENE_CONTAINER) @DisableSceneContainer @Test fun snapToScene() = testScope.runTest { Loading @@ -156,7 +154,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( assertThat(currentScene).isEqualTo(CommunalScenes.Communal) } @DisableFlags(FLAG_SCENE_CONTAINER) @DisableSceneContainer @Test fun snapToSceneWithDelay() = testScope.runTest { Loading @@ -172,7 +170,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( assertThat(currentScene).isEqualTo(CommunalScenes.Communal) } @DisableFlags(FLAG_SCENE_CONTAINER) @DisableSceneContainer @Test fun transitionProgress_fullProgress() = testScope.runTest { Loading @@ -191,7 +189,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( .isEqualTo(CommunalTransitionProgressModel.Idle(CommunalScenes.Communal)) } @DisableFlags(FLAG_SCENE_CONTAINER) @DisableSceneContainer @Test fun transitionProgress_transitioningAwayFromTrackedScene() = testScope.runTest { Loading Loading @@ -232,7 +230,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( .isEqualTo(CommunalTransitionProgressModel.Idle(CommunalScenes.Communal)) } @DisableFlags(FLAG_SCENE_CONTAINER) @DisableSceneContainer @Test fun transitionProgress_transitioningToTrackedScene() = testScope.runTest { Loading Loading @@ -270,7 +268,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( .isEqualTo(CommunalTransitionProgressModel.Idle(CommunalScenes.Communal)) } @DisableFlags(FLAG_SCENE_CONTAINER) @DisableSceneContainer @Test fun isIdleOnCommunal() = testScope.runTest { Loading Loading @@ -298,7 +296,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( assertThat(isIdleOnCommunal).isEqualTo(false) } @DisableFlags(FLAG_SCENE_CONTAINER) @DisableSceneContainer @Test fun isTransitioningToOrIdleOnCommunal() = testScope.runTest { Loading Loading @@ -340,7 +338,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( assertThat(isTransitioningToOrIdleOnCommunal).isEqualTo(false) } @DisableFlags(FLAG_SCENE_CONTAINER) @DisableSceneContainer @Test fun isCommunalVisible() = testScope.runTest { Loading Loading @@ -381,7 +379,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( assertThat(isCommunalVisible).isEqualTo(true) } @EnableFlags(FLAG_SCENE_CONTAINER) @EnableSceneContainer @Test fun changeScene_legacyCommunalScene_mapToStfScene() = testScope.runTest { Loading @@ -403,7 +401,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( assertThat(currentScene).isEqualTo(Scenes.Lockscreen) } @EnableFlags(FLAG_SCENE_CONTAINER) @EnableSceneContainer @Test fun changeScene_stfScenes() = testScope.runTest { Loading @@ -425,7 +423,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( assertThat(currentScene).isEqualTo(Scenes.Lockscreen) } @EnableFlags(FLAG_SCENE_CONTAINER) @EnableSceneContainer @Test fun snapToScene_legacyCommunalScene_mapToStfScene() = testScope.runTest { Loading @@ -447,7 +445,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( assertThat(currentScene).isEqualTo(Scenes.Lockscreen) } @EnableFlags(FLAG_SCENE_CONTAINER) @EnableSceneContainer @Test fun snapToScene_stfScenes() = testScope.runTest { Loading @@ -469,7 +467,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( assertThat(currentScene).isEqualTo(Scenes.Lockscreen) } @EnableFlags(FLAG_SCENE_CONTAINER) @EnableSceneContainer @Test fun isIdleOnCommunal_sceneContainerEnabled() = testScope.runTest { Loading Loading @@ -514,7 +512,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase( assertThat(isIdleOnCommunal).isEqualTo(false) } @EnableFlags(FLAG_SCENE_CONTAINER) @EnableSceneContainer @Test fun isCommunalVisible_sceneContainerEnabled() = testScope.runTest { Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/WidgetTrampolineInteractorTest.kt +34 −12 Original line number Diff line number Diff line Loading @@ -19,11 +19,13 @@ package com.android.systemui.communal.domain.interactor import android.app.ActivityManager.RunningTaskInfo import android.app.usage.UsageEvents import android.content.pm.UserInfo import android.platform.test.flag.junit.FlagsParameterization import android.service.dream.dreamManager import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.usagestats.data.repository.fakeUsageStatsRepository import com.android.systemui.flags.DisableSceneContainer import com.android.systemui.flags.andSceneContainer import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.shared.model.TransitionState Loading Loading @@ -54,22 +56,24 @@ import org.mockito.kotlin.mock import org.mockito.kotlin.never import org.mockito.kotlin.times import org.mockito.kotlin.verify import platform.test.runner.parameterized.ParameterizedAndroidJunit4 import platform.test.runner.parameterized.Parameters @SmallTest @RunWith(AndroidJUnit4::class) class WidgetTrampolineInteractorTest : SysuiTestCase() { @RunWith(ParameterizedAndroidJunit4::class) class WidgetTrampolineInteractorTest(flags: FlagsParameterization) : SysuiTestCase() { private val kosmos = testKosmos() private val testScope = kosmos.testScope private val activityStarter = kosmos.activityStarter private val usageStatsRepository = kosmos.fakeUsageStatsRepository private val taskStackChangeListeners = kosmos.taskStackChangeListeners private val keyguardTransitionRepository = kosmos.fakeKeyguardTransitionRepository private val userTracker = kosmos.fakeUserTracker private val systemClock = kosmos.fakeSystemClock private val activityStarter by lazy { kosmos.activityStarter } private val usageStatsRepository by lazy { kosmos.fakeUsageStatsRepository } private val taskStackChangeListeners by lazy { kosmos.taskStackChangeListeners } private val keyguardTransitionRepository by lazy { kosmos.fakeKeyguardTransitionRepository } private val userTracker by lazy { kosmos.fakeUserTracker } private val systemClock by lazy { kosmos.fakeSystemClock } private val underTest = kosmos.widgetTrampolineInteractor private val underTest by lazy { kosmos.widgetTrampolineInteractor } @Before fun setUp() { Loading @@ -77,6 +81,7 @@ class WidgetTrampolineInteractorTest : SysuiTestCase() { systemClock.setCurrentTimeMillis(testScope.currentTime) } @DisableSceneContainer @Test fun testNewTaskStartsWhileOnHub_triggersUnlock() = testScope.runTest { Loading @@ -90,6 +95,7 @@ class WidgetTrampolineInteractorTest : SysuiTestCase() { verify(activityStarter).dismissKeyguardThenExecute(any(), anyOrNull(), any()) } @DisableSceneContainer @Test fun testNewTaskStartsWhileOnHub_stopsDream() = testScope.runTest { Loading @@ -111,6 +117,7 @@ class WidgetTrampolineInteractorTest : SysuiTestCase() { } } @DisableSceneContainer @Test fun testNewTaskStartsAfterExitingHub_doesNotTriggerUnlock() = testScope.runTest { Loading @@ -124,6 +131,7 @@ class WidgetTrampolineInteractorTest : SysuiTestCase() { verify(activityStarter, never()).dismissKeyguardThenExecute(any(), anyOrNull(), any()) } @DisableSceneContainer @Test fun testNewTaskStartsAfterTimeout_doesNotTriggerUnlock() = testScope.runTest { Loading @@ -137,6 +145,7 @@ class WidgetTrampolineInteractorTest : SysuiTestCase() { verify(activityStarter, never()).dismissKeyguardThenExecute(any(), anyOrNull(), any()) } @DisableSceneContainer @Test fun testActivityResumedWhileOnHub_triggersUnlock() = testScope.runTest { Loading @@ -150,6 +159,7 @@ class WidgetTrampolineInteractorTest : SysuiTestCase() { verify(activityStarter).dismissKeyguardThenExecute(any(), anyOrNull(), any()) } @DisableSceneContainer @Test fun testActivityResumedAfterExitingHub_doesNotTriggerUnlock() = testScope.runTest { Loading @@ -164,6 +174,7 @@ class WidgetTrampolineInteractorTest : SysuiTestCase() { verify(activityStarter, never()).dismissKeyguardThenExecute(any(), anyOrNull(), any()) } @DisableSceneContainer @Test fun testActivityDestroyed_doesNotTriggerUnlock() = testScope.runTest { Loading @@ -177,6 +188,7 @@ class WidgetTrampolineInteractorTest : SysuiTestCase() { verify(activityStarter, never()).dismissKeyguardThenExecute(any(), anyOrNull(), any()) } @DisableSceneContainer @Test fun testMultipleActivityEvents_triggersUnlockOnlyOnce() = testScope.runTest { Loading Loading @@ -236,7 +248,17 @@ class WidgetTrampolineInteractorTest : SysuiTestCase() { runCurrent() } private companion object { val MAIN_USER: UserInfo = UserInfo(0, "primary", UserInfo.FLAG_MAIN) init { mSetFlagsRule.setFlagsParameterization(flags) } companion object { private val MAIN_USER: UserInfo = UserInfo(0, "primary", UserInfo.FLAG_MAIN) @JvmStatic @Parameters(name = "{0}") fun getParams(): List<FlagsParameterization> { return FlagsParameterization.allCombinationsOf().andSceneContainer() } } }
packages/SystemUI/multivalentTests/src/com/android/systemui/communal/widgets/CommunalTransitionAnimatorControllerTest.kt +68 −4 Original line number Diff line number Diff line Loading @@ -23,9 +23,12 @@ import com.android.systemui.animation.ActivityTransitionAnimator import com.android.systemui.communal.domain.interactor.communalSceneInteractor import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.DisableSceneContainer import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.kosmos.testScope import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.testKosmos import com.google.common.truth.Truth import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.advanceTimeBy import kotlinx.coroutines.test.runTest import org.junit.Assert.assertFalse Loading Loading @@ -67,6 +70,7 @@ class CommunalTransitionAnimatorControllerTest : SysuiTestCase() { } } @DisableSceneContainer @Test fun animationCancelled_launchingWidgetStateIsCleared() { with(kosmos) { Loading @@ -75,7 +79,7 @@ class CommunalTransitionAnimatorControllerTest : SysuiTestCase() { val scene by collectLastValue(communalSceneInteractor.currentScene) communalSceneInteractor.changeScene(CommunalScenes.Communal, "test") Truth.assertThat(scene).isEqualTo(CommunalScenes.Communal) assertThat(scene).isEqualTo(CommunalScenes.Communal) communalSceneInteractor.setIsLaunchingWidget(true) assertTrue(launching!!) Loading @@ -94,6 +98,35 @@ class CommunalTransitionAnimatorControllerTest : SysuiTestCase() { } } @EnableSceneContainer @Test fun animationCancelled_sceneContainerEnabled_launchingWidgetStateIsCleared() { with(kosmos) { testScope.runTest { val launching by collectLastValue(communalSceneInteractor.isLaunchingWidget) val scene by collectLastValue(communalSceneInteractor.currentScene) communalSceneInteractor.changeScene(Scenes.Communal, "test") assertThat(scene).isEqualTo(Scenes.Communal) communalSceneInteractor.setIsLaunchingWidget(true) assertTrue(launching!!) underTest.onIntentStarted(willAnimate = true) assertTrue(launching!!) verify(controller).onIntentStarted(willAnimate = true) underTest.onTransitionAnimationStart(isExpandingFullyAbove = true) assertTrue(launching!!) verify(controller).onTransitionAnimationStart(isExpandingFullyAbove = true) underTest.onTransitionAnimationCancelled(newKeyguardOccludedState = true) assertFalse(launching!!) verify(controller).onTransitionAnimationCancelled(newKeyguardOccludedState = true) } } } @DisableSceneContainer @Test fun animationComplete_launchingWidgetStateIsClearedAndSceneIsChanged() { with(kosmos) { Loading @@ -102,7 +135,38 @@ class CommunalTransitionAnimatorControllerTest : SysuiTestCase() { val scene by collectLastValue(communalSceneInteractor.currentScene) communalSceneInteractor.changeScene(CommunalScenes.Communal, "test") Truth.assertThat(scene).isEqualTo(CommunalScenes.Communal) assertThat(scene).isEqualTo(CommunalScenes.Communal) communalSceneInteractor.setIsLaunchingWidget(true) assertTrue(launching!!) underTest.onIntentStarted(willAnimate = true) assertTrue(launching!!) verify(controller).onIntentStarted(willAnimate = true) underTest.onTransitionAnimationStart(isExpandingFullyAbove = true) assertTrue(launching!!) verify(controller).onTransitionAnimationStart(isExpandingFullyAbove = true) testScope.advanceTimeBy(ActivityTransitionAnimator.TIMINGS.totalDuration) underTest.onTransitionAnimationEnd(isExpandingFullyAbove = true) assertFalse(launching!!) assertThat(scene).isEqualTo(CommunalScenes.Blank) verify(controller).onTransitionAnimationEnd(isExpandingFullyAbove = true) } } } @EnableSceneContainer @Test fun animationComplete_sceneContainerEnabled_launchingWidgetStateIsClearedAndSceneIsChanged() { with(kosmos) { testScope.runTest { val launching by collectLastValue(communalSceneInteractor.isLaunchingWidget) val scene by collectLastValue(communalSceneInteractor.currentScene) communalSceneInteractor.changeScene(Scenes.Communal, "test") assertThat(scene).isEqualTo(Scenes.Communal) communalSceneInteractor.setIsLaunchingWidget(true) assertTrue(launching!!) Loading @@ -118,7 +182,7 @@ class CommunalTransitionAnimatorControllerTest : SysuiTestCase() { underTest.onTransitionAnimationEnd(isExpandingFullyAbove = true) assertFalse(launching!!) Truth.assertThat(scene).isEqualTo(CommunalScenes.Blank) assertThat(scene).isEqualTo(Scenes.Lockscreen) verify(controller).onTransitionAnimationEnd(isExpandingFullyAbove = true) } } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/DreamingToGlanceableHubTransitionViewModelTest.kt +1 −2 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.ui.data.repository.fakeConfigurationRepository import com.android.systemui.coroutines.collectValues import com.android.systemui.flags.DisableSceneContainer import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.shared.model.KeyguardState Loading @@ -42,6 +41,7 @@ import org.mockito.kotlin.mock import org.mockito.kotlin.whenever @SmallTest @DisableSceneContainer @RunWith(AndroidJUnit4::class) class DreamingToGlanceableHubTransitionViewModelTest : SysuiTestCase() { val kosmos = testKosmos() Loading Loading @@ -97,7 +97,6 @@ class DreamingToGlanceableHubTransitionViewModelTest : SysuiTestCase() { } @Test @DisableSceneContainer fun blurBecomesMaxValueImmediately() = kosmos.runTest { val values by collectValues(underTest.windowBlurRadius) Loading