Loading packages/SystemUI/multivalentTests/src/com/android/systemui/scene/SceneFrameworkIntegrationTest.kt +2 −1 Original line number Diff line number Diff line Loading @@ -615,6 +615,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { private fun TestScope.emulatePendingTransitionProgress( expectedVisible: Boolean = true, ) { val isVisible by collectLastValue(sceneContainerViewModel.isVisible) assertWithMessage("The FakeSceneDataSource has to be paused for this to do anything.") .that(fakeSceneDataSource.isPaused) .isTrue() Loading Loading @@ -651,7 +652,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { runCurrent() assertWithMessage("Visibility mismatch after scene transition from $from to $to!") .that(sceneContainerViewModel.isVisible.value) .that(isVisible) .isEqualTo(expectedVisible) assertThat(sceneContainerViewModel.currentScene.value).isEqualTo(to) Loading packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/interactor/SceneInteractorTest.kt +17 −0 Original line number Diff line number Diff line Loading @@ -14,6 +14,8 @@ * limitations under the License. */ @file:OptIn(ExperimentalCoroutinesApi::class) package com.android.systemui.scene.domain.interactor import androidx.test.ext.junit.runners.AndroidJUnit4 Loading @@ -31,6 +33,7 @@ import com.android.systemui.scene.shared.model.SceneKey import com.android.systemui.scene.shared.model.fakeSceneDataSource 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.runCurrent Loading Loading @@ -275,4 +278,18 @@ class SceneInteractorTest : SysuiTestCase() { underTest.setVisible(true, "reason") assertThat(isVisible).isTrue() } @Test fun isVisible_duringRemoteUserInteraction_forcedVisible() = testScope.runTest { underTest.setVisible(false, "reason") val isVisible by collectLastValue(underTest.isVisible) assertThat(isVisible).isFalse() underTest.onRemoteUserInteractionStarted("reason") assertThat(isVisible).isTrue() underTest.onUserInteractionFinished() assertThat(isVisible).isFalse() } } packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModelTest.kt +22 −7 Original line number Diff line number Diff line Loading @@ -14,10 +14,9 @@ * limitations under the License. */ @file:OptIn(ExperimentalCoroutinesApi::class) package com.android.systemui.scene.ui.viewmodel import android.view.MotionEvent import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase Loading @@ -35,9 +34,9 @@ import com.android.systemui.scene.shared.model.SceneKey import com.android.systemui.scene.shared.model.fakeSceneDataSource import com.android.systemui.testKosmos import com.android.systemui.util.mockito.mock import com.android.systemui.util.mockito.whenever import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertWithMessage import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.Before Loading @@ -50,7 +49,7 @@ class SceneContainerViewModelTest : SysuiTestCase() { private val kosmos = testKosmos() private val testScope by lazy { kosmos.testScope } private val interactor by lazy { kosmos.sceneInteractor } private val sceneInteractor by lazy { kosmos.sceneInteractor } private val fakeSceneDataSource = kosmos.fakeSceneDataSource private val sceneContainerConfig = kosmos.sceneContainerConfig private val falsingManager = kosmos.fakeFalsingManager Loading @@ -62,7 +61,7 @@ class SceneContainerViewModelTest : SysuiTestCase() { kosmos.fakeSceneContainerFlags.enabled = true underTest = SceneContainerViewModel( sceneInteractor = interactor, sceneInteractor = sceneInteractor, falsingInteractor = kosmos.falsingInteractor, powerInteractor = kosmos.powerInteractor, ) Loading @@ -74,10 +73,10 @@ class SceneContainerViewModelTest : SysuiTestCase() { val isVisible by collectLastValue(underTest.isVisible) assertThat(isVisible).isTrue() interactor.setVisible(false, "reason") sceneInteractor.setVisible(false, "reason") assertThat(isVisible).isFalse() interactor.setVisible(true, "reason") sceneInteractor.setVisible(true, "reason") assertThat(isVisible).isTrue() } Loading Loading @@ -199,4 +198,20 @@ class SceneContainerViewModelTest : SysuiTestCase() { underTest.onMotionEvent(mock()) assertThat(kosmos.fakePowerRepository.userTouchRegistered).isTrue() } @Test fun remoteUserInteraction_keepsContainerVisible() = testScope.runTest { sceneInteractor.setVisible(false, "reason") val isVisible by collectLastValue(underTest.isVisible) assertThat(isVisible).isFalse() sceneInteractor.onRemoteUserInteractionStarted("reason") assertThat(isVisible).isTrue() underTest.onMotionEvent( mock { whenever(actionMasked).thenReturn(MotionEvent.ACTION_UP) } ) assertThat(isVisible).isFalse() } } packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java +1 −1 Original line number Diff line number Diff line Loading @@ -221,7 +221,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis // If scene framework is enabled, set the scene container window to // visible and let the touch "slip" into that window. if (mSceneContainerFlags.isEnabled()) { mSceneInteractor.get().setVisible(true, "swipe down on launcher"); mSceneInteractor.get().onRemoteUserInteractionStarted("launcher swipe"); } else { mShadeViewControllerLazy.get().startInputFocusTransfer(); } Loading packages/SystemUI/src/com/android/systemui/scene/data/repository/SceneContainerRepository.kt +7 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,13 @@ constructor( private val _isVisible = MutableStateFlow(true) val isVisible: StateFlow<Boolean> = _isVisible.asStateFlow() /** * Whether there's an ongoing remotely-initiated user interaction. * * For more information see the logic in `SceneInteractor` that mutates this. */ val isRemoteUserInteractionOngoing = MutableStateFlow(false) private val defaultTransitionState = ObservableTransitionState.Idle(config.initialSceneKey) private val _transitionState = MutableStateFlow<Flow<ObservableTransitionState>?>(null) val transitionState: StateFlow<ObservableTransitionState> = Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/scene/SceneFrameworkIntegrationTest.kt +2 −1 Original line number Diff line number Diff line Loading @@ -615,6 +615,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { private fun TestScope.emulatePendingTransitionProgress( expectedVisible: Boolean = true, ) { val isVisible by collectLastValue(sceneContainerViewModel.isVisible) assertWithMessage("The FakeSceneDataSource has to be paused for this to do anything.") .that(fakeSceneDataSource.isPaused) .isTrue() Loading Loading @@ -651,7 +652,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() { runCurrent() assertWithMessage("Visibility mismatch after scene transition from $from to $to!") .that(sceneContainerViewModel.isVisible.value) .that(isVisible) .isEqualTo(expectedVisible) assertThat(sceneContainerViewModel.currentScene.value).isEqualTo(to) Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/interactor/SceneInteractorTest.kt +17 −0 Original line number Diff line number Diff line Loading @@ -14,6 +14,8 @@ * limitations under the License. */ @file:OptIn(ExperimentalCoroutinesApi::class) package com.android.systemui.scene.domain.interactor import androidx.test.ext.junit.runners.AndroidJUnit4 Loading @@ -31,6 +33,7 @@ import com.android.systemui.scene.shared.model.SceneKey import com.android.systemui.scene.shared.model.fakeSceneDataSource 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.runCurrent Loading Loading @@ -275,4 +278,18 @@ class SceneInteractorTest : SysuiTestCase() { underTest.setVisible(true, "reason") assertThat(isVisible).isTrue() } @Test fun isVisible_duringRemoteUserInteraction_forcedVisible() = testScope.runTest { underTest.setVisible(false, "reason") val isVisible by collectLastValue(underTest.isVisible) assertThat(isVisible).isFalse() underTest.onRemoteUserInteractionStarted("reason") assertThat(isVisible).isTrue() underTest.onUserInteractionFinished() assertThat(isVisible).isFalse() } }
packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModelTest.kt +22 −7 Original line number Diff line number Diff line Loading @@ -14,10 +14,9 @@ * limitations under the License. */ @file:OptIn(ExperimentalCoroutinesApi::class) package com.android.systemui.scene.ui.viewmodel import android.view.MotionEvent import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase Loading @@ -35,9 +34,9 @@ import com.android.systemui.scene.shared.model.SceneKey import com.android.systemui.scene.shared.model.fakeSceneDataSource import com.android.systemui.testKosmos import com.android.systemui.util.mockito.mock import com.android.systemui.util.mockito.whenever import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertWithMessage import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.Before Loading @@ -50,7 +49,7 @@ class SceneContainerViewModelTest : SysuiTestCase() { private val kosmos = testKosmos() private val testScope by lazy { kosmos.testScope } private val interactor by lazy { kosmos.sceneInteractor } private val sceneInteractor by lazy { kosmos.sceneInteractor } private val fakeSceneDataSource = kosmos.fakeSceneDataSource private val sceneContainerConfig = kosmos.sceneContainerConfig private val falsingManager = kosmos.fakeFalsingManager Loading @@ -62,7 +61,7 @@ class SceneContainerViewModelTest : SysuiTestCase() { kosmos.fakeSceneContainerFlags.enabled = true underTest = SceneContainerViewModel( sceneInteractor = interactor, sceneInteractor = sceneInteractor, falsingInteractor = kosmos.falsingInteractor, powerInteractor = kosmos.powerInteractor, ) Loading @@ -74,10 +73,10 @@ class SceneContainerViewModelTest : SysuiTestCase() { val isVisible by collectLastValue(underTest.isVisible) assertThat(isVisible).isTrue() interactor.setVisible(false, "reason") sceneInteractor.setVisible(false, "reason") assertThat(isVisible).isFalse() interactor.setVisible(true, "reason") sceneInteractor.setVisible(true, "reason") assertThat(isVisible).isTrue() } Loading Loading @@ -199,4 +198,20 @@ class SceneContainerViewModelTest : SysuiTestCase() { underTest.onMotionEvent(mock()) assertThat(kosmos.fakePowerRepository.userTouchRegistered).isTrue() } @Test fun remoteUserInteraction_keepsContainerVisible() = testScope.runTest { sceneInteractor.setVisible(false, "reason") val isVisible by collectLastValue(underTest.isVisible) assertThat(isVisible).isFalse() sceneInteractor.onRemoteUserInteractionStarted("reason") assertThat(isVisible).isTrue() underTest.onMotionEvent( mock { whenever(actionMasked).thenReturn(MotionEvent.ACTION_UP) } ) assertThat(isVisible).isFalse() } }
packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java +1 −1 Original line number Diff line number Diff line Loading @@ -221,7 +221,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis // If scene framework is enabled, set the scene container window to // visible and let the touch "slip" into that window. if (mSceneContainerFlags.isEnabled()) { mSceneInteractor.get().setVisible(true, "swipe down on launcher"); mSceneInteractor.get().onRemoteUserInteractionStarted("launcher swipe"); } else { mShadeViewControllerLazy.get().startInputFocusTransfer(); } Loading
packages/SystemUI/src/com/android/systemui/scene/data/repository/SceneContainerRepository.kt +7 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,13 @@ constructor( private val _isVisible = MutableStateFlow(true) val isVisible: StateFlow<Boolean> = _isVisible.asStateFlow() /** * Whether there's an ongoing remotely-initiated user interaction. * * For more information see the logic in `SceneInteractor` that mutates this. */ val isRemoteUserInteractionOngoing = MutableStateFlow(false) private val defaultTransitionState = ObservableTransitionState.Idle(config.initialSceneKey) private val _transitionState = MutableStateFlow<Flow<ObservableTransitionState>?>(null) val transitionState: StateFlow<ObservableTransitionState> = Loading