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

Commit e463562c authored by Josh Tsuji's avatar Josh Tsuji
Browse files

Additional test fixes for keyguard_wm_state_refactor.

Also, deletes one KeyguardTransitionScenarioTest - looks like we can't use @(Enable|Disable)Flags annotations due to the way this test is set up, and this is the only test that fails with the flag enabled (due to using keyguardShowing).

Bug: 278086361
Test: atest SystemUITests
Flag: com.android.systemui.keyguard_wm_state_refactor
Change-Id: Iff8796624888ce49b5739e107654d4d350dc784d
parent 95f7388f
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -32,8 +32,11 @@

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.systemui.Flags
import com.android.systemui.SysuiTestCase
import com.android.systemui.bouncer.data.repository.fakeKeyguardBouncerRepository
import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository
@@ -76,6 +79,7 @@ class FromAlternateBouncerTransitionInteractorTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(Flags.FLAG_KEYGUARD_WM_STATE_REFACTOR)
    fun transitionToGone_keyguardOccluded_biometricAuthenticated() =
        testScope.runTest {
            transitionRepository.sendTransitionSteps(
@@ -95,6 +99,25 @@ class FromAlternateBouncerTransitionInteractorTest : SysuiTestCase() {
                .startedTransition(from = KeyguardState.ALTERNATE_BOUNCER, to = KeyguardState.GONE)
        }

    @Test
    @EnableFlags(Flags.FLAG_KEYGUARD_WM_STATE_REFACTOR)
    fun transitionToGone_keyguardOccludedThenAltBouncer_authed_wmStateRefactor() =
        testScope.runTest {
            transitionRepository.sendTransitionSteps(
                from = KeyguardState.OCCLUDED,
                to = KeyguardState.ALTERNATE_BOUNCER,
                testScope
            )
            reset(transitionRepository)

            // Authentication results in calling startDismissKeyguardTransition.
            kosmos.keyguardTransitionInteractor.startDismissKeyguardTransition()
            runCurrent()

            assertThat(transitionRepository)
                .startedTransition(from = KeyguardState.ALTERNATE_BOUNCER, to = KeyguardState.GONE)
        }

    @Test
    fun noTransition_keyguardNotOccluded_biometricAuthenticated() =
        testScope.runTest {
+3 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ import com.android.systemui.power.domain.interactor.PowerInteractor
import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAsleepForTest
import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAwakeForTest
import com.android.systemui.power.domain.interactor.powerInteractor
import com.android.systemui.statusbar.domain.interactor.keyguardOcclusionInteractor
import com.android.systemui.testKosmos
import junit.framework.Assert.assertEquals
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -299,6 +300,7 @@ class FromAodTransitionInteractorTest : SysuiTestCase() {
    fun testTransitionToOccluded_onWake() =
        testScope.runTest {
            kosmos.fakeKeyguardRepository.setKeyguardOccluded(true)
            kosmos.keyguardOcclusionInteractor.setWmNotifiedShowWhenLockedActivityOnTop(true)
            powerInteractor.setAwakeForTest()
            advanceTimeBy(100) // account for debouncing

@@ -312,6 +314,7 @@ class FromAodTransitionInteractorTest : SysuiTestCase() {
        testScope.runTest {
            kosmos.fakeKeyguardRepository.setKeyguardShowing(false)
            kosmos.fakeKeyguardRepository.setKeyguardDismissible(true)
            kosmos.keyguardTransitionInteractor.startDismissKeyguardTransition()
            powerInteractor.setAwakeForTest()
            advanceTimeBy(100) // account for debouncing

+0 −26
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ import com.android.systemui.bouncer.data.repository.fakeKeyguardBouncerRepositor
import com.android.systemui.communal.domain.interactor.communalInteractor
import com.android.systemui.communal.domain.interactor.setCommunalAvailable
import com.android.systemui.communal.shared.model.CommunalScenes
import com.android.systemui.deviceentry.data.repository.fakeDeviceEntryRepository
import com.android.systemui.dock.fakeDockManager
import com.android.systemui.flags.BrokenWithSceneContainer
import com.android.systemui.flags.DisableSceneContainer
@@ -606,31 +605,6 @@ class KeyguardTransitionScenariosTest(flags: FlagsParameterization?) : SysuiTest
            coroutineContext.cancelChildren()
        }

    /** This handles security method NONE and screen off with lock timeout */
    @Test
    fun dozingToGoneWithKeyguardNotShowing() =
        testScope.runTest {
            // GIVEN a prior transition has run to DOZING
            runTransitionAndSetWakefulness(KeyguardState.LOCKSCREEN, KeyguardState.DOZING)
            runCurrent()

            // WHEN the device wakes up without a keyguard
            keyguardRepository.setKeyguardShowing(false)
            keyguardRepository.setKeyguardDismissible(true)
            kosmos.fakeDeviceEntryRepository.setLockscreenEnabled(false)
            powerInteractor.setAwakeForTest()
            advanceTimeBy(60L)

            assertThat(transitionRepository)
                .startedTransition(
                    to = KeyguardState.GONE,
                    from = KeyguardState.DOZING,
                    animatorAssertion = { it.isNotNull() }
                )

            coroutineContext.cancelChildren()
        }

    /** This handles security method NONE and screen off with lock timeout */
    @Test
    @DisableSceneContainer