Loading packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeInteractorSceneContainerImplTest.kt +79 −4 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import com.android.systemui.shade.shadeTestUtil import com.android.systemui.shade.shared.model.ShadeMode import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.TestScope Loading @@ -43,6 +44,7 @@ import kotlinx.coroutines.test.runTest import org.junit.Test import org.junit.runner.RunWith @OptIn(ExperimentalCoroutinesApi::class) @SmallTest @RunWith(AndroidJUnit4::class) @EnableSceneContainer Loading Loading @@ -114,7 +116,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { } @Test fun qsFullscreen_falseWhenTransitioning() = fun qsFullscreen_singleShade_falseWhenTransitioning() = testScope.runTest { val actual by collectLastValue(underTest.isQsFullscreen) Loading @@ -139,7 +141,36 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { } @Test fun qsFullscreen_falseWhenIdleNotQS() = fun qsFullscreen_dualShade_falseWhenTransitioning() = testScope.runTest { kosmos.enableDualShade(wideLayout = false) val actual by collectLastValue(underTest.isQsFullscreen) // WHEN overlay transition active keyguardRepository.setStatusBarState(StatusBarState.SHADE) sceneInteractor.setTransitionState( MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Transition.ReplaceOverlay( fromOverlay = Overlays.QuickSettingsShade, toOverlay = Overlays.NotificationsShade, currentScene = Scenes.Gone, currentOverlays = flowOf(setOf(Overlays.QuickSettingsShade)), progress = MutableStateFlow(.3f), isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), previewProgress = flowOf(0f), isInPreviewStage = flowOf(false), ) ) ) runCurrent() // THEN QS is not fullscreen assertThat(actual).isFalse() } @Test fun qsFullscreen_falseWhenIdleNotQs() = testScope.runTest { val actual by collectLastValue(underTest.isQsFullscreen) Loading @@ -157,7 +188,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { } @Test fun qsFullscreen_falseWhenIdleSplitShadeQs() = fun qsFullscreen_splitShade_falseWhenIdleQs() = testScope.runTest { val actual by collectLastValue(underTest.isQsFullscreen) Loading @@ -176,7 +207,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { } @Test fun qsFullscreen_trueWhenIdleQS() = fun qsFullscreen_singleShade_trueWhenIdleQs() = testScope.runTest { val actual by collectLastValue(underTest.isQsFullscreen) Loading @@ -193,6 +224,50 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { assertThat(actual).isTrue() } @Test fun qsFullscreen_dualShade_trueWhenIdleQs() = testScope.runTest { kosmos.enableDualShade(wideLayout = false) val actual by collectLastValue(underTest.isQsFullscreen) // WHEN Idle on QuickSettingsShade overlay keyguardRepository.setStatusBarState(StatusBarState.SHADE) sceneInteractor.setTransitionState( MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Idle( currentScene = Scenes.Gone, currentOverlays = setOf(Overlays.QuickSettingsShade), ) ) ) runCurrent() // THEN QS is fullscreen assertThat(actual).isTrue() } @Test fun qsFullscreen_dualShadeWide_falseWhenIdleQs() = testScope.runTest { kosmos.enableDualShade(wideLayout = true) val actual by collectLastValue(underTest.isQsFullscreen) // WHEN Idle on QuickSettingsShade overlay keyguardRepository.setStatusBarState(StatusBarState.SHADE) sceneInteractor.setTransitionState( MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Idle( currentScene = Scenes.Gone, currentOverlays = setOf(Overlays.QuickSettingsShade), ) ) ) runCurrent() // THEN QS is fullscreen assertThat(actual).isFalse() } @Test fun lockscreenShadeExpansion_idle_onScene() = testScope.runTest { Loading packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractorSceneContainerImpl.kt +26 −11 Original line number Diff line number Diff line Loading @@ -95,18 +95,16 @@ constructor( shadeModeInteractor.shadeMode .flatMapLatest { shadeMode -> when (shadeMode) { ShadeMode.Single -> sceneInteractor.transitionState .map { state -> when (state) { is ObservableTransitionState.Idle -> state.currentScene == Scenes.QuickSettings is ObservableTransitionState.Transition -> false ShadeMode.Single -> Scenes.QuickSettings.isShownAndIdle ShadeMode.Split -> flowOf(false) ShadeMode.Dual -> shadeModeInteractor.isShadeLayoutWide.flatMapLatest { isShadeLayoutWide -> if (isShadeLayoutWide) { flowOf(false) } else { Overlays.QuickSettingsShade.isShownAndIdle } } .distinctUntilChanged() ShadeMode.Split, ShadeMode.Dual -> flowOf(false) } } .distinctUntilChanged() Loading Loading @@ -368,6 +366,23 @@ constructor( } .distinctUntilChanged() /** Whether this content key is currently shown and in idle transition state. */ private val ContentKey.isShownAndIdle: Flow<Boolean> get() { return sceneInteractor.transitionState .map { state -> when (state) { is ObservableTransitionState.Idle -> when (this) { is SceneKey -> this == state.currentScene is OverlayKey -> this in state.currentOverlays } is ObservableTransitionState.Transition -> false } } .distinctUntilChanged() } private val ShadeMode.notificationsContentKey: ContentKey get() { return when (this) { Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeInteractorSceneContainerImplTest.kt +79 −4 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import com.android.systemui.shade.shadeTestUtil import com.android.systemui.shade.shared.model.ShadeMode import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.TestScope Loading @@ -43,6 +44,7 @@ import kotlinx.coroutines.test.runTest import org.junit.Test import org.junit.runner.RunWith @OptIn(ExperimentalCoroutinesApi::class) @SmallTest @RunWith(AndroidJUnit4::class) @EnableSceneContainer Loading Loading @@ -114,7 +116,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { } @Test fun qsFullscreen_falseWhenTransitioning() = fun qsFullscreen_singleShade_falseWhenTransitioning() = testScope.runTest { val actual by collectLastValue(underTest.isQsFullscreen) Loading @@ -139,7 +141,36 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { } @Test fun qsFullscreen_falseWhenIdleNotQS() = fun qsFullscreen_dualShade_falseWhenTransitioning() = testScope.runTest { kosmos.enableDualShade(wideLayout = false) val actual by collectLastValue(underTest.isQsFullscreen) // WHEN overlay transition active keyguardRepository.setStatusBarState(StatusBarState.SHADE) sceneInteractor.setTransitionState( MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Transition.ReplaceOverlay( fromOverlay = Overlays.QuickSettingsShade, toOverlay = Overlays.NotificationsShade, currentScene = Scenes.Gone, currentOverlays = flowOf(setOf(Overlays.QuickSettingsShade)), progress = MutableStateFlow(.3f), isInitiatedByUserInput = false, isUserInputOngoing = flowOf(false), previewProgress = flowOf(0f), isInPreviewStage = flowOf(false), ) ) ) runCurrent() // THEN QS is not fullscreen assertThat(actual).isFalse() } @Test fun qsFullscreen_falseWhenIdleNotQs() = testScope.runTest { val actual by collectLastValue(underTest.isQsFullscreen) Loading @@ -157,7 +188,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { } @Test fun qsFullscreen_falseWhenIdleSplitShadeQs() = fun qsFullscreen_splitShade_falseWhenIdleQs() = testScope.runTest { val actual by collectLastValue(underTest.isQsFullscreen) Loading @@ -176,7 +207,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { } @Test fun qsFullscreen_trueWhenIdleQS() = fun qsFullscreen_singleShade_trueWhenIdleQs() = testScope.runTest { val actual by collectLastValue(underTest.isQsFullscreen) Loading @@ -193,6 +224,50 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { assertThat(actual).isTrue() } @Test fun qsFullscreen_dualShade_trueWhenIdleQs() = testScope.runTest { kosmos.enableDualShade(wideLayout = false) val actual by collectLastValue(underTest.isQsFullscreen) // WHEN Idle on QuickSettingsShade overlay keyguardRepository.setStatusBarState(StatusBarState.SHADE) sceneInteractor.setTransitionState( MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Idle( currentScene = Scenes.Gone, currentOverlays = setOf(Overlays.QuickSettingsShade), ) ) ) runCurrent() // THEN QS is fullscreen assertThat(actual).isTrue() } @Test fun qsFullscreen_dualShadeWide_falseWhenIdleQs() = testScope.runTest { kosmos.enableDualShade(wideLayout = true) val actual by collectLastValue(underTest.isQsFullscreen) // WHEN Idle on QuickSettingsShade overlay keyguardRepository.setStatusBarState(StatusBarState.SHADE) sceneInteractor.setTransitionState( MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Idle( currentScene = Scenes.Gone, currentOverlays = setOf(Overlays.QuickSettingsShade), ) ) ) runCurrent() // THEN QS is fullscreen assertThat(actual).isFalse() } @Test fun lockscreenShadeExpansion_idle_onScene() = testScope.runTest { Loading
packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractorSceneContainerImpl.kt +26 −11 Original line number Diff line number Diff line Loading @@ -95,18 +95,16 @@ constructor( shadeModeInteractor.shadeMode .flatMapLatest { shadeMode -> when (shadeMode) { ShadeMode.Single -> sceneInteractor.transitionState .map { state -> when (state) { is ObservableTransitionState.Idle -> state.currentScene == Scenes.QuickSettings is ObservableTransitionState.Transition -> false ShadeMode.Single -> Scenes.QuickSettings.isShownAndIdle ShadeMode.Split -> flowOf(false) ShadeMode.Dual -> shadeModeInteractor.isShadeLayoutWide.flatMapLatest { isShadeLayoutWide -> if (isShadeLayoutWide) { flowOf(false) } else { Overlays.QuickSettingsShade.isShownAndIdle } } .distinctUntilChanged() ShadeMode.Split, ShadeMode.Dual -> flowOf(false) } } .distinctUntilChanged() Loading Loading @@ -368,6 +366,23 @@ constructor( } .distinctUntilChanged() /** Whether this content key is currently shown and in idle transition state. */ private val ContentKey.isShownAndIdle: Flow<Boolean> get() { return sceneInteractor.transitionState .map { state -> when (state) { is ObservableTransitionState.Idle -> when (this) { is SceneKey -> this == state.currentScene is OverlayKey -> this in state.currentOverlays } is ObservableTransitionState.Transition -> false } } .distinctUntilChanged() } private val ShadeMode.notificationsContentKey: ContentKey get() { return when (this) { Loading