Loading services/tests/servicestests/src/com/android/server/biometrics/AuthServiceTest.java +16 −19 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.annotation.UserIdInt; import android.app.AppOpsManager; import android.content.Context; import android.content.pm.PackageManager; Loading Loading @@ -92,6 +93,8 @@ public class AuthServiceTest { private static final String TEST_OP_PACKAGE_NAME = "test_package"; private final @UserIdInt int mUserId = UserHandle.getCallingUserId(); private AuthService mAuthService; @Rule Loading Loading @@ -257,12 +260,11 @@ public class AuthServiceTest { final Binder token = new Binder(); final PromptInfo promptInfo = new PromptInfo(); final long sessionId = 0; final int userId = 0; mAuthService.mImpl.authenticate( token, sessionId, userId, mUserId, mReceiver, TEST_OP_PACKAGE_NAME, promptInfo); Loading @@ -270,7 +272,7 @@ public class AuthServiceTest { verify(mBiometricService).authenticate( eq(token), eq(sessionId), eq(userId), eq(mUserId), eq(mReceiver), eq(TEST_OP_PACKAGE_NAME), eq(promptInfo)); Loading @@ -286,12 +288,11 @@ public class AuthServiceTest { final Binder token = new Binder(); final PromptInfo promptInfo = new PromptInfo(); final long sessionId = 0; final int userId = 0; mAuthService.mImpl.authenticate( token, sessionId, userId, mUserId, mReceiver, TEST_OP_PACKAGE_NAME, promptInfo); Loading @@ -299,7 +300,7 @@ public class AuthServiceTest { verify(mBiometricService, never()).authenticate( eq(token), eq(sessionId), eq(userId), eq(mUserId), eq(mReceiver), eq(TEST_OP_PACKAGE_NAME), eq(promptInfo)); Loading @@ -313,12 +314,11 @@ public class AuthServiceTest { final PromptInfo promptInfo = new PromptInfo(); final long sessionId = 0; final int userId = 0; mAuthService.mImpl.authenticate( null /* token */, sessionId, userId, mUserId, mReceiver, TEST_OP_PACKAGE_NAME, promptInfo); Loading @@ -338,7 +338,7 @@ public class AuthServiceTest { mAuthService.mImpl.authenticate( token, 0, /* sessionId */ 0, /* userId */ mUserId, mReceiver, TEST_OP_PACKAGE_NAME, new PromptInfo()); Loading @@ -356,7 +356,7 @@ public class AuthServiceTest { mAuthService.mImpl.authenticate( token, 0, /* sessionId */ 0, /* userId */ mUserId, mReceiver, TEST_OP_PACKAGE_NAME, new PromptInfo()); Loading Loading @@ -414,20 +414,19 @@ public class AuthServiceTest { mAuthService = new AuthService(mContext, mInjector); mAuthService.onStart(); final int userId = 0; final int expectedResult = BIOMETRIC_SUCCESS; final int authenticators = 0; when(mBiometricService.canAuthenticate(anyString(), anyInt(), anyInt(), anyInt())) .thenReturn(expectedResult); final int result = mAuthService.mImpl .canAuthenticate(TEST_OP_PACKAGE_NAME, userId, authenticators); .canAuthenticate(TEST_OP_PACKAGE_NAME, mUserId, authenticators); assertEquals(expectedResult, result); waitForIdle(); verify(mBiometricService).canAuthenticate( eq(TEST_OP_PACKAGE_NAME), eq(userId), eq(mUserId), eq(UserHandle.getCallingUserId()), eq(authenticators)); } Loading @@ -440,18 +439,17 @@ public class AuthServiceTest { mAuthService = new AuthService(mContext, mInjector); mAuthService.onStart(); final int userId = 0; final boolean expectedResult = true; when(mBiometricService.hasEnrolledBiometrics(anyInt(), anyString())).thenReturn( expectedResult); final boolean result = mAuthService.mImpl.hasEnrolledBiometrics(userId, final boolean result = mAuthService.mImpl.hasEnrolledBiometrics(mUserId, TEST_OP_PACKAGE_NAME); assertEquals(expectedResult, result); waitForIdle(); verify(mBiometricService).hasEnrolledBiometrics( eq(userId), eq(mUserId), eq(TEST_OP_PACKAGE_NAME)); } Loading Loading @@ -528,13 +526,12 @@ public class AuthServiceTest { mAuthService = new AuthService(mContext, mInjector); mAuthService.onStart(); final int userId = 0; final int authenticators = BiometricManager.Authenticators.BIOMETRIC_STRONG; mAuthService.mImpl.getLastAuthenticationTime(userId, authenticators); mAuthService.mImpl.getLastAuthenticationTime(mUserId, authenticators); waitForIdle(); verify(mBiometricService).getLastAuthenticationTime(eq(userId), eq(authenticators)); verify(mBiometricService).getLastAuthenticationTime(eq(mUserId), eq(authenticators)); } private static void setInternalAndTestBiometricPermissions( Loading Loading
services/tests/servicestests/src/com/android/server/biometrics/AuthServiceTest.java +16 −19 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.annotation.UserIdInt; import android.app.AppOpsManager; import android.content.Context; import android.content.pm.PackageManager; Loading Loading @@ -92,6 +93,8 @@ public class AuthServiceTest { private static final String TEST_OP_PACKAGE_NAME = "test_package"; private final @UserIdInt int mUserId = UserHandle.getCallingUserId(); private AuthService mAuthService; @Rule Loading Loading @@ -257,12 +260,11 @@ public class AuthServiceTest { final Binder token = new Binder(); final PromptInfo promptInfo = new PromptInfo(); final long sessionId = 0; final int userId = 0; mAuthService.mImpl.authenticate( token, sessionId, userId, mUserId, mReceiver, TEST_OP_PACKAGE_NAME, promptInfo); Loading @@ -270,7 +272,7 @@ public class AuthServiceTest { verify(mBiometricService).authenticate( eq(token), eq(sessionId), eq(userId), eq(mUserId), eq(mReceiver), eq(TEST_OP_PACKAGE_NAME), eq(promptInfo)); Loading @@ -286,12 +288,11 @@ public class AuthServiceTest { final Binder token = new Binder(); final PromptInfo promptInfo = new PromptInfo(); final long sessionId = 0; final int userId = 0; mAuthService.mImpl.authenticate( token, sessionId, userId, mUserId, mReceiver, TEST_OP_PACKAGE_NAME, promptInfo); Loading @@ -299,7 +300,7 @@ public class AuthServiceTest { verify(mBiometricService, never()).authenticate( eq(token), eq(sessionId), eq(userId), eq(mUserId), eq(mReceiver), eq(TEST_OP_PACKAGE_NAME), eq(promptInfo)); Loading @@ -313,12 +314,11 @@ public class AuthServiceTest { final PromptInfo promptInfo = new PromptInfo(); final long sessionId = 0; final int userId = 0; mAuthService.mImpl.authenticate( null /* token */, sessionId, userId, mUserId, mReceiver, TEST_OP_PACKAGE_NAME, promptInfo); Loading @@ -338,7 +338,7 @@ public class AuthServiceTest { mAuthService.mImpl.authenticate( token, 0, /* sessionId */ 0, /* userId */ mUserId, mReceiver, TEST_OP_PACKAGE_NAME, new PromptInfo()); Loading @@ -356,7 +356,7 @@ public class AuthServiceTest { mAuthService.mImpl.authenticate( token, 0, /* sessionId */ 0, /* userId */ mUserId, mReceiver, TEST_OP_PACKAGE_NAME, new PromptInfo()); Loading Loading @@ -414,20 +414,19 @@ public class AuthServiceTest { mAuthService = new AuthService(mContext, mInjector); mAuthService.onStart(); final int userId = 0; final int expectedResult = BIOMETRIC_SUCCESS; final int authenticators = 0; when(mBiometricService.canAuthenticate(anyString(), anyInt(), anyInt(), anyInt())) .thenReturn(expectedResult); final int result = mAuthService.mImpl .canAuthenticate(TEST_OP_PACKAGE_NAME, userId, authenticators); .canAuthenticate(TEST_OP_PACKAGE_NAME, mUserId, authenticators); assertEquals(expectedResult, result); waitForIdle(); verify(mBiometricService).canAuthenticate( eq(TEST_OP_PACKAGE_NAME), eq(userId), eq(mUserId), eq(UserHandle.getCallingUserId()), eq(authenticators)); } Loading @@ -440,18 +439,17 @@ public class AuthServiceTest { mAuthService = new AuthService(mContext, mInjector); mAuthService.onStart(); final int userId = 0; final boolean expectedResult = true; when(mBiometricService.hasEnrolledBiometrics(anyInt(), anyString())).thenReturn( expectedResult); final boolean result = mAuthService.mImpl.hasEnrolledBiometrics(userId, final boolean result = mAuthService.mImpl.hasEnrolledBiometrics(mUserId, TEST_OP_PACKAGE_NAME); assertEquals(expectedResult, result); waitForIdle(); verify(mBiometricService).hasEnrolledBiometrics( eq(userId), eq(mUserId), eq(TEST_OP_PACKAGE_NAME)); } Loading Loading @@ -528,13 +526,12 @@ public class AuthServiceTest { mAuthService = new AuthService(mContext, mInjector); mAuthService.onStart(); final int userId = 0; final int authenticators = BiometricManager.Authenticators.BIOMETRIC_STRONG; mAuthService.mImpl.getLastAuthenticationTime(userId, authenticators); mAuthService.mImpl.getLastAuthenticationTime(mUserId, authenticators); waitForIdle(); verify(mBiometricService).getLastAuthenticationTime(eq(userId), eq(authenticators)); verify(mBiometricService).getLastAuthenticationTime(eq(mUserId), eq(authenticators)); } private static void setInternalAndTestBiometricPermissions( Loading