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

Commit cd7fa8f4 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[flexiglass] Replace ShadeRepository.isShadeLayoutWide with two flows." into main

parents 138d5e8c d0de5b3e
Loading
Loading
Loading
Loading
+134 −155
Original line number Diff line number Diff line
@@ -38,6 +38,8 @@ import com.android.systemui.keyguard.ui.viewmodel.keyguardClockViewModel
import com.android.systemui.keyguard.ui.viewmodel.keyguardRootViewModel
import com.android.systemui.keyguard.ui.viewmodel.keyguardSmartspaceViewModel
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.collectLastValue
import com.android.systemui.kosmos.runTest
import com.android.systemui.kosmos.testScope
import com.android.systemui.plugins.clocks.ClockViewIds
import com.android.systemui.res.R
@@ -48,6 +50,7 @@ import com.android.systemui.statusbar.policy.fakeConfigurationController
import com.android.systemui.statusbar.ui.fakeSystemBarUtilsProxy
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.advanceUntilIdle
import kotlinx.coroutines.test.runTest
import org.junit.Before
@@ -56,6 +59,7 @@ import org.junit.runner.RunWith
import org.mockito.MockitoAnnotations
import org.mockito.kotlin.mock

@OptIn(ExperimentalCoroutinesApi::class)
@RunWith(AndroidJUnit4::class)
@SmallTest
@DisableSceneContainer
@@ -95,9 +99,6 @@ class ClockSectionTest : SysuiTestCase() {
                ENHANCED_SMART_SPACE_HEIGHT
        }

    private val CLOCK_FADE_TRANSLATION_Y: Int
        get() = resources.getDimensionPixelSize(clocksR.dimen.small_clock_height)

    private lateinit var kosmos: Kosmos

    @Before
@@ -123,12 +124,10 @@ class ClockSectionTest : SysuiTestCase() {
    @Test
    @DisableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_SMARTSPACE_LAYOUT)
    fun testApplyDefaultConstraints_LargeClock_SplitShade() =
        kosmos.testScope.runTest {
            with(kosmos) {
        kosmos.runTest {
            shadeRepository.setShadeLayoutWide(true)
            keyguardClockInteractor.setClockSize(ClockSize.LARGE)
                advanceUntilIdle()
            }
            testScope.advanceUntilIdle()

            val cs = ConstraintSet()
            underTest.applyDefaultConstraints(cs)
@@ -140,12 +139,10 @@ class ClockSectionTest : SysuiTestCase() {
    @Test
    @EnableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_SMARTSPACE_LAYOUT)
    fun testApplyDefaultConstraints_LargeClock_SplitShade_ReactiveVariantsOn() =
        kosmos.testScope.runTest {
            with(kosmos) {
        kosmos.runTest {
            shadeRepository.setShadeLayoutWide(true)
            keyguardClockInteractor.setClockSize(ClockSize.LARGE)
                advanceUntilIdle()
            }
            testScope.advanceUntilIdle()

            val cs = ConstraintSet()
            underTest.applyDefaultConstraints(cs)
@@ -159,18 +156,17 @@ class ClockSectionTest : SysuiTestCase() {
    @Test
    @DisableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_SMARTSPACE_LAYOUT)
    fun testApplyDefaultConstraints_LargeClock_NonSplitShade() =
        kosmos.testScope.runTest {
            with(kosmos) {
                val isShadeLayoutWide by collectLastValue(shadeRepository.isShadeLayoutWide)
                val isLargeClockVisible by
                    collectLastValue(keyguardClockViewModel.isLargeClockVisible)
        kosmos.runTest {
            val isWideScreen by collectLastValue(shadeRepository.isWideScreen)
            val legacyUseSplitShade by collectLastValue(shadeRepository.legacyUseSplitShade)
            val isLargeClockVisible by collectLastValue(keyguardClockViewModel.isLargeClockVisible)

            shadeRepository.setShadeLayoutWide(false)
            keyguardClockInteractor.setClockSize(ClockSize.LARGE)
            notificationsKeyguardInteractor.setNotificationsFullyHidden(true)
            keyguardSmartspaceInteractor.setBcSmartspaceVisibility(VISIBLE)
            fakeConfigurationController.notifyConfigurationChanged()
                advanceUntilIdle()
            testScope.advanceUntilIdle()

            val cs = ConstraintSet()
            underTest.applyDefaultConstraints(cs)
@@ -178,23 +174,21 @@ class ClockSectionTest : SysuiTestCase() {
            cs.assertLargeClock(topMargin = LARGE_CLOCK_TOP)
            cs.assertSmallClock()
        }
        }

    @Test
    @EnableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_SMARTSPACE_LAYOUT)
    fun testApplyDefaultConstraints_LargeClock_NonSplitShade_reactiveVariantsOn() =
        kosmos.testScope.runTest {
            with(kosmos) {
                val isShadeLayoutWide by collectLastValue(shadeRepository.isShadeLayoutWide)
                val isLargeClockVisible by
                    collectLastValue(keyguardClockViewModel.isLargeClockVisible)
        kosmos.runTest {
            val isWideScreen by collectLastValue(shadeRepository.isWideScreen)
            val legacyUseSplitShade by collectLastValue(shadeRepository.legacyUseSplitShade)
            val isLargeClockVisible by collectLastValue(keyguardClockViewModel.isLargeClockVisible)

            shadeRepository.setShadeLayoutWide(false)
            keyguardClockInteractor.setClockSize(ClockSize.LARGE)
            notificationsKeyguardInteractor.setNotificationsFullyHidden(true)
            keyguardSmartspaceInteractor.setBcSmartspaceVisibility(VISIBLE)
            fakeConfigurationController.notifyConfigurationChanged()
                advanceUntilIdle()
            testScope.advanceUntilIdle()

            val cs = ConstraintSet()
            underTest.applyDefaultConstraints(cs)
@@ -204,23 +198,21 @@ class ClockSectionTest : SysuiTestCase() {
            )
            cs.assertSmallClock()
        }
        }

    @Test
    @DisableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_SMARTSPACE_LAYOUT)
    fun testApplyDefaultConstraints_SmallClock_SplitShade() =
        kosmos.testScope.runTest {
            with(kosmos) {
                val isShadeLayoutWide by collectLastValue(shadeRepository.isShadeLayoutWide)
                val isLargeClockVisible by
                    collectLastValue(keyguardClockViewModel.isLargeClockVisible)
        kosmos.runTest {
            val isWideScreen by collectLastValue(shadeRepository.isWideScreen)
            val legacyUseSplitShade by collectLastValue(shadeRepository.legacyUseSplitShade)
            val isLargeClockVisible by collectLastValue(keyguardClockViewModel.isLargeClockVisible)

            shadeRepository.setShadeLayoutWide(true)
            keyguardClockInteractor.setClockSize(ClockSize.SMALL)
            notificationsKeyguardInteractor.setNotificationsFullyHidden(true)
            keyguardSmartspaceInteractor.setBcSmartspaceVisibility(VISIBLE)
            fakeConfigurationController.notifyConfigurationChanged()
                advanceUntilIdle()
            testScope.advanceUntilIdle()

            val cs = ConstraintSet()
            underTest.applyDefaultConstraints(cs)
@@ -228,23 +220,21 @@ class ClockSectionTest : SysuiTestCase() {
            cs.assertLargeClock(topMargin = LARGE_CLOCK_TOP)
            cs.assertSmallClock()
        }
        }

    @Test
    @EnableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_SMARTSPACE_LAYOUT)
    fun testApplyDefaultConstraints_SmallClock_SplitShade_ReactiveVariantsOn() =
        kosmos.testScope.runTest {
            with(kosmos) {
                val isShadeLayoutWide by collectLastValue(shadeRepository.isShadeLayoutWide)
                val isLargeClockVisible by
                    collectLastValue(keyguardClockViewModel.isLargeClockVisible)
        kosmos.runTest {
            val isWideScreen by collectLastValue(shadeRepository.isWideScreen)
            val legacyUseSplitShade by collectLastValue(shadeRepository.legacyUseSplitShade)
            val isLargeClockVisible by collectLastValue(keyguardClockViewModel.isLargeClockVisible)

            shadeRepository.setShadeLayoutWide(true)
            keyguardClockInteractor.setClockSize(ClockSize.SMALL)
            notificationsKeyguardInteractor.setNotificationsFullyHidden(true)
            keyguardSmartspaceInteractor.setBcSmartspaceVisibility(VISIBLE)
            fakeConfigurationController.notifyConfigurationChanged()
                advanceUntilIdle()
            testScope.advanceUntilIdle()

            val cs = ConstraintSet()
            underTest.applyDefaultConstraints(cs)
@@ -254,23 +244,21 @@ class ClockSectionTest : SysuiTestCase() {
            )
            cs.assertSmallClock()
        }
        }

    @Test
    @DisableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_SMARTSPACE_LAYOUT)
    fun testApplyDefaultConstraints_SmallClock_NonSplitShade() =
        kosmos.testScope.runTest {
            with(kosmos) {
                val isShadeLayoutWide by collectLastValue(shadeRepository.isShadeLayoutWide)
                val isLargeClockVisible by
                    collectLastValue(keyguardClockViewModel.isLargeClockVisible)
        kosmos.runTest {
            val isWideScreen by collectLastValue(shadeRepository.isWideScreen)
            val legacyUseSplitShade by collectLastValue(shadeRepository.legacyUseSplitShade)
            val isLargeClockVisible by collectLastValue(keyguardClockViewModel.isLargeClockVisible)

            shadeRepository.setShadeLayoutWide(false)
            keyguardClockInteractor.setClockSize(ClockSize.SMALL)
            notificationsKeyguardInteractor.setNotificationsFullyHidden(true)
            keyguardSmartspaceInteractor.setBcSmartspaceVisibility(VISIBLE)
            fakeConfigurationController.notifyConfigurationChanged()
                advanceUntilIdle()
            testScope.advanceUntilIdle()

            val cs = ConstraintSet()
            underTest.applyDefaultConstraints(cs)
@@ -278,23 +266,21 @@ class ClockSectionTest : SysuiTestCase() {
            cs.assertLargeClock(topMargin = LARGE_CLOCK_TOP)
            cs.assertSmallClock()
        }
        }

    @Test
    @EnableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_SMARTSPACE_LAYOUT)
    fun testApplyDefaultConstraints_SmallClock_NonSplitShade_ReactiveVariantsOn() =
        kosmos.testScope.runTest {
            with(kosmos) {
                val isShadeLayoutWide by collectLastValue(shadeRepository.isShadeLayoutWide)
                val isLargeClockVisible by
                    collectLastValue(keyguardClockViewModel.isLargeClockVisible)
        kosmos.runTest {
            val isWideScreen by collectLastValue(shadeRepository.isWideScreen)
            val legacyUseSplitShade by collectLastValue(shadeRepository.legacyUseSplitShade)
            val isLargeClockVisible by collectLastValue(keyguardClockViewModel.isLargeClockVisible)

            shadeRepository.setShadeLayoutWide(false)
            keyguardClockInteractor.setClockSize(ClockSize.SMALL)
            notificationsKeyguardInteractor.setNotificationsFullyHidden(true)
            keyguardSmartspaceInteractor.setBcSmartspaceVisibility(VISIBLE)
            fakeConfigurationController.notifyConfigurationChanged()
                advanceUntilIdle()
            testScope.advanceUntilIdle()

            val cs = ConstraintSet()
            underTest.applyDefaultConstraints(cs)
@@ -304,17 +290,14 @@ class ClockSectionTest : SysuiTestCase() {
            )
            cs.assertSmallClock()
        }
        }

    @Test
    fun testSmartspaceVisible_weatherClockDateAndIconsBarrierBottomBelowBCSmartspace() =
        kosmos.testScope.runTest {
            with(kosmos) {
        kosmos.runTest {
            notificationsKeyguardInteractor.setNotificationsFullyHidden(false)
            keyguardSmartspaceInteractor.setBcSmartspaceVisibility(VISIBLE)
            fakeConfigurationController.notifyConfigurationChanged()
                advanceUntilIdle()
            }
            testScope.advanceUntilIdle()

            val cs = ConstraintSet()
            underTest.applyDefaultConstraints(cs)
@@ -326,13 +309,11 @@ class ClockSectionTest : SysuiTestCase() {

    @Test
    fun testSmartspaceGone_weatherClockDateAndIconsBarrierBottomBelowSmartspaceDateWeather() =
        kosmos.testScope.runTest {
            with(kosmos) {
        kosmos.runTest {
            notificationsKeyguardInteractor.setNotificationsFullyHidden(false)
            keyguardSmartspaceInteractor.setBcSmartspaceVisibility(GONE)
            fakeConfigurationController.notifyConfigurationChanged()
                advanceUntilIdle()
            }
            testScope.advanceUntilIdle()

            val cs = ConstraintSet()
            underTest.applyDefaultConstraints(cs)
@@ -342,12 +323,10 @@ class ClockSectionTest : SysuiTestCase() {

    @Test
    fun testHasAodIcons_weatherClockDateAndIconsBarrierBottomBelowSmartspaceDateWeather() =
        kosmos.testScope.runTest {
            with(kosmos) {
        kosmos.runTest {
            notificationsKeyguardInteractor.setNotificationsFullyHidden(true)
            fakeConfigurationController.notifyConfigurationChanged()
                advanceUntilIdle()
            }
            testScope.advanceUntilIdle()

            val cs = ConstraintSet()
            underTest.applyDefaultConstraints(cs)
+2 −1
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ 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.useUnconfinedTestDispatcher
import com.android.systemui.plugins.clocks.ClockConfig
import com.android.systemui.plugins.clocks.ClockController
import com.android.systemui.plugins.clocks.ClockFaceConfig
@@ -59,7 +60,7 @@ import platform.test.runner.parameterized.Parameters
@RunWith(ParameterizedAndroidJunit4::class)
class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase() {

    private val kosmos = testKosmos()
    private val kosmos = testKosmos().useUnconfinedTestDispatcher()
    private val testScope = kosmos.testScope
    private val underTest by lazy { kosmos.keyguardClockViewModel }
    private val res = context.resources
+4 −2
Original line number Diff line number Diff line
@@ -293,7 +293,8 @@ class LockscreenContentViewModelTest(flags: FlagsParameterization) : SysuiTestCa
        hasNotifications: Boolean = false,
        shadeLayoutWide: Boolean? = null,
    ) {
        val isShadeLayoutWide by collectLastValue(shadeRepository.isShadeLayoutWide)
        val isWideScreen by collectLastValue(shadeRepository.isWideScreen)
        val legacyUseSplitShade by collectLastValue(shadeRepository.legacyUseSplitShade)
        val collectedClockSize by collectLastValue(keyguardClockInteractor.clockSize)
        val collectedShadeMode by collectLastValue(shadeModeInteractor.shadeMode)
        val areAnyNotificationsPresent by
@@ -320,7 +321,8 @@ class LockscreenContentViewModelTest(flags: FlagsParameterization) : SysuiTestCa
                .build()
        runCurrent()
        if (shadeLayoutWide != null) {
            assertThat(isShadeLayoutWide).isEqualTo(shadeLayoutWide)
            assertThat(isWideScreen).isEqualTo(shadeLayoutWide)
            assertThat(legacyUseSplitShade).isEqualTo(shadeLayoutWide)
        }
        assertThat(collectedShadeMode).isEqualTo(shadeMode)
        assertThat(collectedClockSize).isEqualTo(clockSize)
+15 −11
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.test.StandardTestDispatcher
import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.runTest
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith

@@ -35,12 +34,7 @@ class ShadeRepositoryImplTest : SysuiTestCase() {
    private val testDispatcher = StandardTestDispatcher()
    private val testScope = TestScope(testDispatcher)

    private lateinit var underTest: ShadeRepositoryImpl

    @Before
    fun setUp() {
        underTest = ShadeRepositoryImpl(testScope)
    }
    private val underTest by lazy { ShadeRepositoryImpl(testScope) }

    @Test
    fun updateQsExpansion() =
@@ -175,12 +169,22 @@ class ShadeRepositoryImplTest : SysuiTestCase() {
        }

    @Test
    fun isShadeLayoutWide() =
    fun updateLegacyUseSplitShade() =
        testScope.runTest {
            val legacyUseSplitShade by collectLastValue(underTest.legacyUseSplitShade)
            assertThat(legacyUseSplitShade).isFalse()

            underTest.setShadeLayoutWide(true)
            assertThat(legacyUseSplitShade).isTrue()
        }

    @Test
    fun updateIsWideScreen() =
        testScope.runTest {
            val isShadeLayoutWide by collectLastValue(underTest.isShadeLayoutWide)
            assertThat(isShadeLayoutWide).isFalse()
            val isWideScreen by collectLastValue(underTest.isWideScreen)
            assertThat(isWideScreen).isFalse()

            underTest.setShadeLayoutWide(true)
            assertThat(isShadeLayoutWide).isTrue()
            assertThat(isWideScreen).isTrue()
        }
}
+16 −8
Original line number Diff line number Diff line
@@ -225,52 +225,60 @@ class ShadeStartableTest(flags: FlagsParameterization) : SysuiTestCase() {
    @EnableSceneContainer
    fun hydrateFullWidth_singleShade() =
        kosmos.runTest {
            val isShadeLayoutWide by collectLastValue(shadeRepository.isShadeLayoutWide)
            val isWideScreen by collectLastValue(shadeRepository.isWideScreen)
            val legacyUseSplitShade by collectLastValue(shadeRepository.legacyUseSplitShade)
            enableSingleShade()
            underTest.start()

            verify(notificationStackScrollLayoutController).setIsFullWidth(true)
            assertThat(scrimController.clipQsScrim).isFalse()
            assertThat(isShadeLayoutWide).isFalse()
            assertThat(isWideScreen).isFalse()
            assertThat(legacyUseSplitShade).isFalse()
        }

    @Test
    @EnableSceneContainer
    fun hydrateFullWidth_splitShade() =
        kosmos.runTest {
            val isShadeLayoutWide by collectLastValue(shadeRepository.isShadeLayoutWide)
            val isWideScreen by collectLastValue(shadeRepository.isWideScreen)
            val legacyUseSplitShade by collectLastValue(shadeRepository.legacyUseSplitShade)
            enableSplitShade()
            underTest.start()

            verify(notificationStackScrollLayoutController).setIsFullWidth(false)
            assertThat(scrimController.clipQsScrim).isFalse()
            assertThat(isShadeLayoutWide).isTrue()
            assertThat(isWideScreen).isTrue()
            assertThat(legacyUseSplitShade).isTrue()
        }

    @Test
    @EnableSceneContainer
    fun hydrateFullWidth_dualShade_narrowScreen() =
        kosmos.runTest {
            val isShadeLayoutWide by collectLastValue(shadeRepository.isShadeLayoutWide)
            val isWideScreen by collectLastValue(shadeRepository.isWideScreen)
            val legacyUseSplitShade by collectLastValue(shadeRepository.legacyUseSplitShade)
            enableDualShade(wideLayout = false)
            underTest.start()

            verify(notificationStackScrollLayoutController).setIsFullWidth(true)
            assertThat(scrimController.clipQsScrim).isFalse()
            assertThat(isShadeLayoutWide).isFalse()
            assertThat(isWideScreen).isFalse()
            assertThat(legacyUseSplitShade).isFalse()
        }

    @Test
    @EnableSceneContainer
    fun hydrateFullWidth_dualShade_wideScreen() =
        kosmos.runTest {
            val isShadeLayoutWide by collectLastValue(shadeRepository.isShadeLayoutWide)
            val isWideScreen by collectLastValue(shadeRepository.isWideScreen)
            val legacyUseSplitShade by collectLastValue(shadeRepository.legacyUseSplitShade)
            enableDualShade(wideLayout = true)
            underTest.start()

            verify(notificationStackScrollLayoutController).setIsFullWidth(false)
            assertThat(scrimController.clipQsScrim).isFalse()
            assertThat(isShadeLayoutWide).isTrue()
            assertThat(isWideScreen).isTrue()
            assertThat(legacyUseSplitShade).isFalse()
        }

    @Test
Loading