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

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

Merge "[flexiglass] Remove references to shadeTestUtil.setSplitShade." into main

parents 35076264 154dffb6
Loading
Loading
Loading
Loading
+37 −41
Original line number Diff line number Diff line
@@ -25,6 +25,10 @@ import com.android.systemui.flags.DisableSceneContainer
import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository
import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository
import com.android.systemui.keyguard.shared.model.StatusBarState
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.collectLastValue
import com.android.systemui.kosmos.runCurrent
import com.android.systemui.kosmos.runTest
import com.android.systemui.kosmos.testScope
import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.shade.data.repository.fakeShadeRepository
@@ -42,24 +46,17 @@ import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
@DisableSceneContainer
class ShadeInteractorLegacyImplTest : SysuiTestCase() {
    val kosmos = testKosmos()
    val testScope = kosmos.testScope
    val shadeTestUtil = kosmos.shadeTestUtil
    val configurationRepository = kosmos.fakeConfigurationRepository
    val keyguardRepository = kosmos.fakeKeyguardRepository
    val keyguardTransitionRepository = kosmos.fakeKeyguardTransitionRepository
    val sceneInteractor = kosmos.sceneInteractor
    val shadeRepository = kosmos.fakeShadeRepository
    val userRepository = kosmos.fakeUserRepository

    val underTest = kosmos.shadeInteractorLegacyImpl

    private val kosmos = testKosmos()
    private val shadeRepository = kosmos.fakeShadeRepository
    private val Kosmos.underTest by Kosmos.Fixture { kosmos.shadeInteractorLegacyImpl }

    @Test
    fun fullShadeExpansionWhenShadeLocked() =
        testScope.runTest {
        kosmos.runTest {
            val actual by collectLastValue(underTest.shadeExpansion)

            keyguardRepository.setStatusBarState(StatusBarState.SHADE_LOCKED)
            fakeKeyguardRepository.setStatusBarState(StatusBarState.SHADE_LOCKED)
            shadeRepository.setLockscreenShadeExpansion(0.5f)

            assertThat(actual).isEqualTo(1f)
@@ -67,10 +64,10 @@ class ShadeInteractorLegacyImplTest : SysuiTestCase() {

    @Test
    fun fullShadeExpansionWhenStatusBarStateIsNotShadeLocked() =
        testScope.runTest {
        kosmos.runTest {
            val actual by collectLastValue(underTest.shadeExpansion)

            keyguardRepository.setStatusBarState(StatusBarState.KEYGUARD)
            fakeKeyguardRepository.setStatusBarState(StatusBarState.KEYGUARD)

            shadeRepository.setLockscreenShadeExpansion(0.5f)
            assertThat(actual).isEqualTo(0.5f)
@@ -81,13 +78,12 @@ class ShadeInteractorLegacyImplTest : SysuiTestCase() {

    @Test
    fun shadeExpansionWhenInSplitShadeAndQsExpanded() =
        testScope.runTest {
        kosmos.runTest {
            val actual by collectLastValue(underTest.shadeExpansion)

            // WHEN split shade is enabled and QS is expanded
            keyguardRepository.setStatusBarState(StatusBarState.SHADE)
            shadeTestUtil.setSplitShade(true)
            configurationRepository.onAnyConfigurationChange()
            fakeKeyguardRepository.setStatusBarState(StatusBarState.SHADE)
            enableSplitShade()
            shadeRepository.setQsExpansion(.5f)
            shadeRepository.setLegacyShadeExpansion(.7f)
            runCurrent()
@@ -98,12 +94,12 @@ class ShadeInteractorLegacyImplTest : SysuiTestCase() {

    @Test
    fun shadeExpansionWhenNotInSplitShadeAndQsPartiallyExpanded() =
        testScope.runTest {
        kosmos.runTest {
            val actual by collectLastValue(underTest.shadeExpansion)

            // WHEN split shade is not enabled and QS is expanded
            keyguardRepository.setStatusBarState(StatusBarState.SHADE)
            shadeTestUtil.setSplitShade(false)
            fakeKeyguardRepository.setStatusBarState(StatusBarState.SHADE)
            enableSingleShade()
            shadeRepository.setQsExpansion(.5f)
            shadeRepository.setLegacyShadeExpansion(1f)
            runCurrent()
@@ -114,12 +110,12 @@ class ShadeInteractorLegacyImplTest : SysuiTestCase() {

    @Test
    fun shadeExpansionWhenNotInSplitShadeAndQsFullyExpanded() =
        testScope.runTest {
        kosmos.runTest {
            val actual by collectLastValue(underTest.shadeExpansion)

            // WHEN split shade is not enabled and QS is expanded
            keyguardRepository.setStatusBarState(StatusBarState.SHADE)
            shadeTestUtil.setSplitShade(false)
            fakeKeyguardRepository.setStatusBarState(StatusBarState.SHADE)
            enableSingleShade()
            shadeRepository.setQsExpansion(1f)
            shadeRepository.setLegacyShadeExpansion(1f)
            runCurrent()
@@ -130,12 +126,12 @@ class ShadeInteractorLegacyImplTest : SysuiTestCase() {

    @Test
    fun shadeExpansionWhenNotInSplitShadeAndQsPartlyExpanded() =
        testScope.runTest {
        kosmos.runTest {
            val actual by collectLastValue(underTest.shadeExpansion)

            // WHEN split shade is not enabled and QS partly expanded
            keyguardRepository.setStatusBarState(StatusBarState.SHADE)
            shadeTestUtil.setSplitShade(false)
            fakeKeyguardRepository.setStatusBarState(StatusBarState.SHADE)
            enableSingleShade()
            shadeRepository.setQsExpansion(.4f)
            shadeRepository.setLegacyShadeExpansion(1f)
            runCurrent()
@@ -146,12 +142,12 @@ class ShadeInteractorLegacyImplTest : SysuiTestCase() {

    @Test
    fun shadeExpansionWhenNotInSplitShadeAndQsCollapsed() =
        testScope.runTest {
        kosmos.runTest {
            val actual by collectLastValue(underTest.shadeExpansion)

            // WHEN split shade is not enabled and QS collapsed
            keyguardRepository.setStatusBarState(StatusBarState.SHADE)
            shadeTestUtil.setSplitShade(false)
            fakeKeyguardRepository.setStatusBarState(StatusBarState.SHADE)
            enableSingleShade()
            shadeRepository.setQsExpansion(0f)
            shadeRepository.setLegacyShadeExpansion(.6f)
            runCurrent()
@@ -162,7 +158,7 @@ class ShadeInteractorLegacyImplTest : SysuiTestCase() {

    @Test
    fun userInteractingWithShade_shadeDraggedUpAndDown() =
        testScope.runTest {
        kosmos.runTest {
            val actual by collectLastValue(underTest.isUserInteractingWithShade)
            // GIVEN shade collapsed and not tracking input
            shadeRepository.setLegacyShadeExpansion(0f)
@@ -218,7 +214,7 @@ class ShadeInteractorLegacyImplTest : SysuiTestCase() {

    @Test
    fun userInteractingWithShade_shadeExpanded() =
        testScope.runTest {
        kosmos.runTest {
            val actual by collectLastValue(underTest.isUserInteractingWithShade)
            // GIVEN shade collapsed and not tracking input
            shadeRepository.setLegacyShadeExpansion(0f)
@@ -253,7 +249,7 @@ class ShadeInteractorLegacyImplTest : SysuiTestCase() {

    @Test
    fun userInteractingWithShade_shadePartiallyExpanded() =
        testScope.runTest {
        kosmos.runTest {
            val actual by collectLastValue(underTest.isUserInteractingWithShade)
            // GIVEN shade collapsed and not tracking input
            shadeRepository.setLegacyShadeExpansion(0f)
@@ -294,7 +290,7 @@ class ShadeInteractorLegacyImplTest : SysuiTestCase() {

    @Test
    fun userInteractingWithShade_shadeCollapsed() =
        testScope.runTest {
        kosmos.runTest {
            val actual by collectLastValue(underTest.isUserInteractingWithShade)
            // GIVEN shade expanded and not tracking input
            shadeRepository.setLegacyShadeExpansion(1f)
@@ -329,7 +325,7 @@ class ShadeInteractorLegacyImplTest : SysuiTestCase() {

    @Test
    fun userInteractingWithQs_qsDraggedUpAndDown() =
        testScope.runTest {
        kosmos.runTest {
            val actual by collectLastValue(underTest.isUserInteractingWithQs)
            // GIVEN qs collapsed and not tracking input
            shadeRepository.setQsExpansion(0f)
@@ -385,7 +381,7 @@ class ShadeInteractorLegacyImplTest : SysuiTestCase() {

    @Test
    fun expandNotificationsShade_unsupported() =
        testScope.runTest {
        kosmos.runTest {
            assertThrows(UnsupportedOperationException::class.java) {
                underTest.expandNotificationsShade("reason")
            }
@@ -393,7 +389,7 @@ class ShadeInteractorLegacyImplTest : SysuiTestCase() {

    @Test
    fun expandQuickSettingsShade_unsupported() =
        testScope.runTest {
        kosmos.runTest {
            assertThrows(UnsupportedOperationException::class.java) {
                underTest.expandQuickSettingsShade("reason")
            }
@@ -401,7 +397,7 @@ class ShadeInteractorLegacyImplTest : SysuiTestCase() {

    @Test
    fun collapseNotificationsShade_unsupported() =
        testScope.runTest {
        kosmos.runTest {
            assertThrows(UnsupportedOperationException::class.java) {
                underTest.collapseNotificationsShade("reason")
            }
@@ -409,7 +405,7 @@ class ShadeInteractorLegacyImplTest : SysuiTestCase() {

    @Test
    fun collapseQuickSettingsShade_unsupported() =
        testScope.runTest {
        kosmos.runTest {
            assertThrows(UnsupportedOperationException::class.java) {
                underTest.collapseQuickSettingsShade("reason")
            }
@@ -417,7 +413,7 @@ class ShadeInteractorLegacyImplTest : SysuiTestCase() {

    @Test
    fun collapseEitherShade_unsupported() =
        testScope.runTest {
        kosmos.runTest {
            assertThrows(UnsupportedOperationException::class.java) {
                underTest.collapseEitherShade("reason")
            }
+2 −0
Original line number Diff line number Diff line
@@ -232,6 +232,7 @@ class NotificationListViewModelTest(flags: FlagsParameterization) : SysuiTestCas
    fun shouldShowEmptyShadeView_falseWhenQsExpandedDefault() =
        kosmos.runTest {
            val shouldShow by collectLastValue(underTest.shouldShowEmptyShadeView.map { it.value })
            enableSingleShade()

            // WHEN has no notifs
            activeNotificationListRepository.setActiveNotifs(count = 0)
@@ -269,6 +270,7 @@ class NotificationListViewModelTest(flags: FlagsParameterization) : SysuiTestCas
    fun shouldShowEmptyShadeView_notAnimatingWhenQsExpandedOnKeyguard() =
        kosmos.runTest {
            val shouldShow by collectLastValue(underTest.shouldShowEmptyShadeView)
            enableSingleShade()

            // WHEN has no notifs
            activeNotificationListRepository.setActiveNotifs(count = 0)
+22 −23
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ import com.android.systemui.keyguard.ui.viewmodel.ViewStateAccessor
import com.android.systemui.keyguard.ui.viewmodel.aodBurnInViewModel
import com.android.systemui.keyguard.ui.viewmodel.keyguardRootViewModel
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.advanceTimeBy
import com.android.systemui.kosmos.collectLastValue
import com.android.systemui.kosmos.collectValues
import com.android.systemui.kosmos.runTest
@@ -898,25 +899,24 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S
            var notificationCount = 10
            val calculateSpace = { space: Float, useExtraShelfSpace: Boolean -> notificationCount }
            val maxNotifications by collectLastValue(underTest.getMaxNotifications(calculateSpace))
            testScope.advanceTimeBy(50L)
            advanceTimeBy(50L)
            showLockscreen()

            shadeTestUtil.setSplitShade(false)
            fakeConfigurationRepository.onAnyConfigurationChange()
            enableSingleShade()

            assertThat(maxNotifications).isEqualTo(10)

            // Also updates when directly requested (as it would from NotificationStackScrollLayout)
            notificationCount = 25
            sharedNotificationContainerInteractor.notificationStackChanged()
            testScope.advanceTimeBy(50L)
            advanceTimeBy(50L)
            assertThat(maxNotifications).isEqualTo(25)

            // Also ensure another collection starts with the same value. As an example, folding
            // then unfolding will restart the coroutine and it must get the last value immediately.
            val newMaxNotifications by
                collectLastValue(underTest.getMaxNotifications(calculateSpace))
            testScope.advanceTimeBy(50L)
            advanceTimeBy(50L)
            assertThat(newMaxNotifications).isEqualTo(25)
        }

@@ -927,7 +927,7 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S
            var notificationCount = 10
            val calculateSpace = { space: Float, useExtraShelfSpace: Boolean -> notificationCount }
            val maxNotifications by collectLastValue(underTest.getMaxNotifications(calculateSpace))
            testScope.advanceTimeBy(50L)
            advanceTimeBy(50L)
            showLockscreen()

            fakeConfigurationRepository.onAnyConfigurationChange()
@@ -958,13 +958,12 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S
        kosmos.runTest {
            val calculateSpace = { space: Float, useExtraShelfSpace: Boolean -> 10 }
            val maxNotifications by collectLastValue(underTest.getMaxNotifications(calculateSpace))
            testScope.advanceTimeBy(50L)
            advanceTimeBy(50L)

            // Show lockscreen with shade expanded
            showLockscreenWithShadeExpanded()

            shadeTestUtil.setSplitShade(false)
            fakeConfigurationRepository.onAnyConfigurationChange()
            enableSingleShade()

            // -1 means No Limit
            assertThat(maxNotifications).isEqualTo(-1)
@@ -1445,19 +1444,19 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S
                        calculateHeight,
                    )
                )
            kosmos.activeNotificationListRepository.setActiveNotifs(notificationCount)
            activeNotificationListRepository.setActiveNotifs(notificationCount)
            showLockscreen()
            keyguardInteractor.setNotificationContainerBounds(
                NotificationContainerBounds(top = 100F, bottom = 300F)
            )

            sharedNotificationContainerInteractor.notificationStackChanged()
            testScope.advanceTimeBy(50L)
            advanceTimeBy(50L)
            assertThat(stackAbsoluteBottom).isEqualTo(150F)

            notificationCount = 3
            sharedNotificationContainerInteractor.notificationStackChanged()
            testScope.advanceTimeBy(50L)
            advanceTimeBy(50L)
            assertThat(stackAbsoluteBottom).isEqualTo(170F)
        }

@@ -1483,7 +1482,7 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S
                NotificationContainerBounds(top = 100F, bottom = 300F)
            )
            activeNotificationListRepository.setActiveNotifs(notificationCount)
            testScope.advanceTimeBy(50L)
            advanceTimeBy(50L)

            assertThat(stackAbsoluteBottom).isEqualTo(0F)
        }
@@ -1507,18 +1506,18 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S
            activeNotificationListRepository.setActiveNotifs(notificationCount)
            showLockscreen()

            shadeTestUtil.setSplitShade(false)
            enableSingleShade()
            keyguardInteractor.setNotificationContainerBounds(
                NotificationContainerBounds(top = 100F, bottom = 300F)
            )

            sharedNotificationContainerInteractor.notificationStackChanged()
            testScope.advanceTimeBy(50L)
            advanceTimeBy(50L)
            assertThat(stackAbsoluteBottom).isEqualTo(150F)

            shelfHeight = 0f
            sharedNotificationContainerInteractor.notificationStackChanged()
            testScope.advanceTimeBy(50L)
            advanceTimeBy(50L)
            assertThat(stackAbsoluteBottom).isEqualTo(140F)
        }

@@ -1537,9 +1536,9 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S
                        calculateHeight,
                    )
                )
            testScope.advanceTimeBy(50L)
            advanceTimeBy(50L)

            shadeTestUtil.setSplitShade(false)
            enableSingleShade()
            keyguardInteractor.setNotificationContainerBounds(
                NotificationContainerBounds(top = 100F, bottom = 300F)
            )
@@ -1567,19 +1566,19 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S
                    )
                )
            showLockscreen()
            shadeTestUtil.setSplitShade(false)
            enableSingleShade()
            activeNotificationListRepository.setActiveNotifs(notificationCount)
            keyguardInteractor.setNotificationContainerBounds(
                NotificationContainerBounds(top = 100F, bottom = 300F)
            )
            testScope.advanceTimeBy(50L)
            advanceTimeBy(50L)
            assertThat(stackAbsoluteBottom).isEqualTo(150F)

            showLockscreenWithQSExpanded()
            keyguardInteractor.setNotificationContainerBounds(
                NotificationContainerBounds(top = 200F, bottom = 300F)
            )
            testScope.advanceTimeBy(50L)
            advanceTimeBy(50L)
            assertThat(stackAbsoluteBottom).isEqualTo(150F)
        }

@@ -1600,12 +1599,12 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S
                    )
                )
            showLockscreen()
            shadeTestUtil.setSplitShade(false)
            enableSingleShade()
            activeNotificationListRepository.setActiveNotifs(notificationCount)
            keyguardInteractor.setNotificationContainerBounds(
                NotificationContainerBounds(top = 100F, bottom = 100F)
            )
            testScope.advanceTimeBy(50L)
            advanceTimeBy(50L)
            assertThat(stackAbsoluteBottom).isEqualTo(200F)
        }