Loading packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneTransitionLayoutDataSource.kt +6 −12 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import com.android.compose.animation.scene.TransitionKey import com.android.compose.animation.scene.observableTransitionState import com.android.systemui.scene.shared.model.SceneDataSource import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.flatMapLatest Loading @@ -32,6 +33,7 @@ import kotlinx.coroutines.flow.stateIn /** * An implementation of [SceneDataSource] that's backed by a [MutableSceneTransitionLayoutState]. */ @OptIn(ExperimentalCoroutinesApi::class) class SceneTransitionLayoutDataSource( private val state: MutableSceneTransitionLayoutState, Loading Loading @@ -67,10 +69,6 @@ class SceneTransitionLayoutDataSource( ) } override fun snapToScene(toScene: SceneKey) { state.snapTo(scene = toScene) } override fun showOverlay(overlay: OverlayKey, transitionKey: TransitionKey?) { state.showOverlay( overlay = overlay, Loading @@ -96,15 +94,11 @@ class SceneTransitionLayoutDataSource( ) } override fun instantlyShowOverlay(overlay: OverlayKey) { state.snapTo(overlays = state.currentOverlays + overlay) } override fun instantlyHideOverlay(overlay: OverlayKey) { state.snapTo(overlays = state.currentOverlays - overlay) } override fun freezeAndAnimateToCurrentState() { state.currentTransition?.freezeAndAnimateToCurrentState() } override fun instantlyTransitionTo(scene: SceneKey, overlays: Set<OverlayKey>) { state.snapTo(scene = scene, overlays = overlays) } } packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/FromDozingTransitionInteractorTest.kt +15 −6 Original line number Diff line number Diff line Loading @@ -44,8 +44,6 @@ import com.android.systemui.keyguard.shared.model.BiometricUnlockMode import com.android.systemui.keyguard.shared.model.DozeStateModel import com.android.systemui.keyguard.shared.model.DozeTransitionModel import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.shared.model.KeyguardState.GONE import com.android.systemui.keyguard.shared.model.KeyguardState.LOCKSCREEN import com.android.systemui.keyguard.shared.model.TransitionState import com.android.systemui.keyguard.util.KeyguardTransitionRepositorySpySubject.Companion.assertThat import com.android.systemui.kosmos.Kosmos Loading @@ -63,6 +61,7 @@ import com.android.systemui.testKosmos import com.google.common.truth.Truth import junit.framework.Assert.assertEquals import kotlin.time.Duration.Companion.milliseconds import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.advanceTimeBy Loading @@ -78,6 +77,7 @@ import org.mockito.kotlin.whenever import platform.test.runner.parameterized.ParameterizedAndroidJunit4 import platform.test.runner.parameterized.Parameters @OptIn(ExperimentalCoroutinesApi::class) @SmallTest @RunWith(ParameterizedAndroidJunit4::class) @EnableFlags(FLAG_COMMUNAL_HUB) Loading Loading @@ -166,7 +166,8 @@ class FromDozingTransitionInteractorTest(flags: FlagsParameterization?) : SysuiT // If dreaming is possible and communal is available, then we should transition to // GLANCEABLE_HUB when waking up due to power button press. verify(fakeCommunalSceneRepository).snapToScene(CommunalScenes.Communal) verify(fakeCommunalSceneRepository) .instantlyTransitionTo(CommunalScenes.Communal, emptySet()) } @Test Loading Loading @@ -321,7 +322,9 @@ class FromDozingTransitionInteractorTest(flags: FlagsParameterization?) : SysuiT fun testTransitionToGone_onWakeUp_ifPowerButtonGestureDetected_fromGone() = kosmos.runTest { val isGone by collectLastValue(keyguardTransitionInteractor.isFinishedIn(Scenes.Gone, GONE)) collectLastValue( keyguardTransitionInteractor.isFinishedIn(Scenes.Gone, KeyguardState.GONE) ) powerInteractor.setAwakeForTest() transitionRepository.sendTransitionSteps( from = KeyguardState.DOZING, Loading Loading @@ -361,7 +364,10 @@ class FromDozingTransitionInteractorTest(flags: FlagsParameterization?) : SysuiT kosmos.runTest { val isGone by collectLastValue( kosmos.keyguardTransitionInteractor.isFinishedIn(Scenes.Gone, GONE) kosmos.keyguardTransitionInteractor.isFinishedIn( Scenes.Gone, KeyguardState.GONE, ) ) powerInteractor.setAwakeForTest() transitionRepository.sendTransitionSteps( Loading Loading @@ -398,7 +404,10 @@ class FromDozingTransitionInteractorTest(flags: FlagsParameterization?) : SysuiT kosmos.runTest { val isLockscreen by collectLastValue( kosmos.keyguardTransitionInteractor.isFinishedIn(Scenes.Lockscreen, LOCKSCREEN) kosmos.keyguardTransitionInteractor.isFinishedIn( Scenes.Lockscreen, KeyguardState.LOCKSCREEN, ) ) powerInteractor.setAwakeForTest() transitionRepository.sendTransitionSteps( Loading packages/SystemUI/multivalentTests/src/com/android/systemui/scene/data/repository/SceneContainerRepositoryTest.kt +3 −3 Original line number Diff line number Diff line Loading @@ -59,7 +59,7 @@ class SceneContainerRepositoryTest : SysuiTestCase() { underTest.changeScene(Scenes.Shade) assertThat(currentScene).isEqualTo(Scenes.Shade) underTest.snapToScene(Scenes.QuickSettings) underTest.instantlyTransitionTo(Scenes.QuickSettings) assertThat(currentScene).isEqualTo(Scenes.QuickSettings) } Loading @@ -83,10 +83,10 @@ class SceneContainerRepositoryTest : SysuiTestCase() { } @Test(expected = IllegalStateException::class) fun snapToScene_noSuchSceneInContainer_throws() { fun instantlyTransitionTo_noSuchSceneInContainer_throws() { kosmos.sceneKeys = listOf(Scenes.QuickSettings, Scenes.Lockscreen) val underTest = kosmos.sceneContainerRepository underTest.snapToScene(Scenes.Shade) underTest.instantlyTransitionTo(Scenes.Shade) } @Test Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewControllerTest.kt +7 −5 Original line number Diff line number Diff line Loading @@ -72,6 +72,7 @@ import com.android.systemui.util.settings.SecureSettings import com.android.systemui.util.time.FakeSystemClock import com.google.common.truth.Truth import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest Loading @@ -87,6 +88,7 @@ import org.mockito.Mockito import org.mockito.MockitoAnnotations import org.mockito.kotlin.whenever @OptIn(ExperimentalCoroutinesApi::class) @SmallTest @RunWith(AndroidJUnit4::class) @RunWithLooper(setAsMainLooper = true) Loading Loading @@ -802,10 +804,10 @@ class KeyguardStatusBarViewControllerTest : SysuiTestCase() { looper.processAllMessages() updateStateToKeyguard() kosmos.fakeCommunalSceneRepository.snapToScene(CommunalScenes.Communal) kosmos.fakeCommunalSceneRepository.instantlyTransitionTo(CommunalScenes.Communal) runCurrent() controller.updateCommunalAlphaTransition(transitionAlphaAmount) assertThat(keyguardStatusBarView.getAlpha()).isEqualTo(transitionAlphaAmount) assertThat(keyguardStatusBarView.alpha).isEqualTo(transitionAlphaAmount) } finally { ViewUtils.detachView(keyguardStatusBarView) } Loading @@ -822,12 +824,12 @@ class KeyguardStatusBarViewControllerTest : SysuiTestCase() { looper.processAllMessages() updateStateToKeyguard() kosmos.fakeCommunalSceneRepository.snapToScene(CommunalScenes.Communal) kosmos.fakeCommunalSceneRepository.instantlyTransitionTo(CommunalScenes.Communal) runCurrent() controller.updateCommunalAlphaTransition(transitionAlphaAmount) kosmos.fakeCommunalSceneRepository.snapToScene(CommunalScenes.Blank) kosmos.fakeCommunalSceneRepository.instantlyTransitionTo(CommunalScenes.Blank) runCurrent() assertThat(keyguardStatusBarView.getAlpha()).isNotEqualTo(transitionAlphaAmount) assertThat(keyguardStatusBarView.alpha).isNotEqualTo(transitionAlphaAmount) } finally { ViewUtils.detachView(keyguardStatusBarView) } Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/ShadeTouchableRegionManagerTest.kt +4 −2 Original line number Diff line number Diff line Loading @@ -31,12 +31,14 @@ import com.android.systemui.testKosmos import com.android.systemui.util.kotlin.getValue import com.google.common.truth.Truth.assertThat import dagger.Lazy import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.Test import org.junit.runner.RunWith @OptIn(ExperimentalCoroutinesApi::class) @SmallTest @RunWith(AndroidJUnit4::class) class ShadeTouchableRegionManagerTest : SysuiTestCase() { Loading Loading @@ -120,12 +122,12 @@ class ShadeTouchableRegionManagerTest : SysuiTestCase() { testScope.runTest { assertThat(underTest.shouldMakeEntireScreenTouchable()).isFalse() kosmos.fakeCommunalSceneRepository.snapToScene(CommunalScenes.Communal) kosmos.fakeCommunalSceneRepository.instantlyTransitionTo(CommunalScenes.Communal) runCurrent() assertThat(underTest.shouldMakeEntireScreenTouchable()).isTrue() kosmos.fakeCommunalSceneRepository.snapToScene(CommunalScenes.Blank) kosmos.fakeCommunalSceneRepository.instantlyTransitionTo(CommunalScenes.Blank) runCurrent() assertThat(underTest.shouldMakeEntireScreenTouchable()).isFalse() Loading Loading
packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneTransitionLayoutDataSource.kt +6 −12 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import com.android.compose.animation.scene.TransitionKey import com.android.compose.animation.scene.observableTransitionState import com.android.systemui.scene.shared.model.SceneDataSource import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.flatMapLatest Loading @@ -32,6 +33,7 @@ import kotlinx.coroutines.flow.stateIn /** * An implementation of [SceneDataSource] that's backed by a [MutableSceneTransitionLayoutState]. */ @OptIn(ExperimentalCoroutinesApi::class) class SceneTransitionLayoutDataSource( private val state: MutableSceneTransitionLayoutState, Loading Loading @@ -67,10 +69,6 @@ class SceneTransitionLayoutDataSource( ) } override fun snapToScene(toScene: SceneKey) { state.snapTo(scene = toScene) } override fun showOverlay(overlay: OverlayKey, transitionKey: TransitionKey?) { state.showOverlay( overlay = overlay, Loading @@ -96,15 +94,11 @@ class SceneTransitionLayoutDataSource( ) } override fun instantlyShowOverlay(overlay: OverlayKey) { state.snapTo(overlays = state.currentOverlays + overlay) } override fun instantlyHideOverlay(overlay: OverlayKey) { state.snapTo(overlays = state.currentOverlays - overlay) } override fun freezeAndAnimateToCurrentState() { state.currentTransition?.freezeAndAnimateToCurrentState() } override fun instantlyTransitionTo(scene: SceneKey, overlays: Set<OverlayKey>) { state.snapTo(scene = scene, overlays = overlays) } }
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/FromDozingTransitionInteractorTest.kt +15 −6 Original line number Diff line number Diff line Loading @@ -44,8 +44,6 @@ import com.android.systemui.keyguard.shared.model.BiometricUnlockMode import com.android.systemui.keyguard.shared.model.DozeStateModel import com.android.systemui.keyguard.shared.model.DozeTransitionModel import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.shared.model.KeyguardState.GONE import com.android.systemui.keyguard.shared.model.KeyguardState.LOCKSCREEN import com.android.systemui.keyguard.shared.model.TransitionState import com.android.systemui.keyguard.util.KeyguardTransitionRepositorySpySubject.Companion.assertThat import com.android.systemui.kosmos.Kosmos Loading @@ -63,6 +61,7 @@ import com.android.systemui.testKosmos import com.google.common.truth.Truth import junit.framework.Assert.assertEquals import kotlin.time.Duration.Companion.milliseconds import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.advanceTimeBy Loading @@ -78,6 +77,7 @@ import org.mockito.kotlin.whenever import platform.test.runner.parameterized.ParameterizedAndroidJunit4 import platform.test.runner.parameterized.Parameters @OptIn(ExperimentalCoroutinesApi::class) @SmallTest @RunWith(ParameterizedAndroidJunit4::class) @EnableFlags(FLAG_COMMUNAL_HUB) Loading Loading @@ -166,7 +166,8 @@ class FromDozingTransitionInteractorTest(flags: FlagsParameterization?) : SysuiT // If dreaming is possible and communal is available, then we should transition to // GLANCEABLE_HUB when waking up due to power button press. verify(fakeCommunalSceneRepository).snapToScene(CommunalScenes.Communal) verify(fakeCommunalSceneRepository) .instantlyTransitionTo(CommunalScenes.Communal, emptySet()) } @Test Loading Loading @@ -321,7 +322,9 @@ class FromDozingTransitionInteractorTest(flags: FlagsParameterization?) : SysuiT fun testTransitionToGone_onWakeUp_ifPowerButtonGestureDetected_fromGone() = kosmos.runTest { val isGone by collectLastValue(keyguardTransitionInteractor.isFinishedIn(Scenes.Gone, GONE)) collectLastValue( keyguardTransitionInteractor.isFinishedIn(Scenes.Gone, KeyguardState.GONE) ) powerInteractor.setAwakeForTest() transitionRepository.sendTransitionSteps( from = KeyguardState.DOZING, Loading Loading @@ -361,7 +364,10 @@ class FromDozingTransitionInteractorTest(flags: FlagsParameterization?) : SysuiT kosmos.runTest { val isGone by collectLastValue( kosmos.keyguardTransitionInteractor.isFinishedIn(Scenes.Gone, GONE) kosmos.keyguardTransitionInteractor.isFinishedIn( Scenes.Gone, KeyguardState.GONE, ) ) powerInteractor.setAwakeForTest() transitionRepository.sendTransitionSteps( Loading Loading @@ -398,7 +404,10 @@ class FromDozingTransitionInteractorTest(flags: FlagsParameterization?) : SysuiT kosmos.runTest { val isLockscreen by collectLastValue( kosmos.keyguardTransitionInteractor.isFinishedIn(Scenes.Lockscreen, LOCKSCREEN) kosmos.keyguardTransitionInteractor.isFinishedIn( Scenes.Lockscreen, KeyguardState.LOCKSCREEN, ) ) powerInteractor.setAwakeForTest() transitionRepository.sendTransitionSteps( Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/scene/data/repository/SceneContainerRepositoryTest.kt +3 −3 Original line number Diff line number Diff line Loading @@ -59,7 +59,7 @@ class SceneContainerRepositoryTest : SysuiTestCase() { underTest.changeScene(Scenes.Shade) assertThat(currentScene).isEqualTo(Scenes.Shade) underTest.snapToScene(Scenes.QuickSettings) underTest.instantlyTransitionTo(Scenes.QuickSettings) assertThat(currentScene).isEqualTo(Scenes.QuickSettings) } Loading @@ -83,10 +83,10 @@ class SceneContainerRepositoryTest : SysuiTestCase() { } @Test(expected = IllegalStateException::class) fun snapToScene_noSuchSceneInContainer_throws() { fun instantlyTransitionTo_noSuchSceneInContainer_throws() { kosmos.sceneKeys = listOf(Scenes.QuickSettings, Scenes.Lockscreen) val underTest = kosmos.sceneContainerRepository underTest.snapToScene(Scenes.Shade) underTest.instantlyTransitionTo(Scenes.Shade) } @Test Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewControllerTest.kt +7 −5 Original line number Diff line number Diff line Loading @@ -72,6 +72,7 @@ import com.android.systemui.util.settings.SecureSettings import com.android.systemui.util.time.FakeSystemClock import com.google.common.truth.Truth import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest Loading @@ -87,6 +88,7 @@ import org.mockito.Mockito import org.mockito.MockitoAnnotations import org.mockito.kotlin.whenever @OptIn(ExperimentalCoroutinesApi::class) @SmallTest @RunWith(AndroidJUnit4::class) @RunWithLooper(setAsMainLooper = true) Loading Loading @@ -802,10 +804,10 @@ class KeyguardStatusBarViewControllerTest : SysuiTestCase() { looper.processAllMessages() updateStateToKeyguard() kosmos.fakeCommunalSceneRepository.snapToScene(CommunalScenes.Communal) kosmos.fakeCommunalSceneRepository.instantlyTransitionTo(CommunalScenes.Communal) runCurrent() controller.updateCommunalAlphaTransition(transitionAlphaAmount) assertThat(keyguardStatusBarView.getAlpha()).isEqualTo(transitionAlphaAmount) assertThat(keyguardStatusBarView.alpha).isEqualTo(transitionAlphaAmount) } finally { ViewUtils.detachView(keyguardStatusBarView) } Loading @@ -822,12 +824,12 @@ class KeyguardStatusBarViewControllerTest : SysuiTestCase() { looper.processAllMessages() updateStateToKeyguard() kosmos.fakeCommunalSceneRepository.snapToScene(CommunalScenes.Communal) kosmos.fakeCommunalSceneRepository.instantlyTransitionTo(CommunalScenes.Communal) runCurrent() controller.updateCommunalAlphaTransition(transitionAlphaAmount) kosmos.fakeCommunalSceneRepository.snapToScene(CommunalScenes.Blank) kosmos.fakeCommunalSceneRepository.instantlyTransitionTo(CommunalScenes.Blank) runCurrent() assertThat(keyguardStatusBarView.getAlpha()).isNotEqualTo(transitionAlphaAmount) assertThat(keyguardStatusBarView.alpha).isNotEqualTo(transitionAlphaAmount) } finally { ViewUtils.detachView(keyguardStatusBarView) } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/ShadeTouchableRegionManagerTest.kt +4 −2 Original line number Diff line number Diff line Loading @@ -31,12 +31,14 @@ import com.android.systemui.testKosmos import com.android.systemui.util.kotlin.getValue import com.google.common.truth.Truth.assertThat import dagger.Lazy import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.Test import org.junit.runner.RunWith @OptIn(ExperimentalCoroutinesApi::class) @SmallTest @RunWith(AndroidJUnit4::class) class ShadeTouchableRegionManagerTest : SysuiTestCase() { Loading Loading @@ -120,12 +122,12 @@ class ShadeTouchableRegionManagerTest : SysuiTestCase() { testScope.runTest { assertThat(underTest.shouldMakeEntireScreenTouchable()).isFalse() kosmos.fakeCommunalSceneRepository.snapToScene(CommunalScenes.Communal) kosmos.fakeCommunalSceneRepository.instantlyTransitionTo(CommunalScenes.Communal) runCurrent() assertThat(underTest.shouldMakeEntireScreenTouchable()).isTrue() kosmos.fakeCommunalSceneRepository.snapToScene(CommunalScenes.Blank) kosmos.fakeCommunalSceneRepository.instantlyTransitionTo(CommunalScenes.Blank) runCurrent() assertThat(underTest.shouldMakeEntireScreenTouchable()).isFalse() Loading