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

Commit 3836719d authored by Lucas Silva's avatar Lucas Silva Committed by Android (Google) Code Review
Browse files

Merge changes I2928567e,I81171f04 into main

* changes:
  Add transition for glanceble hub -> dream
  Handle dream->glanceable_hub transitions
parents 966fffd3 b0fa886b
Loading
Loading
Loading
Loading
+0 −26
Original line number Diff line number Diff line
@@ -92,25 +92,6 @@ class CommunalSceneStartableTest : SysuiTestCase() {
            }
        }

    @Test
    fun deviceDreaming_forceBlankScene() =
        with(kosmos) {
            testScope.runTest {
                val scene by collectLastValue(communalInteractor.desiredScene)

                communalInteractor.onSceneChanged(CommunalSceneKey.Communal)
                assertThat(scene).isEqualTo(CommunalSceneKey.Communal)

                fakeKeyguardTransitionRepository.sendTransitionSteps(
                    from = KeyguardState.GLANCEABLE_HUB,
                    to = KeyguardState.DREAMING,
                    testScope = this
                )

                assertThat(scene).isEqualTo(CommunalSceneKey.Blank)
            }
        }

    @Test
    fun deviceDocked_forceCommunalScene() =
        with(kosmos) {
@@ -125,13 +106,6 @@ class CommunalSceneStartableTest : SysuiTestCase() {
                    testScope = this
                )
                assertThat(scene).isEqualTo(CommunalSceneKey.Communal)

                fakeKeyguardTransitionRepository.sendTransitionSteps(
                    from = KeyguardState.GLANCEABLE_HUB,
                    to = KeyguardState.DREAMING,
                    testScope = this
                )
                assertThat(scene).isEqualTo(CommunalSceneKey.Blank)
            }
        }

+0 −3
Original line number Diff line number Diff line
@@ -11,7 +11,6 @@ import com.android.systemui.complication.ComplicationHostViewController
import com.android.systemui.dreams.ui.viewmodel.DreamOverlayViewModel
import com.android.systemui.log.core.FakeLogBuffer
import com.android.systemui.statusbar.BlurUtils
import com.android.systemui.statusbar.policy.ConfigurationController
import com.android.systemui.util.mockito.argumentCaptor
import com.android.systemui.util.mockito.mock
import com.android.systemui.util.mockito.whenever
@@ -46,7 +45,6 @@ class DreamOverlayAnimationsControllerTest : SysuiTestCase() {
    @Mock private lateinit var hostViewController: ComplicationHostViewController
    @Mock private lateinit var statusBarViewController: DreamOverlayStatusBarViewController
    @Mock private lateinit var stateController: DreamOverlayStateController
    @Mock private lateinit var configController: ConfigurationController
    @Mock private lateinit var transitionViewModel: DreamOverlayViewModel
    private val logBuffer = FakeLogBuffer.Factory.create()
    private lateinit var controller: DreamOverlayAnimationsController
@@ -62,7 +60,6 @@ class DreamOverlayAnimationsControllerTest : SysuiTestCase() {
                stateController,
                DREAM_BLUR_RADIUS,
                transitionViewModel,
                configController,
                DREAM_IN_BLUR_ANIMATION_DURATION,
                DREAM_IN_COMPLICATIONS_ANIMATION_DURATION,
                DREAM_IN_TRANSLATION_Y_DISTANCE,
+9 −1
Original line number Diff line number Diff line
@@ -19,12 +19,14 @@ package com.android.systemui.keyguard.ui.viewmodel
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.common.ui.data.repository.fakeConfigurationRepository
import com.android.systemui.coroutines.collectValues
import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.model.TransitionState
import com.android.systemui.keyguard.shared.model.TransitionStep
import com.android.systemui.kosmos.testScope
import com.android.systemui.res.R
import com.android.systemui.testKosmos
import com.google.common.collect.Range
import com.google.common.truth.Truth.assertThat
@@ -38,6 +40,7 @@ class DreamingToGlanceableHubTransitionViewModelTest : SysuiTestCase() {
    val kosmos = testKosmos()
    val testScope = kosmos.testScope

    val configurationRepository by lazy { kosmos.fakeConfigurationRepository }
    val underTest by lazy { kosmos.dreamingToGlanceableHubTransitionViewModel }

    @Test
@@ -66,7 +69,12 @@ class DreamingToGlanceableHubTransitionViewModelTest : SysuiTestCase() {
    @Test
    fun dreamOverlayTranslationX() =
        testScope.runTest {
            val values by collectValues(underTest.dreamOverlayTranslationX(100))
            configurationRepository.setDimensionPixelSize(
                R.dimen.dreaming_to_hub_transition_dream_overlay_translation_x,
                -100
            )

            val values by collectValues(underTest.dreamOverlayTranslationX)
            assertThat(values).isEmpty()

            kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps(
+105 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.keyguard.ui.viewmodel

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.common.ui.data.repository.fakeConfigurationRepository
import com.android.systemui.coroutines.collectValues
import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.model.TransitionState
import com.android.systemui.keyguard.shared.model.TransitionStep
import com.android.systemui.kosmos.testScope
import com.android.systemui.res.R
import com.android.systemui.testKosmos
import com.google.common.collect.Range
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.test.runTest
import org.junit.Test
import org.junit.runner.RunWith

@SmallTest
@RunWith(AndroidJUnit4::class)
class GlanceableHubToDreamingTransitionViewModelTest : SysuiTestCase() {
    val kosmos = testKosmos()
    val testScope = kosmos.testScope

    val configurationRepository by lazy { kosmos.fakeConfigurationRepository }
    val underTest by lazy { kosmos.glanceableHubToDreamingTransitionViewModel }

    @Test
    fun dreamOverlayAlpha() =
        testScope.runTest {
            val values by collectValues(underTest.dreamOverlayAlpha)
            assertThat(values).isEmpty()

            kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps(
                listOf(
                    step(0f, TransitionState.STARTED),
                    step(0f),
                    // Should start running here...
                    step(0.1f),
                    step(0.5f),
                    // Up to here...
                    step(1f),
                ),
                testScope,
            )

            assertThat(values).hasSize(2)
            values.forEach { assertThat(it).isIn(Range.closed(0f, 1f)) }
        }

    @Test
    fun dreamOverlayTranslationX() =
        testScope.runTest {
            configurationRepository.setDimensionPixelSize(
                R.dimen.hub_to_dreaming_transition_dream_overlay_translation_x,
                100
            )

            val values by collectValues(underTest.dreamOverlayTranslationX)
            assertThat(values).isEmpty()

            kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps(
                listOf(
                    step(0f, TransitionState.STARTED),
                    step(0.3f),
                    step(0.6f),
                ),
                testScope,
            )

            assertThat(values).hasSize(3)
            values.forEach { assertThat(it).isIn(Range.closed(-100f, 0f)) }
        }

    private fun step(
        value: Float,
        state: TransitionState = TransitionState.RUNNING
    ): TransitionStep {
        return TransitionStep(
            from = KeyguardState.GLANCEABLE_HUB,
            to = KeyguardState.DREAMING,
            value = value,
            transitionState = state,
            ownerName = GlanceableHubToDreamingTransitionViewModelTest::class.java.simpleName
        )
    }
}
+6 −1
Original line number Diff line number Diff line
@@ -1518,6 +1518,12 @@
    <!-- GLANCEABLE_HUB -> LOCKSCREEN transition: Amount to shift lockscreen content on entering -->
    <dimen name="hub_to_lockscreen_transition_lockscreen_translation_x">824dp</dimen>

    <!-- DREAMING -> GLANCEABLE_HUB transition: Amount to shift dream overlay on entering -->
    <dimen name="dreaming_to_hub_transition_dream_overlay_translation_x">-824dp</dimen>

    <!-- GLANCEABLE_HUB -> DREAMING transition: Amount to shift dream overlay on entering -->
    <dimen name="hub_to_dreaming_transition_dream_overlay_translation_x">824dp</dimen>

    <!-- Distance that the full shade transition takes in order for media to fully transition to
         the shade -->
    <dimen name="lockscreen_shade_media_transition_distance">120dp</dimen>
@@ -1861,7 +1867,6 @@
    <dimen name="dream_overlay_y_offset">80dp</dimen>
    <dimen name="dream_overlay_entry_y_offset">40dp</dimen>
    <dimen name="dream_overlay_exit_y_offset">40dp</dimen>
    <dimen name="dream_overlay_exit_x_offset">824dp</dimen>

    <dimen name="status_view_margin_horizontal">0dp</dimen>

Loading