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

Commit e3114701 authored by Beverly's avatar Beverly
Browse files

Add & update tests for new dozing keyguard states flag

Flag: com.android.systemui.new_dozing_keyguard_states
Bug: 415704030
Test: atest FromPrimaryBouncerTransitionInteractorTest
Test: atest KeyguardInteractorTest
Change-Id: Iba2faa02926f5cfd65a1d91f212e9a730c9c919e
parent 298837c0
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.se
import com.android.systemui.power.domain.interactor.powerInteractor
import com.android.systemui.testKosmos
import com.google.common.truth.Truth
import com.google.common.truth.Truth.assertThat
import junit.framework.Assert.assertEquals
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.flowOf
@@ -176,6 +177,7 @@ class FromPrimaryBouncerTransitionInteractorTest(flags: FlagsParameterization) :
        testScope.runTest {
            underTest.start()
            bouncerRepository.setPrimaryShow(true)
            runCurrent()
            transitionRepository.sendTransitionSteps(
                from = KeyguardState.LOCKSCREEN,
                to = KeyguardState.PRIMARY_BOUNCER,
@@ -203,6 +205,7 @@ class FromPrimaryBouncerTransitionInteractorTest(flags: FlagsParameterization) :
                flowOf(ObservableTransitionState.Idle(CommunalScenes.Communal))
            )
            bouncerRepository.setPrimaryShow(true)
            runCurrent()
            transitionRepository.sendTransitionSteps(
                from = KeyguardState.LOCKSCREEN,
                to = KeyguardState.PRIMARY_BOUNCER,
@@ -266,6 +269,7 @@ class FromPrimaryBouncerTransitionInteractorTest(flags: FlagsParameterization) :
        testScope.runTest {
            underTest.start()
            bouncerRepository.setPrimaryShow(true)
            runCurrent()
            transitionRepository.sendTransitionSteps(
                from = KeyguardState.LOCKSCREEN,
                to = KeyguardState.PRIMARY_BOUNCER,
@@ -295,6 +299,7 @@ class FromPrimaryBouncerTransitionInteractorTest(flags: FlagsParameterization) :
        kosmos.runTest {
            underTest.start()
            bouncerRepository.setPrimaryShow(true)
            runCurrent()
            transitionRepository.sendTransitionSteps(
                from = KeyguardState.LOCKSCREEN,
                to = KeyguardState.PRIMARY_BOUNCER,
@@ -330,6 +335,7 @@ class FromPrimaryBouncerTransitionInteractorTest(flags: FlagsParameterization) :

            // Bouncer is shown on top of the Glanceable Hub.
            bouncerRepository.setPrimaryShow(true)
            runCurrent()
            transitionRepository.sendTransitionSteps(
                from = KeyguardState.GLANCEABLE_HUB,
                to = KeyguardState.PRIMARY_BOUNCER,
+28 −0
Original line number Diff line number Diff line
@@ -19,10 +19,12 @@ package com.android.systemui.keyguard.domain.interactor

import android.app.StatusBarManager
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.compose.animation.scene.ObservableTransitionState
import com.android.systemui.Flags.FLAG_KEYGUARD_WM_STATE_REFACTOR
import com.android.systemui.Flags.FLAG_NEW_DOZING_KEYGUARD_STATES
import com.android.systemui.SysuiTestCase
import com.android.systemui.bouncer.data.repository.keyguardBouncerRepository
import com.android.systemui.common.ui.data.repository.fakeConfigurationRepository
@@ -663,6 +665,32 @@ class KeyguardInteractorTest : SysuiTestCase() {
            assertThat(dozeAmount).isEqualTo(0f)
        }

    @Test
    fun primaryBouncerShowing_initialValueFalse() =
        testScope.runTest {
            val primaryBouncerShowing by collectLastValue(underTest.primaryBouncerShowing)
            assertThat(primaryBouncerShowing).isFalse()
        }

    @Test
    fun primaryBouncerShowing_bouncerShow() =
        testScope.runTest {
            val primaryBouncerShowing by collectLastValue(underTest.primaryBouncerShowing)
            bouncerRepository.setPrimaryShow(true)
            runCurrent()
            assertThat(primaryBouncerShowing).isTrue()
        }

    @Test
    @EnableFlags(FLAG_NEW_DOZING_KEYGUARD_STATES)
    fun primaryBouncerShowing_bouncerShowingSoon() =
        testScope.runTest {
            val primaryBouncerShowing by collectLastValue(underTest.primaryBouncerShowing)
            bouncerRepository.setPrimaryShowingSoon(true)
            runCurrent()
            assertThat(primaryBouncerShowing).isTrue()
        }

    private suspend fun sendTransitionStep(step: TransitionStep) {
        keyguardTransitionRepository.sendTransitionStep(step)
        testScope.runCurrent()
+19 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar.phone;

import static android.service.dreams.Flags.FLAG_DREAMS_V2;

import static com.android.systemui.Flags.FLAG_NEW_DOZING_KEYGUARD_STATES;
import static com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_NONE;
import static com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_WAKE_AND_UNLOCK;

@@ -40,6 +41,7 @@ import android.hardware.fingerprint.FingerprintManager;
import android.os.Handler;
import android.os.PowerManager;
import android.os.UserHandle;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.testing.TestableLooper.RunWithLooper;
import android.testing.TestableResources;
@@ -475,6 +477,7 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
    }

    @Test
    @DisableFlags(FLAG_NEW_DOZING_KEYGUARD_STATES)
    public void onBiometricAuthenticated_whenFaceAndPulsing_dontDismissKeyguard() {
        reset(mUpdateMonitor);
        reset(mStatusBarKeyguardViewManager);
@@ -489,6 +492,22 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
                .isEqualTo(BiometricUnlockController.MODE_ONLY_WAKE);
    }

    @Test
    @EnableFlags(FLAG_NEW_DOZING_KEYGUARD_STATES)
    public void onBiometricAuthenticated_whenFaceAndPulsing_alwaysDismissKeyguard() {
        reset(mUpdateMonitor);
        reset(mStatusBarKeyguardViewManager);
        when(mUpdateMonitor.isUnlockingWithBiometricAllowed(anyBoolean())).thenReturn(true);
        when(mDozeScrimController.isPulsing()).thenReturn(true);
        // the value of isStrongBiometric doesn't matter here since we only care about the returned
        // value of isUnlockingWithBiometricAllowed()
        mBiometricUnlockController.onBiometricAuthenticated(UserHandle.USER_CURRENT,
                BiometricSourceType.FACE, true /* isStrongBiometric */);

        assertThat(mBiometricUnlockController.getMode())
                .isEqualTo(BiometricUnlockController.MODE_WAKE_AND_UNLOCK_PULSING);
    }

    @Test
    public void onOpticalUdfpsConsecutivelyFailedThreeTimes_showPrimaryBouncer() {
        // GIVEN optical UDFPS is supported