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

Commit de5b025b authored by Danny Burakov's avatar Danny Burakov Committed by Android (Google) Code Review
Browse files

Merge "[flexiglass] Unify methods to collapse the shade under ShadeInteractor." into main

parents 93af3c89 6beed404
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -91,9 +91,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