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

Commit 89f81b2b authored by Josh Tsuji's avatar Josh Tsuji
Browse files

Fix tests for keyguard_wm_state_refactor flag.

We need to set up more consistent state for the refactor or it won't actually start the transitions.

Test: atest SystemUITests
Flag: EXEMPT tests
Bug: 278086361
Change-Id: I6ce67018b30a07630432d7d657a826d6062b7023
parent cc54a24c
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import com.android.systemui.keyguard.util.KeyguardTransitionRepositorySpySubject
import com.android.systemui.kosmos.testScope
import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAsleepForTest
import com.android.systemui.power.domain.interactor.powerInteractor
import com.android.systemui.statusbar.domain.interactor.keyguardOcclusionInteractor
import com.android.systemui.testKosmos
import kotlin.test.Test
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -78,6 +79,9 @@ class FromDreamingTransitionInteractorTest : SysuiTestCase() {
    fun setup() {
        underTest.start()

        kosmos.fakeKeyguardRepository.setDreaming(true)
        kosmos.keyguardOcclusionInteractor.setWmNotifiedShowWhenLockedActivityOnTop(true)

        // Transition to DOZING and set the power interactor asleep.
        powerInteractor.setAsleepForTest()
        runBlocking {
+35 −1
Original line number Diff line number Diff line
@@ -16,12 +16,18 @@

package com.android.systemui.keyguard.domain.interactor

import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.widget.LockPatternUtils
import com.android.systemui.Flags
import com.android.systemui.SysuiTestCase
import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository
import com.android.systemui.keyguard.data.repository.fakeBiometricSettingsRepository
import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository
import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository
import com.android.systemui.keyguard.shared.model.AuthenticationFlags
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.model.TransitionState
import com.android.systemui.keyguard.shared.model.TransitionStep
@@ -81,6 +87,7 @@ class FromGoneTransitionInteractorTest : SysuiTestCase() {
        }

    @Test
    @DisableFlags(Flags.FLAG_KEYGUARD_WM_STATE_REFACTOR)
    fun testTransitionsToLockscreen_ifFinishedInGone() =
        testScope.runTest {
            keyguardTransitionRepository.sendTransitionSteps(
@@ -92,7 +99,34 @@ class FromGoneTransitionInteractorTest : SysuiTestCase() {
            kosmos.fakeKeyguardRepository.setKeyguardShowing(true)
            runCurrent()

            // We're in the middle of a LOCKSCREEN -> GONE transition.
            // We're in the middle of a GONE -> LOCKSCREEN transition.
            assertThat(keyguardTransitionRepository)
                .startedTransition(
                    to = KeyguardState.LOCKSCREEN,
                )
        }

    @Test
    @EnableFlags(Flags.FLAG_KEYGUARD_WM_STATE_REFACTOR)
    fun testTransitionsToLockscreen_ifFinishedInGone_wmRefactor() =
        testScope.runTest {
            keyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.LOCKSCREEN,
                to = KeyguardState.GONE,
                testScope,
            )
            reset(keyguardTransitionRepository)

            // Trigger lockdown.
            kosmos.fakeBiometricSettingsRepository.setAuthenticationFlags(
                AuthenticationFlags(
                    0,
                    LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN
                )
            )
            runCurrent()

            // We're in the middle of a GONE -> LOCKSCREEN transition.
            assertThat(keyguardTransitionRepository)
                .startedTransition(
                    to = KeyguardState.LOCKSCREEN,