Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryForegroundViewModelTest.kt +57 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import com.android.systemui.coroutines.collectLastValue import com.android.systemui.keyguard.data.repository.fakeBiometricSettingsRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.shared.model.TransitionState import com.android.systemui.kosmos.testScope import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat Loading Loading @@ -58,6 +59,62 @@ class DeviceEntryForegroundViewModelTest : SysuiTestCase() { assertThat(viewModel?.tint).isEqualTo(Color.WHITE) } @Test fun startsDozing_doNotShowAodVariant() = testScope.runTest { val viewModel by collectLastValue(underTest.viewModel) givenUdfpsEnrolledAndEnabled() kosmos.run { fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.LOCKSCREEN, to = KeyguardState.DOZING, testScope = testScope, throughTransitionState = TransitionState.STARTED, ) } assertThat(viewModel?.useAodVariant).isEqualTo(false) } @Test fun finishedDozing_showAodVariant() = testScope.runTest { val viewModel by collectLastValue(underTest.viewModel) givenUdfpsEnrolledAndEnabled() kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.LOCKSCREEN, to = KeyguardState.AOD, testScope = testScope, throughTransitionState = TransitionState.FINISHED, ) assertThat(viewModel?.useAodVariant).isEqualTo(true) } @Test fun startTransitionToLockscreenFromDozing_doNotShowAodVariant() = testScope.runTest { val viewModel by collectLastValue(underTest.viewModel) givenUdfpsEnrolledAndEnabled() kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.LOCKSCREEN, to = KeyguardState.DOZING, testScope = testScope, throughTransitionState = TransitionState.FINISHED, ) kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.DOZING, to = KeyguardState.LOCKSCREEN, testScope = testScope, throughTransitionState = TransitionState.RUNNING, ) assertThat(viewModel?.useAodVariant).isEqualTo(false) } private fun givenUdfpsEnrolledAndEnabled() { kosmos.fakeFingerprintPropertyRepository.supportsUdfps() kosmos.fakeBiometricSettingsRepository.setIsFingerprintAuthEnrolledAndEnabled(true) Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryForegroundViewModel.kt +5 −2 Original line number Diff line number Diff line Loading @@ -52,8 +52,11 @@ constructor( udfpsOverlayInteractor: UdfpsOverlayInteractor, ) { private val isShowingAodOrDozing: Flow<Boolean> = transitionInteractor.startedKeyguardState.map { keyguardState -> keyguardState == KeyguardState.AOD || keyguardState == KeyguardState.DOZING combine( transitionInteractor.startedKeyguardState, transitionInteractor.transitionValue(KeyguardState.DOZING), ) { startedKeyguardState, dozingTransitionValue -> startedKeyguardState == KeyguardState.AOD || dozingTransitionValue == 1f } private fun getColor(usingBackgroundProtection: Boolean): Int { Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryForegroundViewModelTest.kt +57 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import com.android.systemui.coroutines.collectLastValue import com.android.systemui.keyguard.data.repository.fakeBiometricSettingsRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.shared.model.TransitionState import com.android.systemui.kosmos.testScope import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat Loading Loading @@ -58,6 +59,62 @@ class DeviceEntryForegroundViewModelTest : SysuiTestCase() { assertThat(viewModel?.tint).isEqualTo(Color.WHITE) } @Test fun startsDozing_doNotShowAodVariant() = testScope.runTest { val viewModel by collectLastValue(underTest.viewModel) givenUdfpsEnrolledAndEnabled() kosmos.run { fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.LOCKSCREEN, to = KeyguardState.DOZING, testScope = testScope, throughTransitionState = TransitionState.STARTED, ) } assertThat(viewModel?.useAodVariant).isEqualTo(false) } @Test fun finishedDozing_showAodVariant() = testScope.runTest { val viewModel by collectLastValue(underTest.viewModel) givenUdfpsEnrolledAndEnabled() kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.LOCKSCREEN, to = KeyguardState.AOD, testScope = testScope, throughTransitionState = TransitionState.FINISHED, ) assertThat(viewModel?.useAodVariant).isEqualTo(true) } @Test fun startTransitionToLockscreenFromDozing_doNotShowAodVariant() = testScope.runTest { val viewModel by collectLastValue(underTest.viewModel) givenUdfpsEnrolledAndEnabled() kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.LOCKSCREEN, to = KeyguardState.DOZING, testScope = testScope, throughTransitionState = TransitionState.FINISHED, ) kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.DOZING, to = KeyguardState.LOCKSCREEN, testScope = testScope, throughTransitionState = TransitionState.RUNNING, ) assertThat(viewModel?.useAodVariant).isEqualTo(false) } private fun givenUdfpsEnrolledAndEnabled() { kosmos.fakeFingerprintPropertyRepository.supportsUdfps() kosmos.fakeBiometricSettingsRepository.setIsFingerprintAuthEnrolledAndEnabled(true) Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryForegroundViewModel.kt +5 −2 Original line number Diff line number Diff line Loading @@ -52,8 +52,11 @@ constructor( udfpsOverlayInteractor: UdfpsOverlayInteractor, ) { private val isShowingAodOrDozing: Flow<Boolean> = transitionInteractor.startedKeyguardState.map { keyguardState -> keyguardState == KeyguardState.AOD || keyguardState == KeyguardState.DOZING combine( transitionInteractor.startedKeyguardState, transitionInteractor.transitionValue(KeyguardState.DOZING), ) { startedKeyguardState, dozingTransitionValue -> startedKeyguardState == KeyguardState.AOD || dozingTransitionValue == 1f } private fun getColor(usingBackgroundProtection: Boolean): Int { Loading