Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 76d34a3c authored by burakov's avatar burakov
Browse files

[Dual Shade] Expand the other shade when swiping down the opposite half.

Fix: 417947092
Test: Tested manually by swiping down on the empty side when either
 shade was open (on a wide-screen device), and verifying the expected
 behavior.
Test: Updated unit tests.
Flag: com.android.systemui.scene_container
Change-Id: Iefa588ee13888ce156e1f6c6924b997445923333
parent 1b827075
Loading
Loading
Loading
Loading
+16 −18
Original line number Diff line number Diff line
@@ -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

@@ -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()
@@ -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)
+22 −32
Original line number Diff line number Diff line
@@ -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
@@ -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

@@ -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()
@@ -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))
@@ -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)
+1 −1
Original line number Diff line number Diff line
@@ -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),
+1 −1
Original line number Diff line number Diff line
@@ -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 =