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

Commit bc33eb8b authored by Kevin Chyn's avatar Kevin Chyn
Browse files

9/n: Add test case for udfps rejection after face rejection

This case is already supported by the logic. This CL simply adds
a test case for it.

Bug: 193089985
Test: atest CoexCoordinatorTest
Change-Id: I02898d240f5c22033250b2d1a8476a743e2d4f45
parent bf9a253a
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
@@ -292,6 +292,40 @@ public class CoexCoordinatorTest {
        verify(mCallback, never()).sendHapticFeedback();
    }

    @Test
    public void testKeyguard_udfpsRejected_thenFaceRejected() {
        mCoexCoordinator.reset();

        AuthenticationClient<?> faceClient = mock(AuthenticationClient.class);
        when(faceClient.isKeyguard()).thenReturn(true);
        when(faceClient.getState()).thenReturn(AuthenticationClient.STATE_STARTED);

        AuthenticationClient<?> udfpsClient = mock(AuthenticationClient.class,
                withSettings().extraInterfaces(Udfps.class));
        when(udfpsClient.getState()).thenReturn(AuthenticationClient.STATE_STARTED);
        when(udfpsClient.isKeyguard()).thenReturn(true);
        when(((Udfps) udfpsClient).isPointerDown()).thenReturn(true);

        mCoexCoordinator.addAuthenticationClient(SENSOR_TYPE_FACE, faceClient);
        mCoexCoordinator.addAuthenticationClient(SENSOR_TYPE_UDFPS, udfpsClient);

        mCoexCoordinator.onAuthenticationRejected(0 /* currentTimeMillis */, udfpsClient,
                LockoutTracker.LOCKOUT_NONE, mCallback);
        // Client becomes paused, but finger does not necessarily lift, since we suppress the haptic
        when(udfpsClient.getState()).thenReturn(AuthenticationClient.STATE_STARTED_PAUSED);
        verify(mCallback, never()).sendHapticFeedback();
        verify(mCallback).handleLifecycleAfterAuth();

        // Then face rejected. Note that scheduler leaves UDFPS in the CoexCoordinator since
        // unlike face, its lifecycle becomes "paused" instead of "finished".
        CoexCoordinator.Callback faceCallback = mock(CoexCoordinator.Callback.class);
        mCoexCoordinator.onAuthenticationRejected(1 /* currentTimeMillis */, faceClient,
                LockoutTracker.LOCKOUT_NONE, faceCallback);
        verify(faceCallback).sendHapticFeedback();
        verify(faceCallback).sendAuthenticationResult(eq(false) /* addAuthTokenIfStrong */);
        verify(mCallback, never()).sendHapticFeedback();
    }

    @Test
    public void testNonKeyguard_rejectAndNotLockedOut() {
        mCoexCoordinator.reset();