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

Commit 092b8218 authored by Kevin Liu's avatar Kevin Liu
Browse files

Converted Biometric tests to Robolectric tests

Added TestWithLooperRule to replace AndroidTestingRunner.
Converted some tests to run in parallel as Robolectric tests.

Bug: 267340313
Fix: 269478124
Test: atest SystemUiRoboTests
      atest SystemUITests
Change-Id: Ib2e1edfee4ecb45501f5cc42f1b63c9326d2faa4
parent f3bbc777
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -258,6 +258,24 @@ filegroup {
        "tests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenToDreamingTransitionViewModelTest.kt",
        "tests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenToOccludedTransitionViewModelTest.kt",
        "tests/src/com/android/systemui/keyguard/ui/viewmodel/OccludedToLockscreenTransitionViewModelTest.kt",

        // Biometric
        "tests/src/com/android/systemui/biometrics/BiometricTestExtensions.kt",
        "tests/src/com/android/systemui/biometrics/AuthBiometricFingerprintAndFaceViewTest.kt",
        "tests/src/com/android/systemui/biometrics/AuthBiometricFingerprintViewTest.kt",
        "tests/src/com/android/systemui/biometrics/AuthControllerTest.java",
        "tests/src/com/android/systemui/biometrics/BiometricDisplayListenerTest.java",
        "tests/src/com/android/systemui/biometrics/FaceHelpMessageDeferralTest.kt",
        "tests/src/com/android/systemui/biometrics/SideFpsControllerTest.kt",
        "tests/src/com/android/systemui/biometrics/UdfpsControllerOverlayTest.kt",
        "tests/src/com/android/systemui/biometrics/UdfpsControllerTest.java",
        "tests/src/com/android/systemui/biometrics/UdfpsDialogMeasureAdapterTest.java",
        "tests/src/com/android/systemui/biometrics/UdfpsDisplayModeTest.java",
        "tests/src/com/android/systemui/biometrics/UdfpsKeyguardViewControllerBaseTest.java",
        "tests/src/com/android/systemui/biometrics/UdfpsKeyguardViewControllerTest.java",
        "tests/src/com/android/systemui/biometrics/UdfpsKeyguardViewControllerWithCoroutinesTest.kt",
        "tests/src/com/android/systemui/biometrics/UdfpsShellTest.kt",
        "tests/src/com/android/systemui/biometrics/UdfpsViewTest.kt",
    ],
    path: "tests/src",
}
@@ -402,6 +420,10 @@ android_app {
    privileged: true,
    resource_dirs: [],
    kotlincflags: ["-Xjvm-default=all"],
    optimize: {
        shrink_resources: false,
        proguard_flags_files: ["proguard.flags"],
    },

    plugins: ["dagger2-compiler"],
}
+2 −3
Original line number Diff line number Diff line
@@ -144,8 +144,7 @@ constructor(
                orientationListener.enable()
            }
        }
    @VisibleForTesting
    internal var overlayOffsets: SensorLocationInternal = SensorLocationInternal.DEFAULT
    @VisibleForTesting var overlayOffsets: SensorLocationInternal = SensorLocationInternal.DEFAULT

    private val overlayViewParams =
        WindowManager.LayoutParams(
@@ -297,7 +296,7 @@ constructor(
    }

    @VisibleForTesting
    internal fun updateOverlayParams(display: Display, bounds: Rect) {
    fun updateOverlayParams(display: Display, bounds: Rect) {
        val isNaturalOrientation = display.isNaturalOrientation()
        val isDefaultOrientation =
            if (isReverseDefaultRotation) !isNaturalOrientation else isNaturalOrientation
+2 −2
Original line number Diff line number Diff line
@@ -254,7 +254,7 @@ constructor(
    }

    @VisibleForTesting
    internal suspend fun listenForBouncerExpansion(scope: CoroutineScope): Job {
    suspend fun listenForBouncerExpansion(scope: CoroutineScope): Job {
        return scope.launch {
            primaryBouncerInteractor.bouncerExpansion.collect { bouncerExpansion: Float ->
                inputBouncerExpansion = bouncerExpansion
@@ -265,7 +265,7 @@ constructor(
    }

    @VisibleForTesting
    internal suspend fun listenForAlternateBouncerVisibility(scope: CoroutineScope): Job {
    suspend fun listenForAlternateBouncerVisibility(scope: CoroutineScope): Job {
        return scope.launch {
            alternateBouncerInteractor.isVisible.collect { isVisible: Boolean ->
                showUdfpsBouncer(isVisible)
+4 −1
Original line number Diff line number Diff line
@@ -14,3 +14,6 @@
# limitations under the License.
#
sdk=NEWEST_SDK
shadows=\
  com.android.systemui.testutils.shadow.ShadowLockPatternUtils \
  com.android.systemui.testutils.shadow.ShadowTestableLooper
 No newline at end of file
+33 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.testutils.shadow;

import static com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_NONE;

import com.android.internal.widget.LockPatternUtils;

import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;

@Implements(LockPatternUtils.class)
public class ShadowLockPatternUtils {

    @Implementation
    protected int getCredentialTypeForUser(int userHandle) {
        return CREDENTIAL_TYPE_NONE;
    }
}
Loading