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

Commit b60939a0 authored by Danny Burakov's avatar Danny Burakov
Browse files

[flexiglass] Remove setShadeLayoutWide from KeyguardClockViewModelTest.

Bug: 444643845
Test: Unit test still passes.
Flag: com.android.systemui.scene_container
Change-Id: I5c5c5bb503ac56fa52254cf75931d7865809a8e1
parent bac46421
Loading
Loading
Loading
Loading
+82 −103
Original line number Diff line number Diff line
@@ -33,14 +33,17 @@ import com.android.systemui.keyguard.data.repository.keyguardClockRepository
import com.android.systemui.keyguard.shared.model.ClockSize
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel.ClockLayout
import com.android.systemui.kosmos.testScope
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.collectLastValue
import com.android.systemui.kosmos.runTest
import com.android.systemui.kosmos.useUnconfinedTestDispatcher
import com.android.systemui.plugins.keyguard.ui.clocks.ClockConfig
import com.android.systemui.plugins.keyguard.ui.clocks.ClockController
import com.android.systemui.plugins.keyguard.ui.clocks.ClockFaceConfig
import com.android.systemui.plugins.keyguard.ui.clocks.ClockFaceController
import com.android.systemui.res.R
import com.android.systemui.shade.data.repository.shadeRepository
import com.android.systemui.shade.domain.interactor.enableSingleShade
import com.android.systemui.shade.domain.interactor.enableSplitShade
import com.android.systemui.statusbar.notification.data.repository.activeNotificationListRepository
import com.android.systemui.statusbar.notification.data.repository.setActiveNotifs
import com.android.systemui.statusbar.ui.fakeSystemBarUtilsProxy
@@ -61,14 +64,12 @@ import platform.test.runner.parameterized.Parameters
class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase() {

    private val kosmos = testKosmos().useUnconfinedTestDispatcher()
    private val testScope = kosmos.testScope
    private val underTest by lazy { kosmos.keyguardClockViewModel }
    private val Kosmos.underTest by Kosmos.Fixture { keyguardClockViewModel }
    private val res = context.resources

    @Mock private lateinit var clockController: ClockController
    @Mock private lateinit var largeClock: ClockFaceController
    @Mock private lateinit var smallClock: ClockFaceController

    @Mock private lateinit var mockConfiguration: Configuration

    private var config = ClockConfig("TEST", "Test", "")
@@ -92,18 +93,16 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase()

    @Test
    fun currentClockLayout_splitShadeOn_clockCentered_largeClock() =
        testScope.runTest {
        kosmos.runTest {
            val currentClockLayout by collectLastValue(underTest.currentClockLayout)

            with(kosmos) {
                shadeRepository.setShadeLayoutWide(true)
                kosmos.activeNotificationListRepository.setActiveNotifs(0)
            enableSplitShade()
            activeNotificationListRepository.setActiveNotifs(0)
            fakeKeyguardTransitionRepository.transitionTo(
                KeyguardState.AOD,
                KeyguardState.LOCKSCREEN,
            )
            keyguardClockRepository.setClockSize(ClockSize.LARGE)
            }

            assertThat(currentClockLayout).isEqualTo(ClockLayout.LARGE_CLOCK)
        }
@@ -111,18 +110,16 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase()
    @Test
    @EnableSceneContainer
    fun currentClockLayout_splitShadeOn_clockNotCentered_largeClock_splitShadeLargeClock() =
        testScope.runTest {
        kosmos.runTest {
            val currentClockLayout by collectLastValue(underTest.currentClockLayout)

            with(kosmos) {
                shadeRepository.setShadeLayoutWide(true)
            enableSplitShade()
            activeNotificationListRepository.setActiveNotifs(1)
            fakeKeyguardTransitionRepository.transitionTo(
                KeyguardState.AOD,
                KeyguardState.LOCKSCREEN,
            )
            keyguardClockRepository.setClockSize(ClockSize.LARGE)
            }

            assertThat(currentClockLayout).isEqualTo(ClockLayout.SPLIT_SHADE_LARGE_CLOCK)
        }
@@ -130,18 +127,16 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase()
    @Test
    @EnableSceneContainer
    fun currentClockLayout_splitShadeOn_clockNotCentered_forceSmallClock_splitShadeSmallClock() =
        testScope.runTest {
        kosmos.runTest {
            val currentClockLayout by collectLastValue(underTest.currentClockLayout)

            with(kosmos) {
                shadeRepository.setShadeLayoutWide(true)
            enableSplitShade()
            activeNotificationListRepository.setActiveNotifs(1)
            fakeKeyguardTransitionRepository.transitionTo(
                KeyguardState.AOD,
                KeyguardState.LOCKSCREEN,
            )
            fakeKeyguardClockRepository.setClockSize(ClockSize.SMALL)
            }

            assertThat(currentClockLayout).isEqualTo(ClockLayout.SPLIT_SHADE_SMALL_CLOCK)
        }
@@ -149,85 +144,75 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase()
    @Test
    @EnableSceneContainer
    fun currentClockLayout_singleShade_withNotifs_smallClock() =
        testScope.runTest {
        kosmos.runTest {
            val currentClockLayout by collectLastValue(underTest.currentClockLayout)

            with(kosmos) {
                shadeRepository.setShadeLayoutWide(false)
            enableSingleShade()
            activeNotificationListRepository.setActiveNotifs(1)
            }

            assertThat(currentClockLayout).isEqualTo(ClockLayout.SMALL_CLOCK)
        }

    @Test
    fun currentClockLayout_singleShade_withoutNotifs_largeClock() =
        testScope.runTest {
        kosmos.runTest {
            val currentClockLayout by collectLastValue(underTest.currentClockLayout)

            with(kosmos) {
                shadeRepository.setShadeLayoutWide(false)
            enableSingleShade()
            activeNotificationListRepository.setActiveNotifs(0)
            }

            assertThat(currentClockLayout).isEqualTo(ClockLayout.LARGE_CLOCK)
        }

    @Test
    fun hasCustomPositionUpdatedAnimation_withConfigTrue_isTrue() =
        testScope.runTest {
        kosmos.runTest {
            val hasCustomPositionUpdatedAnimation by
                collectLastValue(underTest.hasCustomPositionUpdatedAnimation)

            with(kosmos) {
            keyguardClockRepository.setClockSize(ClockSize.LARGE)
            faceConfig = ClockFaceConfig(hasCustomPositionUpdatedAnimation = true)
            fakeKeyguardClockRepository.setCurrentClock(clockController)
            }

            assertThat(hasCustomPositionUpdatedAnimation).isEqualTo(true)
        }

    @Test
    fun hasCustomPositionUpdatedAnimation_withConfigFalse_isFalse() =
        testScope.runTest {
        kosmos.runTest {
            val hasCustomPositionUpdatedAnimation by
                collectLastValue(underTest.hasCustomPositionUpdatedAnimation)

            with(kosmos) {
            keyguardClockRepository.setClockSize(ClockSize.LARGE)
            faceConfig = ClockFaceConfig(hasCustomPositionUpdatedAnimation = false)
            fakeKeyguardClockRepository.setCurrentClock(clockController)
            }

            assertThat(hasCustomPositionUpdatedAnimation).isEqualTo(false)
        }

    @Test
    fun isLargeClockVisible_whenLargeClockSize_isTrue() =
        testScope.runTest {
        kosmos.runTest {
            val value by collectLastValue(underTest.isLargeClockVisible)
            kosmos.keyguardClockRepository.setClockSize(ClockSize.LARGE)
            keyguardClockRepository.setClockSize(ClockSize.LARGE)
            assertThat(value).isEqualTo(true)
        }

    @Test
    @DisableSceneContainer
    fun isLargeClockVisible_whenSmallClockSize_isFalse() =
        testScope.runTest {
        kosmos.runTest {
            val value by collectLastValue(underTest.isLargeClockVisible)
            kosmos.keyguardClockRepository.setClockSize(ClockSize.SMALL)
            keyguardClockRepository.setClockSize(ClockSize.SMALL)
            assertThat(value).isEqualTo(false)
        }

    @Test
    @EnableSceneContainer
    fun testSmallClockTop_splitShade_sceneContainerOn() =
        testScope.runTest {
            with(kosmos) {
                shadeRepository.setShadeLayoutWide(true)
        kosmos.runTest {
            enableSplitShade()
            fakeSystemBarUtilsProxy.fakeKeyguardStatusBarHeight = KEYGUARD_STATUS_BAR_HEIGHT
            }

            val expected =
                res.getDimensionPixelSize(R.dimen.keyguard_split_shade_top_margin) -
@@ -238,11 +223,9 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase()
    @Test
    @DisableSceneContainer
    fun testSmallClockTop_splitShade_sceneContainerOff() =
        testScope.runTest {
            with(kosmos) {
                shadeRepository.setShadeLayoutWide(true)
        kosmos.runTest {
            enableSplitShade()
            fakeSystemBarUtilsProxy.fakeKeyguardStatusBarHeight = KEYGUARD_STATUS_BAR_HEIGHT
            }

            assertThat(underTest.getSmallClockTopMargin())
                .isEqualTo(res.getDimensionPixelSize(R.dimen.keyguard_split_shade_top_margin))
@@ -250,12 +233,10 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase()

    @Test
    @EnableSceneContainer
    fun testSmallClockTop_nonSplitShade_sceneContainerOn() =
        testScope.runTest {
            with(kosmos) {
                shadeRepository.setShadeLayoutWide(false)
    fun testSmallClockTop_singleShade_sceneContainerOn() =
        kosmos.runTest {
            enableSingleShade()
            fakeSystemBarUtilsProxy.fakeKeyguardStatusBarHeight = KEYGUARD_STATUS_BAR_HEIGHT
            }

            assertThat(underTest.getSmallClockTopMargin())
                .isEqualTo(res.getDimensionPixelSize(R.dimen.keyguard_clock_top_margin))
@@ -263,12 +244,10 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase()

    @Test
    @DisableSceneContainer
    fun testSmallClockTop_nonSplitShade_sceneContainerOff() =
        testScope.runTest {
            with(kosmos) {
                shadeRepository.setShadeLayoutWide(false)
    fun testSmallClockTop_singleShade_sceneContainerOff() =
        kosmos.runTest {
            enableSingleShade()
            fakeSystemBarUtilsProxy.fakeKeyguardStatusBarHeight = KEYGUARD_STATUS_BAR_HEIGHT
            }

            val expected =
                res.getDimensionPixelSize(R.dimen.keyguard_clock_top_margin) +
@@ -279,7 +258,7 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase()
    @Test
    @DisableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_SMARTSPACE_LAYOUT)
    fun dateWeatherBelowSmallClock_smartspacelayoutflag_off_true() =
        testScope.runTest {
        kosmos.runTest {
            val result by collectLastValue(underTest.shouldDateWeatherBeBelowSmallClock)

            assertThat(result).isTrue()
@@ -288,7 +267,7 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase()
    @Test
    @DisableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_SMARTSPACE_LAYOUT)
    fun dateWeatherBelowLargeClock_smartspacelayoutflag_off_false() =
        testScope.runTest {
        kosmos.runTest {
            val result by collectLastValue(underTest.shouldDateWeatherBeBelowLargeClock)

            assertThat(result).isFalse()
@@ -297,8 +276,8 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase()
    @Test
    @EnableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_SMARTSPACE_LAYOUT)
    fun dateWeatherBelowSmallClock_defaultFontAndDisplaySize_shadeLayoutNotWide_false() =
        testScope.runTest {
            kosmos.shadeRepository.setShadeLayoutWide(false)
        kosmos.runTest {
            enableSingleShade()
            val fontScale = 1.0f
            val screenWidthDp = 347
            mockConfiguration.fontScale = fontScale
@@ -312,7 +291,7 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase()
    @Test
    @EnableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_SMARTSPACE_LAYOUT)
    fun dateWeatherBelowLargeClock_variousFontAndDisplaySize_true() =
        testScope.runTest {
        kosmos.runTest {
            mockConfiguration.fontScale = 1.0f
            mockConfiguration.screenWidthDp = 347
            val result1 by collectLastValue(underTest.shouldDateWeatherBeBelowLargeClock)
@@ -332,8 +311,8 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase()
    @Test
    @EnableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_SMARTSPACE_LAYOUT)
    fun dateWeatherBelowLargeClock_variousFontAndDisplaySize_false() =
        testScope.runTest {
            kosmos.shadeRepository.setShadeLayoutWide(false)
        kosmos.runTest {
            enableSingleShade()
            mockConfiguration.fontScale = 1.0f
            mockConfiguration.screenWidthDp = 310
            val result1 by collectLastValue(underTest.shouldDateWeatherBeBelowLargeClock)
@@ -353,10 +332,10 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase()
    @Test
    @EnableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_SMARTSPACE_LAYOUT)
    fun dateWeatherBelowSmallClock_numberOverlapClock_variousFontAndDisplaySize_true() =
        testScope.runTest {
        kosmos.runTest {
            config = ClockConfig("DIGITAL_CLOCK_NUMBEROVERLAP", "Test", "")
            kosmos.fakeKeyguardClockRepository.setCurrentClock(clockController)
            kosmos.shadeRepository.setShadeLayoutWide(false)
            fakeKeyguardClockRepository.setCurrentClock(clockController)
            enableSingleShade()
            mockConfiguration.fontScale = 0.85f
            mockConfiguration.screenWidthDp = 376
            val result3 by collectLastValue(underTest.shouldDateWeatherBeBelowSmallClock)
@@ -366,9 +345,9 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase()
    @Test
    @EnableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_SMARTSPACE_LAYOUT)
    fun dateWeatherBelowLargeClock_metroClock_variousFontAndDisplaySize_false() =
        testScope.runTest {
        kosmos.runTest {
            config = ClockConfig("DIGITAL_CLOCK_METRO", "Test", "")
            kosmos.fakeKeyguardClockRepository.setCurrentClock(clockController)
            fakeKeyguardClockRepository.setCurrentClock(clockController)
            mockConfiguration.fontScale = 0.85f
            mockConfiguration.screenWidthDp = 375
            val result3 by collectLastValue(underTest.shouldDateWeatherBeBelowLargeClock)
@@ -378,8 +357,8 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase()
    @Test
    @EnableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_SMARTSPACE_LAYOUT)
    fun dateWeatherBelowSmallClock_variousFontAndDisplaySize_shadeLayoutNotWide_false() =
        testScope.runTest {
            kosmos.shadeRepository.setShadeLayoutWide(false)
        kosmos.runTest {
            enableSingleShade()
            mockConfiguration.fontScale = 1.0f
            mockConfiguration.screenWidthDp = 347
            val result1 by collectLastValue(underTest.shouldDateWeatherBeBelowSmallClock)
@@ -399,8 +378,8 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase()
    @Test
    @EnableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_SMARTSPACE_LAYOUT)
    fun dateWeatherBelowSmallClock_variousFontAndDisplaySize_shadeLayoutWide_false() =
        testScope.runTest {
            kosmos.shadeRepository.setShadeLayoutWide(true)
        kosmos.runTest {
            enableSplitShade()
            mockConfiguration.fontScale = 1.0f
            mockConfiguration.screenWidthDp = 694
            val result1 by collectLastValue(underTest.shouldDateWeatherBeBelowSmallClock)
@@ -420,8 +399,8 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase()
    @Test
    @EnableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_SMARTSPACE_LAYOUT)
    fun dateWeatherBelowSmallClock_variousFontAndDisplaySize_shadeLayoutNotWide_true() =
        testScope.runTest {
            kosmos.shadeRepository.setShadeLayoutWide(false)
        kosmos.runTest {
            enableSingleShade()
            mockConfiguration.fontScale = 1.0f
            mockConfiguration.screenWidthDp = 310
            val result1 by collectLastValue(underTest.shouldDateWeatherBeBelowSmallClock)
@@ -441,8 +420,8 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase()
    @Test
    @EnableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_SMARTSPACE_LAYOUT)
    fun dateWeatherBelowSmallClock_variousFontAndDisplaySize_shadeLayoutWide_true() =
        testScope.runTest {
            kosmos.shadeRepository.setShadeLayoutWide(true)
        kosmos.runTest {
            enableSplitShade()
            mockConfiguration.fontScale = 1.0f
            mockConfiguration.screenWidthDp = 620
            val result1 by collectLastValue(underTest.shouldDateWeatherBeBelowSmallClock)