Loading packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ui/viewmodel/ShadeUserActionsViewModelTest.kt +23 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.authentication.data.repository.fakeAuthenticationRepository import com.android.systemui.authentication.shared.model.AuthenticationMethodModel import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectValues import com.android.systemui.deviceentry.data.repository.fakeDeviceEntryRepository import com.android.systemui.deviceentry.domain.interactor.deviceEntryInteractor import com.android.systemui.flags.EnableSceneContainer Loading @@ -50,6 +51,7 @@ import com.android.systemui.shade.domain.startable.shadeStartable import com.android.systemui.shade.shared.flag.DualShade import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertWithMessage import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.test.TestScope Loading Loading @@ -248,6 +250,27 @@ class ShadeUserActionsViewModelTest : SysuiTestCase() { assertThat(actions?.get(Swipe.Up)).isEqualTo(UserActionResult(Scenes.Communal)) } @Test fun upTransitionSceneKey_neverGoesBackToShadeScene() = testScope.runTest { val actions by collectValues(underTest.actions) val currentScene by collectLastValue(kosmos.sceneInteractor.currentScene) assertThat(currentScene).isEqualTo(Scenes.Lockscreen) kosmos.sceneInteractor.changeScene(Scenes.Shade, "") assertThat(currentScene).isEqualTo(Scenes.Shade) kosmos.sceneInteractor.changeScene(Scenes.QuickSettings, "") assertThat(currentScene).isEqualTo(Scenes.QuickSettings) actions.forEachIndexed { index, map -> assertWithMessage( "Actions on index $index is incorrectly mapping back to the Shade scene!" ) .that((map[Swipe.Up] as? UserActionResult.ChangeScene)?.toScene) .isNotEqualTo(Scenes.Shade) } } private fun TestScope.setDeviceEntered(isEntered: Boolean) { if (isEntered) { // Unlock the device marking the device has entered. Loading packages/SystemUI/src/com/android/systemui/shade/ui/viewmodel/ShadeUserActionsViewModel.kt +4 −1 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import com.android.systemui.shade.shared.model.ShadeMode import dagger.assisted.AssistedFactory import dagger.assisted.AssistedInject import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.filter /** * Models the UI state for the user actions that the user can perform to navigate to other scenes. Loading @@ -50,7 +51,9 @@ constructor( combine( shadeInteractor.shadeMode, qsSceneAdapter.isCustomizerShowing, sceneBackInteractor.backScene.map { it ?: SceneFamilies.Home }, sceneBackInteractor.backScene .filter { it != Scenes.Shade } .map { it ?: SceneFamilies.Home }, ) { shadeMode, isCustomizerShowing, backScene -> buildMap<UserAction, UserActionResult> { if (!isCustomizerShowing) { Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ui/viewmodel/ShadeUserActionsViewModelTest.kt +23 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.authentication.data.repository.fakeAuthenticationRepository import com.android.systemui.authentication.shared.model.AuthenticationMethodModel import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectValues import com.android.systemui.deviceentry.data.repository.fakeDeviceEntryRepository import com.android.systemui.deviceentry.domain.interactor.deviceEntryInteractor import com.android.systemui.flags.EnableSceneContainer Loading @@ -50,6 +51,7 @@ import com.android.systemui.shade.domain.startable.shadeStartable import com.android.systemui.shade.shared.flag.DualShade import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertWithMessage import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.test.TestScope Loading Loading @@ -248,6 +250,27 @@ class ShadeUserActionsViewModelTest : SysuiTestCase() { assertThat(actions?.get(Swipe.Up)).isEqualTo(UserActionResult(Scenes.Communal)) } @Test fun upTransitionSceneKey_neverGoesBackToShadeScene() = testScope.runTest { val actions by collectValues(underTest.actions) val currentScene by collectLastValue(kosmos.sceneInteractor.currentScene) assertThat(currentScene).isEqualTo(Scenes.Lockscreen) kosmos.sceneInteractor.changeScene(Scenes.Shade, "") assertThat(currentScene).isEqualTo(Scenes.Shade) kosmos.sceneInteractor.changeScene(Scenes.QuickSettings, "") assertThat(currentScene).isEqualTo(Scenes.QuickSettings) actions.forEachIndexed { index, map -> assertWithMessage( "Actions on index $index is incorrectly mapping back to the Shade scene!" ) .that((map[Swipe.Up] as? UserActionResult.ChangeScene)?.toScene) .isNotEqualTo(Scenes.Shade) } } private fun TestScope.setDeviceEntered(isEntered: Boolean) { if (isEntered) { // Unlock the device marking the device has entered. Loading
packages/SystemUI/src/com/android/systemui/shade/ui/viewmodel/ShadeUserActionsViewModel.kt +4 −1 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import com.android.systemui.shade.shared.model.ShadeMode import dagger.assisted.AssistedFactory import dagger.assisted.AssistedInject import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.filter /** * Models the UI state for the user actions that the user can perform to navigate to other scenes. Loading @@ -50,7 +51,9 @@ constructor( combine( shadeInteractor.shadeMode, qsSceneAdapter.isCustomizerShowing, sceneBackInteractor.backScene.map { it ?: SceneFamilies.Home }, sceneBackInteractor.backScene .filter { it != Scenes.Shade } .map { it ?: SceneFamilies.Home }, ) { shadeMode, isCustomizerShowing, backScene -> buildMap<UserAction, UserActionResult> { if (!isCustomizerShowing) { Loading