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

Commit 6beed404 authored by burakov's avatar burakov
Browse files

[flexiglass] Unify methods to collapse the shade under ShadeInteractor.

Add functions that collapse the notifications shade and QS shade in
ShadeInteractor appropriately, whether it's Dual Shade or not.

This also adds an isNotificationsShadeExpanded flow to ShadeInteractor,
as well as overlay transition definitions for the
SlightlyFasterShadeCollapse transition key.

Bug: 356596436
Flag: com.android.systemui.scene_container
Test: Added unit tests.
Test: Existing unit tests still pass.
Change-Id: Ibaeae400c789aac148e590b0e383d0098001adea
parent 07769937
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -87,9 +87,21 @@ val SceneContainerTransitions = transitions {

    to(Overlays.NotificationsShade) { toNotificationsShadeTransition() }
    to(Overlays.QuickSettingsShade) { toQuickSettingsShadeTransition() }
    from(Overlays.NotificationsShade, Overlays.QuickSettingsShade) {
    from(Overlays.NotificationsShade, to = Overlays.QuickSettingsShade) {
        notificationsShadeToQuickSettingsShadeTransition()
    }
    from(Scenes.Gone, to = Overlays.NotificationsShade, key = SlightlyFasterShadeCollapse) {
        toNotificationsShadeTransition(durationScale = 0.9)
    }
    from(Scenes.Gone, to = Overlays.QuickSettingsShade, key = SlightlyFasterShadeCollapse) {
        toQuickSettingsShadeTransition(durationScale = 0.9)
    }
    from(Scenes.Lockscreen, to = Overlays.NotificationsShade, key = SlightlyFasterShadeCollapse) {
        toNotificationsShadeTransition(durationScale = 0.9)
    }
    from(Scenes.Lockscreen, to = Overlays.QuickSettingsShade, key = SlightlyFasterShadeCollapse) {
        toQuickSettingsShadeTransition(durationScale = 0.9)
    }

    // Scene overscroll

+4 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.notifications.ui.viewmodel

import android.platform.test.annotations.EnableFlags
import android.testing.TestableLooper
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
@@ -25,6 +26,7 @@ import com.android.systemui.flags.EnableSceneContainer
import com.android.systemui.kosmos.testScope
import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.scene.shared.model.Overlays
import com.android.systemui.shade.shared.flag.DualShade
import com.android.systemui.shade.ui.viewmodel.notificationsShadeOverlayContentViewModel
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
@@ -36,13 +38,14 @@ import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper
@EnableSceneContainer
@EnableFlags(DualShade.FLAG_NAME)
class NotificationsShadeOverlayContentViewModelTest : SysuiTestCase() {

    private val kosmos = testKosmos()
    private val testScope = kosmos.testScope
    private val sceneInteractor = kosmos.sceneInteractor

    private val underTest = kosmos.notificationsShadeOverlayContentViewModel
    private val underTest by lazy { kosmos.notificationsShadeOverlayContentViewModel }

    @Test
    fun onScrimClicked_hidesShade() =
+4 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.qs.ui.viewmodel

import android.platform.test.annotations.EnableFlags
import android.testing.TestableLooper
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
@@ -25,6 +26,7 @@ import com.android.systemui.flags.EnableSceneContainer
import com.android.systemui.kosmos.testScope
import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.scene.shared.model.Overlays
import com.android.systemui.shade.shared.flag.DualShade
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.test.runTest
@@ -35,13 +37,14 @@ import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper
@EnableSceneContainer
@EnableFlags(DualShade.FLAG_NAME)
class QuickSettingsShadeOverlayContentViewModelTest : SysuiTestCase() {

    private val kosmos = testKosmos()
    private val testScope = kosmos.testScope
    private val sceneInteractor = kosmos.sceneInteractor

    private val underTest = kosmos.quickSettingsShadeOverlayContentViewModel
    private val underTest by lazy { kosmos.quickSettingsShadeOverlayContentViewModel }

    @Test
    fun onScrimClicked_hidesShade() =
+32 −2
Original line number Diff line number Diff line
@@ -287,7 +287,7 @@ class ShadeInteractorImplTest(flags: FlagsParameterization) : SysuiTestCase() {

    @Test
    fun anyExpansion_shadeGreater() =
        testScope.runTest() {
        testScope.runTest {
            // WHEN shade is more expanded than QS
            shadeTestUtil.setShadeAndQsExpansion(.5f, 0f)
            runCurrent()
@@ -298,7 +298,7 @@ class ShadeInteractorImplTest(flags: FlagsParameterization) : SysuiTestCase() {

    @Test
    fun anyExpansion_qsGreater() =
        testScope.runTest() {
        testScope.runTest {
            // WHEN qs is more expanded than shade
            shadeTestUtil.setShadeAndQsExpansion(0f, .5f)
            runCurrent()
@@ -307,6 +307,36 @@ class ShadeInteractorImplTest(flags: FlagsParameterization) : SysuiTestCase() {
            assertThat(underTest.anyExpansion.value).isEqualTo(.5f)
        }

    @Test
    fun isShadeAnyExpanded_shadeCollapsed() =
        testScope.runTest {
            val isShadeAnyExpanded by collectLastValue(underTest.isShadeAnyExpanded)
            shadeTestUtil.setShadeExpansion(0f)
            runCurrent()

            assertThat(isShadeAnyExpanded).isFalse()
        }

    @Test
    fun isShadeAnyExpanded_shadePartiallyExpanded() =
        testScope.runTest {
            val isShadeAnyExpanded by collectLastValue(underTest.isShadeAnyExpanded)
            shadeTestUtil.setShadeExpansion(0.01f)
            runCurrent()

            assertThat(isShadeAnyExpanded).isTrue()
        }

    @Test
    fun isShadeAnyExpanded_shadeFullyExpanded() =
        testScope.runTest {
            val isShadeAnyExpanded by collectLastValue(underTest.isShadeAnyExpanded)
            shadeTestUtil.setShadeExpansion(1f)
            runCurrent()

            assertThat(isShadeAnyExpanded).isTrue()
        }

    @Test
    fun isShadeTouchable_isFalse_whenDeviceAsleepAndNotPulsing() =
        testScope.runTest {
+41 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.Assert.assertThrows
import org.junit.Test
import org.junit.runner.RunWith

@@ -382,4 +383,44 @@ class ShadeInteractorLegacyImplTest : SysuiTestCase() {
            // THEN user is not interacting
            assertThat(actual).isFalse()
        }

    @Test
    fun expandNotificationsShade_unsupported() =
        testScope.runTest {
            assertThrows(UnsupportedOperationException::class.java) {
                underTest.expandNotificationsShade("reason")
            }
        }

    @Test
    fun expandQuickSettingsShade_unsupported() =
        testScope.runTest {
            assertThrows(UnsupportedOperationException::class.java) {
                underTest.expandQuickSettingsShade("reason")
            }
        }

    @Test
    fun collapseNotificationsShade_unsupported() =
        testScope.runTest {
            assertThrows(UnsupportedOperationException::class.java) {
                underTest.collapseNotificationsShade("reason")
            }
        }

    @Test
    fun collapseQuickSettingsShade_unsupported() =
        testScope.runTest {
            assertThrows(UnsupportedOperationException::class.java) {
                underTest.collapseQuickSettingsShade("reason")
            }
        }

    @Test
    fun collapseEitherShade_unsupported() =
        testScope.runTest {
            assertThrows(UnsupportedOperationException::class.java) {
                underTest.collapseEitherShade("reason")
            }
        }
}
Loading