Loading packages/SystemUI/multivalentTests/src/com/android/systemui/notifications/ui/viewmodel/NotificationsShadeOverlayActionsViewModelTest.kt +16 −18 Original line number Diff line number Diff line Loading @@ -27,14 +27,16 @@ import com.android.compose.animation.scene.UserActionResult.ShowOverlay.HideCurr import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.lifecycle.activateIn import com.android.systemui.scene.shared.model.Overlays import com.android.systemui.scene.ui.viewmodel.SceneContainerArea import com.android.systemui.shade.ui.viewmodel.notificationsShadeOverlayActionsViewModel import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Test import org.junit.runner.RunWith Loading @@ -44,17 +46,19 @@ import org.junit.runner.RunWith @EnableSceneContainer class NotificationsShadeOverlayActionsViewModelTest : SysuiTestCase() { private val kosmos = testKosmos() private val testScope = kosmos.testScope private val kosmos = testKosmos().useUnconfinedTestDispatcher() private val underTest = kosmos.notificationsShadeOverlayActionsViewModel private val underTest by lazy { kosmos.notificationsShadeOverlayActionsViewModel } private val actions by kosmos.testScope.collectLastValue(underTest.actions) @Before fun setUp() { underTest.activateIn(kosmos.testScope) } @Test fun up_hidesShade() = testScope.runTest { val actions by collectLastValue(underTest.actions) underTest.activateIn(this) kosmos.runTest { assertThat((actions?.get(Swipe.Up) as? HideOverlay)?.overlay) .isEqualTo(Overlays.NotificationsShade) assertThat(actions?.get(Swipe.Down)).isNull() Loading @@ -62,21 +66,15 @@ class NotificationsShadeOverlayActionsViewModelTest : SysuiTestCase() { @Test fun back_hidesShade() = testScope.runTest { val actions by collectLastValue(underTest.actions) underTest.activateIn(this) kosmos.runTest { assertThat((actions?.get(Back) as? HideOverlay)?.overlay) .isEqualTo(Overlays.NotificationsShade) } @Test fun downFromTopEnd_switchesToQuickSettingsShade() = testScope.runTest { val actions by collectLastValue(underTest.actions) underTest.activateIn(this) val action = actions?.get(Swipe.Down(fromSource = SceneContainerArea.TopEdgeEndHalf)) fun downFromEndHalf_switchesToQuickSettingsShade() = kosmos.runTest { val action = actions?.get(Swipe.Down(fromSource = SceneContainerArea.EndHalf)) assertThat((action as ShowOverlay).overlay).isEqualTo(Overlays.QuickSettingsShade) assertThat((action.hideCurrentOverlays as HideCurrentOverlays.Some).overlays) .containsExactly(Overlays.NotificationsShade) Loading packages/SystemUI/multivalentTests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayActionsViewModelTest.kt +22 −32 Original line number Diff line number Diff line Loading @@ -27,6 +27,8 @@ import com.android.compose.animation.scene.UserActionResult.ShowOverlay.HideCurr import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.lifecycle.activateIn Loading @@ -35,7 +37,7 @@ import com.android.systemui.scene.shared.model.Overlays import com.android.systemui.scene.ui.viewmodel.SceneContainerArea import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Test import org.junit.runner.RunWith Loading @@ -46,16 +48,18 @@ import org.junit.runner.RunWith class QuickSettingsShadeOverlayActionsViewModelTest : SysuiTestCase() { private val kosmos = testKosmos().useUnconfinedTestDispatcher() private val testScope = kosmos.testScope private val underTest = kosmos.quickSettingsShadeOverlayActionsViewModel private val underTest by lazy { kosmos.quickSettingsShadeOverlayActionsViewModel } private val actions by kosmos.testScope.collectLastValue(underTest.actions) @Before fun setUp() { underTest.activateIn(kosmos.testScope) } @Test fun up_hidesShade() = testScope.runTest { val actions by collectLastValue(underTest.actions) underTest.activateIn(this) kosmos.runTest { assertThat((actions?.get(Swipe.Up) as? HideOverlay)?.overlay) .isEqualTo(Overlays.QuickSettingsShade) assertThat(actions?.get(Swipe.Down)).isNull() Loading @@ -63,10 +67,8 @@ class QuickSettingsShadeOverlayActionsViewModelTest : SysuiTestCase() { @Test fun back_notEditing_hidesShade() = testScope.runTest { val actions by collectLastValue(underTest.actions) val isEditing by collectLastValue(kosmos.editModeViewModel.isEditing) underTest.activateIn(this) kosmos.runTest { val isEditing by collectLastValue(editModeViewModel.isEditing) assertThat(isEditing).isFalse() assertThat(actions?.get(Back)).isEqualTo(HideOverlay(Overlays.QuickSettingsShade)) Loading @@ -74,45 +76,33 @@ class QuickSettingsShadeOverlayActionsViewModelTest : SysuiTestCase() { @Test fun back_whileEditing_doesNotHideShade() = testScope.runTest { val actions by collectLastValue(underTest.actions) underTest.activateIn(this) kosmos.editModeViewModel.startEditing() kosmos.runTest { editModeViewModel.startEditing() assertThat(actions?.get(Back)).isNull() } @Test fun upAboveEdge_whileEditing_doesNotHideShade() = testScope.runTest { val actions by collectLastValue(underTest.actions) underTest.activateIn(this) kosmos.editModeViewModel.startEditing() kosmos.runTest { editModeViewModel.startEditing() assertThat(actions?.get(Swipe.Up)).isNull() } @Test fun upFromEdge_whileEditing_hidesShade() = testScope.runTest { val actions by collectLastValue(underTest.actions) underTest.activateIn(this) kosmos.editModeViewModel.startEditing() kosmos.runTest { editModeViewModel.startEditing() val userAction = Swipe.Up(fromSource = SceneContainerArea.BottomEdge) assertThat(actions?.get(userAction)).isEqualTo(HideOverlay(Overlays.QuickSettingsShade)) } @Test fun downFromTopStart_switchesToNotificationsShade() = testScope.runTest { val actions by collectLastValue(underTest.actions) underTest.activateIn(this) val action = actions?.get(Swipe.Down(fromSource = SceneContainerArea.TopEdgeStartHalf)) fun downFromStartHalf_switchesToNotificationsShade() = kosmos.runTest { val action = actions?.get(Swipe.Down(fromSource = SceneContainerArea.StartHalf)) assertThat((action as ShowOverlay).overlay).isEqualTo(Overlays.NotificationsShade) assertThat((action.hideCurrentOverlays as HideCurrentOverlays.Some).overlays) .containsExactly(Overlays.QuickSettingsShade) Loading packages/SystemUI/src/com/android/systemui/notifications/ui/viewmodel/NotificationsShadeOverlayActionsViewModel.kt +1 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ class NotificationsShadeOverlayActionsViewModel @AssistedInject constructor() : mapOf( Swipe.Up to HideOverlay(Overlays.NotificationsShade), Back to HideOverlay(Overlays.NotificationsShade), Swipe.Down(fromSource = SceneContainerArea.TopEdgeEndHalf) to Swipe.Down(fromSource = SceneContainerArea.EndHalf) to ShowOverlay( Overlays.QuickSettingsShade, hideCurrentOverlays = HideCurrentOverlays.Some(Overlays.NotificationsShade), Loading packages/SystemUI/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayActionsViewModel.kt +1 −1 Original line number Diff line number Diff line Loading @@ -50,7 +50,7 @@ constructor(private val editModeViewModel: EditModeViewModel) : UserActionsViewM put(Swipe.Up, hideQuickSettings) } put( Swipe.Down(fromSource = SceneContainerArea.TopEdgeStartHalf), Swipe.Down(fromSource = SceneContainerArea.StartHalf), ShowOverlay( Overlays.NotificationsShade, hideCurrentOverlays = Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/notifications/ui/viewmodel/NotificationsShadeOverlayActionsViewModelTest.kt +16 −18 Original line number Diff line number Diff line Loading @@ -27,14 +27,16 @@ import com.android.compose.animation.scene.UserActionResult.ShowOverlay.HideCurr import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.lifecycle.activateIn import com.android.systemui.scene.shared.model.Overlays import com.android.systemui.scene.ui.viewmodel.SceneContainerArea import com.android.systemui.shade.ui.viewmodel.notificationsShadeOverlayActionsViewModel import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Test import org.junit.runner.RunWith Loading @@ -44,17 +46,19 @@ import org.junit.runner.RunWith @EnableSceneContainer class NotificationsShadeOverlayActionsViewModelTest : SysuiTestCase() { private val kosmos = testKosmos() private val testScope = kosmos.testScope private val kosmos = testKosmos().useUnconfinedTestDispatcher() private val underTest = kosmos.notificationsShadeOverlayActionsViewModel private val underTest by lazy { kosmos.notificationsShadeOverlayActionsViewModel } private val actions by kosmos.testScope.collectLastValue(underTest.actions) @Before fun setUp() { underTest.activateIn(kosmos.testScope) } @Test fun up_hidesShade() = testScope.runTest { val actions by collectLastValue(underTest.actions) underTest.activateIn(this) kosmos.runTest { assertThat((actions?.get(Swipe.Up) as? HideOverlay)?.overlay) .isEqualTo(Overlays.NotificationsShade) assertThat(actions?.get(Swipe.Down)).isNull() Loading @@ -62,21 +66,15 @@ class NotificationsShadeOverlayActionsViewModelTest : SysuiTestCase() { @Test fun back_hidesShade() = testScope.runTest { val actions by collectLastValue(underTest.actions) underTest.activateIn(this) kosmos.runTest { assertThat((actions?.get(Back) as? HideOverlay)?.overlay) .isEqualTo(Overlays.NotificationsShade) } @Test fun downFromTopEnd_switchesToQuickSettingsShade() = testScope.runTest { val actions by collectLastValue(underTest.actions) underTest.activateIn(this) val action = actions?.get(Swipe.Down(fromSource = SceneContainerArea.TopEdgeEndHalf)) fun downFromEndHalf_switchesToQuickSettingsShade() = kosmos.runTest { val action = actions?.get(Swipe.Down(fromSource = SceneContainerArea.EndHalf)) assertThat((action as ShowOverlay).overlay).isEqualTo(Overlays.QuickSettingsShade) assertThat((action.hideCurrentOverlays as HideCurrentOverlays.Some).overlays) .containsExactly(Overlays.NotificationsShade) Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayActionsViewModelTest.kt +22 −32 Original line number Diff line number Diff line Loading @@ -27,6 +27,8 @@ import com.android.compose.animation.scene.UserActionResult.ShowOverlay.HideCurr import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.lifecycle.activateIn Loading @@ -35,7 +37,7 @@ import com.android.systemui.scene.shared.model.Overlays import com.android.systemui.scene.ui.viewmodel.SceneContainerArea import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Test import org.junit.runner.RunWith Loading @@ -46,16 +48,18 @@ import org.junit.runner.RunWith class QuickSettingsShadeOverlayActionsViewModelTest : SysuiTestCase() { private val kosmos = testKosmos().useUnconfinedTestDispatcher() private val testScope = kosmos.testScope private val underTest = kosmos.quickSettingsShadeOverlayActionsViewModel private val underTest by lazy { kosmos.quickSettingsShadeOverlayActionsViewModel } private val actions by kosmos.testScope.collectLastValue(underTest.actions) @Before fun setUp() { underTest.activateIn(kosmos.testScope) } @Test fun up_hidesShade() = testScope.runTest { val actions by collectLastValue(underTest.actions) underTest.activateIn(this) kosmos.runTest { assertThat((actions?.get(Swipe.Up) as? HideOverlay)?.overlay) .isEqualTo(Overlays.QuickSettingsShade) assertThat(actions?.get(Swipe.Down)).isNull() Loading @@ -63,10 +67,8 @@ class QuickSettingsShadeOverlayActionsViewModelTest : SysuiTestCase() { @Test fun back_notEditing_hidesShade() = testScope.runTest { val actions by collectLastValue(underTest.actions) val isEditing by collectLastValue(kosmos.editModeViewModel.isEditing) underTest.activateIn(this) kosmos.runTest { val isEditing by collectLastValue(editModeViewModel.isEditing) assertThat(isEditing).isFalse() assertThat(actions?.get(Back)).isEqualTo(HideOverlay(Overlays.QuickSettingsShade)) Loading @@ -74,45 +76,33 @@ class QuickSettingsShadeOverlayActionsViewModelTest : SysuiTestCase() { @Test fun back_whileEditing_doesNotHideShade() = testScope.runTest { val actions by collectLastValue(underTest.actions) underTest.activateIn(this) kosmos.editModeViewModel.startEditing() kosmos.runTest { editModeViewModel.startEditing() assertThat(actions?.get(Back)).isNull() } @Test fun upAboveEdge_whileEditing_doesNotHideShade() = testScope.runTest { val actions by collectLastValue(underTest.actions) underTest.activateIn(this) kosmos.editModeViewModel.startEditing() kosmos.runTest { editModeViewModel.startEditing() assertThat(actions?.get(Swipe.Up)).isNull() } @Test fun upFromEdge_whileEditing_hidesShade() = testScope.runTest { val actions by collectLastValue(underTest.actions) underTest.activateIn(this) kosmos.editModeViewModel.startEditing() kosmos.runTest { editModeViewModel.startEditing() val userAction = Swipe.Up(fromSource = SceneContainerArea.BottomEdge) assertThat(actions?.get(userAction)).isEqualTo(HideOverlay(Overlays.QuickSettingsShade)) } @Test fun downFromTopStart_switchesToNotificationsShade() = testScope.runTest { val actions by collectLastValue(underTest.actions) underTest.activateIn(this) val action = actions?.get(Swipe.Down(fromSource = SceneContainerArea.TopEdgeStartHalf)) fun downFromStartHalf_switchesToNotificationsShade() = kosmos.runTest { val action = actions?.get(Swipe.Down(fromSource = SceneContainerArea.StartHalf)) assertThat((action as ShowOverlay).overlay).isEqualTo(Overlays.NotificationsShade) assertThat((action.hideCurrentOverlays as HideCurrentOverlays.Some).overlays) .containsExactly(Overlays.QuickSettingsShade) Loading
packages/SystemUI/src/com/android/systemui/notifications/ui/viewmodel/NotificationsShadeOverlayActionsViewModel.kt +1 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ class NotificationsShadeOverlayActionsViewModel @AssistedInject constructor() : mapOf( Swipe.Up to HideOverlay(Overlays.NotificationsShade), Back to HideOverlay(Overlays.NotificationsShade), Swipe.Down(fromSource = SceneContainerArea.TopEdgeEndHalf) to Swipe.Down(fromSource = SceneContainerArea.EndHalf) to ShowOverlay( Overlays.QuickSettingsShade, hideCurrentOverlays = HideCurrentOverlays.Some(Overlays.NotificationsShade), Loading
packages/SystemUI/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayActionsViewModel.kt +1 −1 Original line number Diff line number Diff line Loading @@ -50,7 +50,7 @@ constructor(private val editModeViewModel: EditModeViewModel) : UserActionsViewM put(Swipe.Up, hideQuickSettings) } put( Swipe.Down(fromSource = SceneContainerArea.TopEdgeStartHalf), Swipe.Down(fromSource = SceneContainerArea.StartHalf), ShowOverlay( Overlays.NotificationsShade, hideCurrentOverlays = Loading