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

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

Merge "[flexiglass] Fixes crash when opening QS from Shade" into main

parents 93be8227 03f010f4
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.systemui.SysuiTestCase
import com.android.systemui.authentication.data.repository.fakeAuthenticationRepository
import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.coroutines.collectValues
import com.android.systemui.deviceentry.data.repository.fakeDeviceEntryRepository
import com.android.systemui.deviceentry.domain.interactor.deviceEntryInteractor
import com.android.systemui.flags.EnableSceneContainer
@@ -50,6 +51,7 @@ import com.android.systemui.shade.domain.startable.shadeStartable
import com.android.systemui.shade.shared.flag.DualShade
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import com.google.common.truth.Truth.assertWithMessage
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.test.TestScope
@@ -248,6 +250,27 @@ class ShadeUserActionsViewModelTest : SysuiTestCase() {
            assertThat(actions?.get(Swipe.Up)).isEqualTo(UserActionResult(Scenes.Communal))
        }

    @Test
    fun upTransitionSceneKey_neverGoesBackToShadeScene() =
        testScope.runTest {
            val actions by collectValues(underTest.actions)
            val currentScene by collectLastValue(kosmos.sceneInteractor.currentScene)
            assertThat(currentScene).isEqualTo(Scenes.Lockscreen)
            kosmos.sceneInteractor.changeScene(Scenes.Shade, "")
            assertThat(currentScene).isEqualTo(Scenes.Shade)

            kosmos.sceneInteractor.changeScene(Scenes.QuickSettings, "")
            assertThat(currentScene).isEqualTo(Scenes.QuickSettings)

            actions.forEachIndexed { index, map ->
                assertWithMessage(
                        "Actions on index $index is incorrectly mapping back to the Shade scene!"
                    )
                    .that((map[Swipe.Up] as? UserActionResult.ChangeScene)?.toScene)
                    .isNotEqualTo(Scenes.Shade)
            }
        }

    private fun TestScope.setDeviceEntered(isEntered: Boolean) {
        if (isEntered) {
            // Unlock the device marking the device has entered.
+4 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import com.android.systemui.shade.shared.model.ShadeMode
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.filter

/**
 * Models the UI state for the user actions that the user can perform to navigate to other scenes.
@@ -50,7 +51,9 @@ constructor(
        combine(
                shadeInteractor.shadeMode,
                qsSceneAdapter.isCustomizerShowing,
                sceneBackInteractor.backScene.map { it ?: SceneFamilies.Home },
                sceneBackInteractor.backScene
                    .filter { it != Scenes.Shade }
                    .map { it ?: SceneFamilies.Home },
            ) { shadeMode, isCustomizerShowing, backScene ->
                buildMap<UserAction, UserActionResult> {
                    if (!isCustomizerShowing) {