Move haptic from authenticated to confirmed (when required).
Fix: 272832355 Test: atest PromptViewModelTest (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:e072fe34e4dec7b5c5fbaed14fbac7936d45ee56) Merged-In: I8d9324384680367af7991eab9b5ce42bf378e8bc Change-Id: I8d9324384680367af7991eab9b5ce42bf378e8bc
This commit is contained in:
committed by
Cherrypicker Worker
parent
b829ba97bc
commit
ee846efe13
@@ -372,7 +372,9 @@ constructor(
|
||||
AuthBiometricView.STATE_AUTHENTICATED
|
||||
}
|
||||
|
||||
vibrator.success(modality)
|
||||
if (!needsUserConfirmation) {
|
||||
vibrator.success(modality)
|
||||
}
|
||||
|
||||
messageJob?.cancel()
|
||||
messageJob = null
|
||||
@@ -418,6 +420,8 @@ constructor(
|
||||
_message.value = PromptMessage.Empty
|
||||
_legacyState.value = AuthBiometricView.STATE_AUTHENTICATED
|
||||
|
||||
vibrator.success(authState.authenticatedModality)
|
||||
|
||||
messageJob?.cancel()
|
||||
messageJob = null
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ import org.junit.runner.RunWith
|
||||
import org.junit.runners.Parameterized
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.never
|
||||
import org.mockito.Mockito.times
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.junit.MockitoJUnit
|
||||
|
||||
@@ -131,20 +132,22 @@ internal class PromptViewModelTest(private val testCase: TestCase) : SysuiTestCa
|
||||
}
|
||||
|
||||
@Test
|
||||
fun plays_haptic_on_authenticated() = runGenericTest {
|
||||
viewModel.showAuthenticated(testCase.authenticatedModality, 1000L)
|
||||
fun play_haptic_on_confirm_when_confirmation_required_otherwise_on_authenticated() =
|
||||
runGenericTest {
|
||||
val expectConfirmation = testCase.expectConfirmation(atLeastOneFailure = false)
|
||||
|
||||
verify(vibrator).vibrateAuthSuccess(any())
|
||||
verify(vibrator, never()).vibrateAuthError(any())
|
||||
}
|
||||
viewModel.showAuthenticated(testCase.authenticatedModality, 1_000L)
|
||||
|
||||
@Test
|
||||
fun plays_no_haptic_on_confirm() = runGenericTest {
|
||||
viewModel.confirmAuthenticated()
|
||||
verify(vibrator, if (expectConfirmation) never() else times(1))
|
||||
.vibrateAuthSuccess(any())
|
||||
|
||||
verify(vibrator, never()).vibrateAuthSuccess(any())
|
||||
verify(vibrator, never()).vibrateAuthError(any())
|
||||
}
|
||||
if (expectConfirmation) {
|
||||
viewModel.confirmAuthenticated()
|
||||
}
|
||||
|
||||
verify(vibrator).vibrateAuthSuccess(any())
|
||||
verify(vibrator, never()).vibrateAuthError(any())
|
||||
}
|
||||
|
||||
private suspend fun TestScope.showAuthenticated(
|
||||
authenticatedModality: BiometricModality,
|
||||
|
||||
Reference in New Issue
Block a user