1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.systemui.biometrics.shared.model 18 19 import android.hardware.fingerprint.FingerprintSensorProperties 20 import androidx.test.ext.junit.runners.AndroidJUnit4 21 import androidx.test.filters.SmallTest 22 import com.android.systemui.SysuiTestCase 23 import com.android.systemui.biometrics.faceSensorPropertiesInternal 24 import com.android.systemui.biometrics.fingerprintSensorPropertiesInternal 25 import com.google.common.truth.Truth.assertThat 26 import org.junit.Test 27 import org.junit.runner.RunWith 28 29 @SmallTest 30 @RunWith(AndroidJUnit4::class) 31 class BiometricModalitiesTest : SysuiTestCase() { 32 33 @Test isEmptynull34 fun isEmpty() { 35 assertThat(BiometricModalities().isEmpty).isTrue() 36 } 37 38 @Test hasUdfpsnull39 fun hasUdfps() { 40 with( 41 BiometricModalities( 42 fingerprintProperties = fingerprintSensorPropertiesInternal( 43 sensorType = FingerprintSensorProperties.TYPE_UDFPS_OPTICAL 44 ).first(), 45 ) 46 ) { 47 assertThat(isEmpty).isFalse() 48 assertThat(hasUdfps).isTrue() 49 assertThat(hasSfps).isFalse() 50 assertThat(hasFace).isFalse() 51 assertThat(hasFaceOnly).isFalse() 52 assertThat(hasFingerprint).isTrue() 53 assertThat(hasFingerprintOnly).isTrue() 54 assertThat(hasFaceAndFingerprint).isFalse() 55 } 56 } 57 58 @Test hasSfpsnull59 fun hasSfps() { 60 with( 61 BiometricModalities( 62 fingerprintProperties = fingerprintSensorPropertiesInternal( 63 sensorType = FingerprintSensorProperties.TYPE_POWER_BUTTON 64 ).first(), 65 ) 66 ) { 67 assertThat(isEmpty).isFalse() 68 assertThat(hasUdfps).isFalse() 69 assertThat(hasSfps).isTrue() 70 assertThat(hasFace).isFalse() 71 assertThat(hasFaceOnly).isFalse() 72 assertThat(hasFingerprint).isTrue() 73 assertThat(hasFingerprintOnly).isTrue() 74 assertThat(hasFaceAndFingerprint).isFalse() 75 } 76 } 77 78 @Test fingerprintOnlynull79 fun fingerprintOnly() { 80 with( 81 BiometricModalities( 82 fingerprintProperties = fingerprintSensorPropertiesInternal().first(), 83 ) 84 ) { 85 assertThat(isEmpty).isFalse() 86 assertThat(hasFace).isFalse() 87 assertThat(hasFaceOnly).isFalse() 88 assertThat(hasFingerprint).isTrue() 89 assertThat(hasFingerprintOnly).isTrue() 90 assertThat(hasFaceAndFingerprint).isFalse() 91 } 92 } 93 94 @Test faceOnlynull95 fun faceOnly() { 96 with(BiometricModalities(faceProperties = faceSensorPropertiesInternal().first())) { 97 assertThat(isEmpty).isFalse() 98 assertThat(hasFace).isTrue() 99 assertThat(hasFaceOnly).isTrue() 100 assertThat(hasFingerprint).isFalse() 101 assertThat(hasFingerprintOnly).isFalse() 102 assertThat(hasFaceAndFingerprint).isFalse() 103 } 104 } 105 106 @Test faceStrengthnull107 fun faceStrength() { 108 with( 109 BiometricModalities( 110 fingerprintProperties = fingerprintSensorPropertiesInternal(strong = false).first(), 111 faceProperties = faceSensorPropertiesInternal(strong = true).first() 112 ) 113 ) { 114 assertThat(isFaceStrong).isTrue() 115 } 116 117 with( 118 BiometricModalities( 119 fingerprintProperties = fingerprintSensorPropertiesInternal(strong = false).first(), 120 faceProperties = faceSensorPropertiesInternal(strong = false).first() 121 ) 122 ) { 123 assertThat(isFaceStrong).isFalse() 124 } 125 } 126 127 @Test faceAndFingerprintnull128 fun faceAndFingerprint() { 129 with( 130 BiometricModalities( 131 fingerprintProperties = fingerprintSensorPropertiesInternal().first(), 132 faceProperties = faceSensorPropertiesInternal().first(), 133 ) 134 ) { 135 assertThat(isEmpty).isFalse() 136 assertThat(hasFace).isTrue() 137 assertThat(hasFingerprint).isTrue() 138 assertThat(hasFaceOnly).isFalse() 139 assertThat(hasFingerprintOnly).isFalse() 140 assertThat(hasFaceAndFingerprint).isTrue() 141 } 142 } 143 } 144