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

Commit ac766ac2 authored by Austin Delgado's avatar Austin Delgado
Browse files

Fix tests related to UDFPS_NEW_TOUCH_DETECTION removal

Bug: 303470930
Test: atest SystemUITests:com.android.systemui.biometrics
Test: PrimaryBouncerToGoneTransitionViewModelTest
Test: StatusBarKeyguardViewManagerTest
Change-Id: Ib5c22069d50f5a6ca22a638e3496c92f6c6e83ab
parent fa4a9fe4
Loading
Loading
Loading
Loading
+11 −35
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ import android.testing.TestableLooper.RunWithLooper
import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.Surface
import android.view.Surface.ROTATION_0
import android.view.Surface.Rotation
import android.view.View
import android.view.WindowManager
@@ -45,7 +44,6 @@ import com.android.systemui.bouncer.domain.interactor.AlternateBouncerInteractor
import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerInteractor
import com.android.systemui.dump.DumpManager
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags
import com.android.systemui.keyguard.ui.viewmodel.UdfpsKeyguardViewModels
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.statusbar.LockscreenShadeTransitionController
@@ -141,7 +139,6 @@ class UdfpsControllerOverlayTest : SysuiTestCase() {
    ) {
        controllerOverlay = UdfpsControllerOverlay(
            context,
            fingerprintManager,
            inflater,
            windowManager,
            accessibilityManager,
@@ -155,7 +152,6 @@ class UdfpsControllerOverlayTest : SysuiTestCase() {
            keyguardStateController,
            unlockedScreenOffAnimationController,
            udfpsDisplayMode,
            secureSettings,
            REQUEST_ID,
            reason,
            controllerCallback,
@@ -165,7 +161,6 @@ class UdfpsControllerOverlayTest : SysuiTestCase() {
            primaryBouncerInteractor,
            alternateBouncerInteractor,
            isDebuggable,
            udfpsUtils,
            udfpsKeyguardAccessibilityDelegate,
            udfpsKeyguardViewModels,
        )
@@ -212,8 +207,8 @@ class UdfpsControllerOverlayTest : SysuiTestCase() {
            val lp = layoutParamsCaptor.value
            assertThat(lp.x).isEqualTo(0)
            assertThat(lp.y).isEqualTo(0)
            assertThat(lp.width).isEqualTo(SENSOR_WIDTH)
            assertThat(lp.height).isEqualTo(SENSOR_HEIGHT)
            assertThat(lp.width).isEqualTo(DISPLAY_WIDTH)
            assertThat(lp.height).isEqualTo(DISPLAY_HEIGHT)
        }
    }

@@ -230,8 +225,8 @@ class UdfpsControllerOverlayTest : SysuiTestCase() {
            val lp = layoutParamsCaptor.value
            assertThat(lp.x).isEqualTo(0)
            assertThat(lp.y).isEqualTo(0)
            assertThat(lp.width).isEqualTo(SENSOR_WIDTH)
            assertThat(lp.height).isEqualTo(SENSOR_HEIGHT)
            assertThat(lp.width).isEqualTo(DISPLAY_WIDTH)
            assertThat(lp.height).isEqualTo(DISPLAY_HEIGHT)
        }
    }

@@ -247,9 +242,9 @@ class UdfpsControllerOverlayTest : SysuiTestCase() {
            // Sensor should be in the bottom left corner in ROTATION_90.
            val lp = layoutParamsCaptor.value
            assertThat(lp.x).isEqualTo(0)
            assertThat(lp.y).isEqualTo(DISPLAY_WIDTH - SENSOR_WIDTH)
            assertThat(lp.width).isEqualTo(SENSOR_HEIGHT)
            assertThat(lp.height).isEqualTo(SENSOR_WIDTH)
            assertThat(lp.y).isEqualTo(0)
            assertThat(lp.width).isEqualTo(DISPLAY_HEIGHT)
            assertThat(lp.height).isEqualTo(DISPLAY_WIDTH)
        }
    }

@@ -264,10 +259,10 @@ class UdfpsControllerOverlayTest : SysuiTestCase() {

            // Sensor should be in the top right corner in ROTATION_270.
            val lp = layoutParamsCaptor.value
            assertThat(lp.x).isEqualTo(DISPLAY_HEIGHT - SENSOR_HEIGHT)
            assertThat(lp.x).isEqualTo(0)
            assertThat(lp.y).isEqualTo(0)
            assertThat(lp.width).isEqualTo(SENSOR_HEIGHT)
            assertThat(lp.height).isEqualTo(SENSOR_WIDTH)
            assertThat(lp.width).isEqualTo(DISPLAY_HEIGHT)
            assertThat(lp.height).isEqualTo(DISPLAY_WIDTH)
        }
    }

@@ -345,11 +340,10 @@ class UdfpsControllerOverlayTest : SysuiTestCase() {
    }

    @Test
    fun smallOverlayOnEnrollmentWithA11y() = withRotation(ROTATION_0) {
    fun smallOverlayOnEnrollmentWithA11y() = withRotation(Surface.ROTATION_0) {
        withReason(REASON_ENROLL_ENROLLING) {
            // When a11y enabled during enrollment
            whenever(accessibilityManager.isTouchExplorationEnabled).thenReturn(true)
            whenever(featureFlags.isEnabled(Flags.UDFPS_NEW_TOUCH_DETECTION)).thenReturn(true)

            controllerOverlay.show(udfpsController, overlayParams)
            verify(windowManager).addView(
@@ -363,22 +357,4 @@ class UdfpsControllerOverlayTest : SysuiTestCase() {
            assertThat(lp.height).isEqualTo(overlayParams.sensorBounds.height())
        }
    }

    @Test
    fun fullScreenOverlayWithNewTouchDetectionEnabled() = withRotation(ROTATION_0) {
        withReason(REASON_AUTH_KEYGUARD) {
            whenever(featureFlags.isEnabled(Flags.UDFPS_NEW_TOUCH_DETECTION)).thenReturn(true)

            controllerOverlay.show(udfpsController, overlayParams)
            verify(windowManager).addView(
                    eq(controllerOverlay.overlayView),
                    layoutParamsCaptor.capture()
            )

            // Layout params should use natural display width and height
            val lp = layoutParamsCaptor.value
            assertThat(lp.width).isEqualTo(overlayParams.naturalDisplayWidth)
            assertThat(lp.height).isEqualTo(overlayParams.naturalDisplayHeight)
        }
    }
}
+142 −484

File changed.

Preview size limit exceeded, changes collapsed.

+2 −4
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ import com.android.systemui.bouncer.domain.interactor.AlternateBouncerInteractor
import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerInteractor;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.flags.FakeFeatureFlags;
import com.android.systemui.flags.Flags;
import com.android.systemui.keyguard.KeyguardViewMediator;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.shade.ShadeExpansionChangeEvent;
@@ -116,7 +115,7 @@ public class UdfpsKeyguardViewLegacyControllerBaseTest extends SysuiTestCase {
    }

    public UdfpsKeyguardViewControllerLegacy createUdfpsKeyguardViewController() {
        return createUdfpsKeyguardViewController(false, false);
        return createUdfpsKeyguardViewController(false);
    }

    public void captureKeyGuardViewManagerCallback() {
@@ -126,8 +125,7 @@ public class UdfpsKeyguardViewLegacyControllerBaseTest extends SysuiTestCase {
    }

    protected UdfpsKeyguardViewControllerLegacy createUdfpsKeyguardViewController(
            boolean useModernBouncer, boolean useExpandedOverlay) {
        mFeatureFlags.set(Flags.UDFPS_NEW_TOUCH_DETECTION, useExpandedOverlay);
            boolean useModernBouncer) {
        UdfpsKeyguardViewControllerLegacy controller = new UdfpsKeyguardViewControllerLegacy(
                mView,
                mStatusBarStateController,
+1 −38
Original line number Diff line number Diff line
@@ -18,15 +18,12 @@ package com.android.systemui.biometrics;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.testing.TestableLooper;
import android.view.MotionEvent;

import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
@@ -44,8 +41,7 @@ public class UdfpsKeyguardViewLegacyControllerTest extends
        UdfpsKeyguardViewLegacyControllerBaseTest {
    @Override
    public UdfpsKeyguardViewControllerLegacy createUdfpsKeyguardViewController() {
        return createUdfpsKeyguardViewController(/* useModernBouncer */ false,
                /* useExpandedOverlay */ false);
        return createUdfpsKeyguardViewController(/* useModernBouncer */ false);
    }

    @Test
@@ -216,37 +212,4 @@ public class UdfpsKeyguardViewLegacyControllerTest extends
        sendStatusBarStateChanged(StatusBarState.SHADE_LOCKED);
        assertTrue(mController.shouldPauseAuth());
    }

    @Test
    // TODO(b/259264861): Tracking Bug
    public void testUdfpsExpandedOverlayOn() {
        // GIVEN view is attached and useExpandedOverlay is true
        mController = createUdfpsKeyguardViewController(false, true);
        mController.onViewAttached();
        captureKeyGuardViewManagerCallback();

        // WHEN a touch is received
        mKeyguardViewManagerCallback.onTouch(
                MotionEvent.obtain(0, 0, 0, 0, 0, 0));

        // THEN udfpsController onTouch is not called
        assertTrue(mView.mUseExpandedOverlay);
        verify(mUdfpsController, never()).onTouch(any());
    }

    @Test
    // TODO(b/259264861): Tracking Bug
    public void testUdfpsExpandedOverlayOff() {
        // GIVEN view is attached and useExpandedOverlay is false
        mController.onViewAttached();
        captureKeyGuardViewManagerCallback();

        // WHEN a touch is received
        mKeyguardViewManagerCallback.onTouch(
                MotionEvent.obtain(0, 0, 0, 0, 0, 0));

        // THEN udfpsController onTouch is called
        assertFalse(mView.mUseExpandedOverlay);
        verify(mUdfpsController).onTouch(any());
    }
}
+1 −4
Original line number Diff line number Diff line
@@ -106,10 +106,7 @@ class UdfpsKeyguardViewLegacyControllerWithCoroutinesTest :
                mock(SystemClock::class.java),
                mKeyguardUpdateMonitor,
            )
        return createUdfpsKeyguardViewController(
            /* useModernBouncer */ true, /* useExpandedOverlay */
            false
        )
        return createUdfpsKeyguardViewController(/* useModernBouncer */ true)
    }

    @Test
Loading