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

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

Merge "[flexiglass] Rename isShadeLayoutWide and flip its meaning." into main

parents 1e3847a7 886c6ba5
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -104,10 +104,8 @@ constructor(
                media = {
                    with(mediaCarouselElement) {
                        KeyguardMediaCarousel(
                            isShadeLayoutWide = viewModel.isShadeLayoutWide,
                            onBottomChanged = { bottom ->
                                viewModel.setMediaPlayerBottom(bottom = bottom)
                            },
                            isFullWidthShade = viewModel.isFullWidthShade,
                            onBottomChanged = viewModel::setMediaPlayerBottom,
                        )
                    }
                },
@@ -125,7 +123,7 @@ constructor(
                        Shortcut(
                            isStart = true,
                            applyPadding = false,
                            onTopChanged = { top -> viewModel.setShortcutTop(top) },
                            onTopChanged = viewModel::setShortcutTop,
                        )
                    }
                },
@@ -146,7 +144,7 @@ constructor(
                        Shortcut(
                            isStart = false,
                            applyPadding = false,
                            onTopChanged = { top -> viewModel.setShortcutTop(top) },
                            onTopChanged = viewModel::setShortcutTop,
                        )
                    }
                },
+4 −4
Original line number Diff line number Diff line
@@ -48,16 +48,16 @@ constructor(

    @Composable
    fun ContentScope.KeyguardMediaCarousel(
        isShadeLayoutWide: Boolean,
        isFullWidthShade: Boolean,
        modifier: Modifier = Modifier,
        onBottomChanged: ((Float) -> Unit)? = null,
    ) {
        val horizontalPadding =
            if (isShadeLayoutWide) {
                dimensionResource(id = R.dimen.notification_side_paddings)
            } else {
            if (isFullWidthShade) {
                dimensionResource(id = R.dimen.notification_side_paddings) +
                    dimensionResource(id = R.dimen.notification_panel_margin_horizontal)
            } else {
                dimensionResource(id = R.dimen.notification_side_paddings)
            }
        if (mediaControlsInCompose()) {
            val viewModel =
+3 −3
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ class SmartspaceSectionTest : SysuiTestCase() {
    private val shouldDateWeatherBeBelowSmallClock = MutableStateFlow(true)
    private val shouldDateWeatherBeBelowLargeClock = MutableStateFlow(true)
    private val isWeatherVisibleFlow = MutableStateFlow(false)
    private val isShadeLayoutWide = MutableStateFlow(false)
    private val isFullWidthShade = MutableStateFlow(true)
    private val isLargeClockVisible = MutableStateFlow(true)

    @Before
@@ -106,7 +106,7 @@ class SmartspaceSectionTest : SysuiTestCase() {
        whenever(keyguardClockViewModel.clockShouldBeCentered).thenReturn(clockShouldBeCentered)
        whenever(keyguardSmartspaceViewModel.isSmartspaceEnabled).thenReturn(true)
        whenever(keyguardSmartspaceViewModel.isWeatherVisible).thenReturn(isWeatherVisibleFlow)
        whenever(keyguardSmartspaceViewModel.isShadeLayoutWide).thenReturn(isShadeLayoutWide)
        whenever(keyguardSmartspaceViewModel.isFullWidthShade).thenReturn(isFullWidthShade)
        constraintSet = ConstraintSet()
    }

@@ -154,7 +154,7 @@ class SmartspaceSectionTest : SysuiTestCase() {
    @Test
    @DisableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_SMARTSPACE_LAYOUT)
    fun testConstraintsWhenShadeLayoutIsWide() {
        isShadeLayoutWide.value = true
        isFullWidthShade.value = false

        underTest.addViews(constraintLayout)
        underTest.applyConstraints(constraintSet)
+42 −65
Original line number Diff line number Diff line
@@ -24,7 +24,8 @@ import com.android.systemui.keyguard.data.repository.fakeKeyguardClockRepository
import com.android.systemui.keyguard.data.repository.keyguardClockRepository
import com.android.systemui.keyguard.data.repository.keyguardSmartspaceRepository
import com.android.systemui.keyguard.shared.model.ClockSize
import com.android.systemui.kosmos.testScope
import com.android.systemui.kosmos.collectLastValue
import com.android.systemui.kosmos.runTest
import com.android.systemui.plugins.clocks.ClockController
import com.android.systemui.shade.data.repository.shadeRepository
import com.android.systemui.testKosmos
@@ -41,9 +42,9 @@ import org.mockito.MockitoAnnotations
@SmallTest
@RunWith(AndroidJUnit4::class)
class KeyguardSmartspaceViewModelTest : SysuiTestCase() {
    val kosmos = testKosmos()
    val testScope = kosmos.testScope
    val underTest = kosmos.keyguardSmartspaceViewModel

    private val kosmos = testKosmos()
    private val underTest = kosmos.keyguardSmartspaceViewModel

    @Mock(answer = Answers.RETURNS_DEEP_STUBS) private lateinit var clockController: ClockController

@@ -55,152 +56,128 @@ class KeyguardSmartspaceViewModelTest : SysuiTestCase() {

    @Test
    fun testWhenWeatherEnabled_notCustomWeatherDataDisplay_isWeatherVisible_shouldBeTrue() =
        testScope.runTest {
        kosmos.runTest {
            val isWeatherVisible by collectLastValue(underTest.isWeatherVisible)
            whenever(clockController.largeClock.config.hasCustomWeatherDataDisplay)
                .thenReturn(false)

            with(kosmos) {
            keyguardSmartspaceRepository.setIsWeatherEnabled(true)
            keyguardClockRepository.setClockSize(ClockSize.LARGE)
            }

            assertThat(isWeatherVisible).isEqualTo(true)
        }

    @Test
    fun testWhenWeatherEnabled_notCustomWeatherDataDisplay_isWeatherVisible_smallClock_shouldBeTrue() =
        testScope.runTest {
        kosmos.runTest {
            val isWeatherVisible by collectLastValue(underTest.isWeatherVisible)
            whenever(clockController.smallClock.config.hasCustomWeatherDataDisplay)
                .thenReturn(false)

            with(kosmos) {
            keyguardSmartspaceRepository.setIsWeatherEnabled(true)
            keyguardClockRepository.setClockSize(ClockSize.SMALL)
            }

            assertThat(isWeatherVisible).isEqualTo(true)
        }

    @Test
    fun testWhenWeatherEnabled_hasCustomWeatherDataDisplay_isWeatherVisible_shouldBeFalse() =
        testScope.runTest {
        kosmos.runTest {
            val isWeatherVisible by collectLastValue(underTest.isWeatherVisible)
            whenever(clockController.largeClock.config.hasCustomWeatherDataDisplay).thenReturn(true)

            with(kosmos) {
            keyguardSmartspaceRepository.setIsWeatherEnabled(true)
            keyguardClockRepository.setClockSize(ClockSize.LARGE)
            }

            assertThat(isWeatherVisible).isEqualTo(false)
        }

    @Test
    fun testWhenWeatherEnabled_hasCustomWeatherDataDisplay_isWeatherVisible_smallClock_shouldBeTrue() =
        testScope.runTest {
        kosmos.runTest {
            val isWeatherVisible by collectLastValue(underTest.isWeatherVisible)
            whenever(clockController.smallClock.config.hasCustomWeatherDataDisplay).thenReturn(true)

            with(kosmos) {
            keyguardSmartspaceRepository.setIsWeatherEnabled(true)
            keyguardClockRepository.setClockSize(ClockSize.SMALL)
            }

            assertThat(isWeatherVisible).isEqualTo(true)
        }

    @Test
    fun testWhenWeatherEnabled_notCustomWeatherDataDisplay_notIsWeatherVisible_shouldBeFalse() =
        testScope.runTest {
        kosmos.runTest {
            val isWeatherVisible by collectLastValue(underTest.isWeatherVisible)
            whenever(clockController.largeClock.config.hasCustomWeatherDataDisplay)
                .thenReturn(false)

            with(kosmos) {
            keyguardSmartspaceRepository.setIsWeatherEnabled(false)
            keyguardClockRepository.setClockSize(ClockSize.LARGE)
            }

            assertThat(isWeatherVisible).isEqualTo(false)
        }

    @Test
    fun isDateVisible_notCustomWeatherDataDisplay_largeClock_shouldBeTrue() =
        testScope.runTest {
        kosmos.runTest {
            val isDateVisible by collectLastValue(underTest.isDateVisible)
            whenever(clockController.largeClock.config.hasCustomWeatherDataDisplay)
                .thenReturn(false)

            with(kosmos) {
            keyguardClockRepository.setClockSize(ClockSize.LARGE)
            }

            assertThat(isDateVisible).isEqualTo(true)
        }

    @Test
    fun isDateVisible_hasCustomWeatherDataDisplay_largeClock_shouldBeFalse() =
        testScope.runTest {
        kosmos.runTest {
            val isDateVisible by collectLastValue(underTest.isDateVisible)
            whenever(clockController.largeClock.config.hasCustomWeatherDataDisplay)
                .thenReturn(true)
            whenever(clockController.largeClock.config.hasCustomWeatherDataDisplay).thenReturn(true)

            with(kosmos) {
            keyguardClockRepository.setClockSize(ClockSize.LARGE)
            }

            assertThat(isDateVisible).isEqualTo(false)
        }

    @Test
    fun isDateVisible_hasCustomWeatherDataDisplay_smallClock_shouldBeTrue() =
        testScope.runTest {
        kosmos.runTest {
            val isDateVisible by collectLastValue(underTest.isDateVisible)
            whenever(clockController.smallClock.config.hasCustomWeatherDataDisplay)
                .thenReturn(true)
            whenever(clockController.smallClock.config.hasCustomWeatherDataDisplay).thenReturn(true)

            with(kosmos) {
            keyguardClockRepository.setClockSize(ClockSize.SMALL)
            }

            assertThat(isDateVisible).isEqualTo(true)
        }

    @Test
    fun isDateVisible_notCustomWeatherDataDisplay_smallClock_shouldBeTrue() =
        testScope.runTest {
        kosmos.runTest {
            val isDateVisible by collectLastValue(underTest.isDateVisible)
            whenever(clockController.smallClock.config.hasCustomWeatherDataDisplay)
                .thenReturn(false)

            with(kosmos) {
            keyguardClockRepository.setClockSize(ClockSize.SMALL)
            }

            assertThat(isDateVisible).isEqualTo(true)
        }

    @Test
    fun isShadeLayoutWide_withConfigTrue_true() =
        with(kosmos) {
            testScope.runTest {
                val isShadeLayoutWide by collectLastValue(underTest.isShadeLayoutWide)
    fun isFullWidthShade_withConfigTrue_false() =
        kosmos.runTest {
            val isFullWidthShade by collectLastValue(underTest.isFullWidthShade)
            shadeRepository.setShadeLayoutWide(true)

                assertThat(isShadeLayoutWide).isTrue()
            }
            assertThat(isFullWidthShade).isFalse()
        }

    @Test
    fun isShadeLayoutWide_withConfigFalse_false() =
        with(kosmos) {
            testScope.runTest {
                val isShadeLayoutWide by collectLastValue(underTest.isShadeLayoutWide)
    fun isFullWidthShade_withConfigFalse_true() =
        kosmos.runTest {
            val isFullWidthShade by collectLastValue(underTest.isFullWidthShade)
            shadeRepository.setShadeLayoutWide(false)

                assertThat(isShadeLayoutWide).isFalse()
            }
            assertThat(isFullWidthShade).isTrue()
        }
}
+2 −2
Original line number Diff line number Diff line
@@ -217,7 +217,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() {
        }

    @Test
    fun qsFullscreen_dualShadeWide_falseWhenIdleQs() =
    fun qsFullscreen_dualShadeWide_trueWhenIdleQs() =
        kosmos.runTest {
            enableDualShade(wideLayout = true)
            val actual by collectLastValue(underTest.isQsFullscreen)
@@ -234,7 +234,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() {
            )

            // THEN QS is fullscreen
            assertThat(actual).isFalse()
            assertThat(actual).isTrue()
        }

    @Test
Loading