Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryIconViewModelTest.kt +16 −44 Original line number Diff line number Diff line Loading @@ -71,10 +71,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() { fun isLongPressEnabled_udfpsRunning() = testScope.runTest { val isLongPressEnabled by collectLastValue(underTest.isLongPressEnabled) setUpState( isUdfpsSupported = true, isUdfpsRunning = true, ) setUpState(isUdfpsSupported = true, isUdfpsRunning = true) assertThat(isLongPressEnabled).isFalse() } Loading @@ -82,10 +79,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() { fun isLongPressEnabled_unlocked() = testScope.runTest { val isLongPressEnabled by collectLastValue(underTest.isLongPressEnabled) setUpState( isUdfpsSupported = true, isLockscreenDismissible = true, ) setUpState(isUdfpsSupported = true, hasTrust = true) assertThat(isLongPressEnabled).isTrue() } Loading Loading @@ -122,10 +116,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() { fun iconType_fingerprint() = testScope.runTest { val iconType by collectLastValue(underTest.iconType) setUpState( isUdfpsSupported = true, isUdfpsRunning = true, ) setUpState(isUdfpsSupported = true, isUdfpsRunning = true) assertThat(iconType).isEqualTo(DeviceEntryIconView.IconType.FINGERPRINT) } Loading @@ -143,7 +134,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() { fun iconType_unlocked() = testScope.runTest { val iconType by collectLastValue(underTest.iconType) setUpState(isLockscreenDismissible = true) setUpState(hasTrust = true) assertThat(iconType).isEqualTo(DeviceEntryIconView.IconType.UNLOCK) } Loading @@ -152,11 +143,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() { fun iconType_none() = testScope.runTest { val iconType by collectLastValue(underTest.iconType) setUpState( isUdfpsSupported = true, isUdfpsRunning = true, isLockscreenDismissible = true, ) setUpState(isUdfpsSupported = true, isUdfpsRunning = true, hasTrust = true) assertThat(iconType).isEqualTo(DeviceEntryIconView.IconType.NONE) } Loading @@ -165,10 +152,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() { fun iconType_fingerprint_withSceneContainer() = testScope.runTest { val iconType by collectLastValue(underTest.iconType) setUpState( isUdfpsSupported = true, isUdfpsRunning = true, ) setUpState(isUdfpsSupported = true, isUdfpsRunning = true) assertThat(iconType).isEqualTo(DeviceEntryIconView.IconType.FINGERPRINT) } Loading @@ -186,9 +170,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() { fun iconType_unlocked_withSceneContainer() = testScope.runTest { val iconType by collectLastValue(underTest.iconType) setUpState( isLockscreenDismissible = true, ) setUpState(hasTrust = true) assertThat(iconType).isEqualTo(DeviceEntryIconView.IconType.UNLOCK) } Loading @@ -197,11 +179,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() { fun iconType_none_withSceneContainer() = testScope.runTest { val iconType by collectLastValue(underTest.iconType) setUpState( isUdfpsSupported = true, isUdfpsRunning = true, isLockscreenDismissible = true, ) setUpState(isUdfpsSupported = true, isUdfpsRunning = true, hasTrust = true) assertThat(iconType).isEqualTo(DeviceEntryIconView.IconType.NONE) } Loading @@ -226,10 +204,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() { .isEqualTo(DeviceEntryIconView.AccessibilityHintType.BOUNCER) // udfps running setUpState( isUdfpsSupported = true, isUdfpsRunning = true, ) setUpState(isUdfpsSupported = true, isUdfpsRunning = true) assertThat(accessibilityDelegateHint) .isEqualTo(DeviceEntryIconView.AccessibilityHintType.BOUNCER) Loading @@ -248,10 +223,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() { kosmos.fakeAccessibilityRepository.isEnabled.value = true // interactive unlock icon setUpState( isUdfpsSupported = true, isLockscreenDismissible = true, ) setUpState(isUdfpsSupported = true, hasTrust = true) assertThat(accessibilityDelegateHint) .isEqualTo(DeviceEntryIconView.AccessibilityHintType.ENTER) Loading @@ -264,7 +236,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() { private suspend fun TestScope.setUpState( isUdfpsSupported: Boolean = false, isUdfpsRunning: Boolean = false, isLockscreenDismissible: Boolean = false, hasTrust: Boolean = false, ) { if (isUdfpsSupported) { fingerprintPropertyRepository.supportsUdfps() Loading @@ -275,17 +247,17 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() { } else { fingerprintAuthRepository.setIsRunning(false) } if (isLockscreenDismissible) { setLockscreenDismissible() if (hasTrust) { setHasTrust() } else { if (!SceneContainerFlag.isEnabled) { keyguardRepository.setKeyguardDismissible(false) keyguardRepository.setHasTrust(false) } } runCurrent() } private suspend fun TestScope.setLockscreenDismissible() { private suspend fun TestScope.setHasTrust() { if (SceneContainerFlag.isEnabled) { // Need to set up a collection for the authentication to be propagated. val unused by collectLastValue(kosmos.deviceUnlockedInteractor.deviceUnlockStatus) Loading @@ -297,7 +269,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() { ) .isEqualTo(AuthenticationResult.SUCCEEDED) } else { keyguardRepository.setKeyguardDismissible(true) keyguardRepository.setHasTrust(true) } advanceTimeBy(UNLOCKED_DELAY_MS * 2) // wait for unlocked delay } Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/GoneToAodTransitionViewModelTest.kt +6 −9 Original line number Diff line number Diff line Loading @@ -227,20 +227,17 @@ class GoneToAodTransitionViewModelTest : SysuiTestCase() { val deviceEntryParentViewAlpha by collectLastValue(underTest.deviceEntryParentViewAlpha) runCurrent() // animation doesn't start until the end // immediately 1f repository.sendTransitionStep(step(0f, TransitionState.STARTED)) assertThat(deviceEntryParentViewAlpha).isEqualTo(0f) assertThat(deviceEntryParentViewAlpha).isEqualTo(1f) repository.sendTransitionStep(step(0.5f)) assertThat(deviceEntryParentViewAlpha).isEqualTo(0f) repository.sendTransitionStep(step(0.4f)) assertThat(deviceEntryParentViewAlpha).isEqualTo(1f) repository.sendTransitionStep(step(.95f)) assertThat(deviceEntryParentViewAlpha).isIn(Range.closed(.01f, 1f)) repository.sendTransitionStep(step(.85f)) assertThat(deviceEntryParentViewAlpha).isEqualTo(1f) repository.sendTransitionStep(step(1f)) assertThat(deviceEntryParentViewAlpha).isIn(Range.closed(.99f, 1f)) repository.sendTransitionStep(step(1f, TransitionState.FINISHED)) assertThat(deviceEntryParentViewAlpha).isEqualTo(1f) } Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryIconViewModel.kt +1 −1 Original line number Diff line number Diff line Loading @@ -191,7 +191,7 @@ constructor( if (SceneContainerFlag.isEnabled) { deviceEntryInteractor.isUnlocked } else { keyguardInteractor.isKeyguardDismissible keyguardInteractor.hasTrust } .flatMapLatest { isUnlocked -> if (!isUnlocked) { Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/GoneToAodTransitionViewModel.kt +1 −9 Original line number Diff line number Diff line Loading @@ -108,15 +108,7 @@ constructor( override val deviceEntryParentViewAlpha: Flow<Float> = deviceEntryUdfpsInteractor.isUdfpsEnrolledAndEnabled.flatMapLatest { udfpsEnrolled -> if (udfpsEnrolled) { // fade in at the end of the transition to give time for FP to start running // and avoid a flicker of the unlocked icon transitionAnimation.sharedFlow( startTime = 1100.milliseconds, duration = 200.milliseconds, onStep = { it }, onCancel = { 1f }, onFinish = { 1f }, ) transitionAnimation.immediatelyTransitionTo(1f) } else { emptyFlow() } Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryIconViewModelTest.kt +16 −44 Original line number Diff line number Diff line Loading @@ -71,10 +71,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() { fun isLongPressEnabled_udfpsRunning() = testScope.runTest { val isLongPressEnabled by collectLastValue(underTest.isLongPressEnabled) setUpState( isUdfpsSupported = true, isUdfpsRunning = true, ) setUpState(isUdfpsSupported = true, isUdfpsRunning = true) assertThat(isLongPressEnabled).isFalse() } Loading @@ -82,10 +79,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() { fun isLongPressEnabled_unlocked() = testScope.runTest { val isLongPressEnabled by collectLastValue(underTest.isLongPressEnabled) setUpState( isUdfpsSupported = true, isLockscreenDismissible = true, ) setUpState(isUdfpsSupported = true, hasTrust = true) assertThat(isLongPressEnabled).isTrue() } Loading Loading @@ -122,10 +116,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() { fun iconType_fingerprint() = testScope.runTest { val iconType by collectLastValue(underTest.iconType) setUpState( isUdfpsSupported = true, isUdfpsRunning = true, ) setUpState(isUdfpsSupported = true, isUdfpsRunning = true) assertThat(iconType).isEqualTo(DeviceEntryIconView.IconType.FINGERPRINT) } Loading @@ -143,7 +134,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() { fun iconType_unlocked() = testScope.runTest { val iconType by collectLastValue(underTest.iconType) setUpState(isLockscreenDismissible = true) setUpState(hasTrust = true) assertThat(iconType).isEqualTo(DeviceEntryIconView.IconType.UNLOCK) } Loading @@ -152,11 +143,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() { fun iconType_none() = testScope.runTest { val iconType by collectLastValue(underTest.iconType) setUpState( isUdfpsSupported = true, isUdfpsRunning = true, isLockscreenDismissible = true, ) setUpState(isUdfpsSupported = true, isUdfpsRunning = true, hasTrust = true) assertThat(iconType).isEqualTo(DeviceEntryIconView.IconType.NONE) } Loading @@ -165,10 +152,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() { fun iconType_fingerprint_withSceneContainer() = testScope.runTest { val iconType by collectLastValue(underTest.iconType) setUpState( isUdfpsSupported = true, isUdfpsRunning = true, ) setUpState(isUdfpsSupported = true, isUdfpsRunning = true) assertThat(iconType).isEqualTo(DeviceEntryIconView.IconType.FINGERPRINT) } Loading @@ -186,9 +170,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() { fun iconType_unlocked_withSceneContainer() = testScope.runTest { val iconType by collectLastValue(underTest.iconType) setUpState( isLockscreenDismissible = true, ) setUpState(hasTrust = true) assertThat(iconType).isEqualTo(DeviceEntryIconView.IconType.UNLOCK) } Loading @@ -197,11 +179,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() { fun iconType_none_withSceneContainer() = testScope.runTest { val iconType by collectLastValue(underTest.iconType) setUpState( isUdfpsSupported = true, isUdfpsRunning = true, isLockscreenDismissible = true, ) setUpState(isUdfpsSupported = true, isUdfpsRunning = true, hasTrust = true) assertThat(iconType).isEqualTo(DeviceEntryIconView.IconType.NONE) } Loading @@ -226,10 +204,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() { .isEqualTo(DeviceEntryIconView.AccessibilityHintType.BOUNCER) // udfps running setUpState( isUdfpsSupported = true, isUdfpsRunning = true, ) setUpState(isUdfpsSupported = true, isUdfpsRunning = true) assertThat(accessibilityDelegateHint) .isEqualTo(DeviceEntryIconView.AccessibilityHintType.BOUNCER) Loading @@ -248,10 +223,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() { kosmos.fakeAccessibilityRepository.isEnabled.value = true // interactive unlock icon setUpState( isUdfpsSupported = true, isLockscreenDismissible = true, ) setUpState(isUdfpsSupported = true, hasTrust = true) assertThat(accessibilityDelegateHint) .isEqualTo(DeviceEntryIconView.AccessibilityHintType.ENTER) Loading @@ -264,7 +236,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() { private suspend fun TestScope.setUpState( isUdfpsSupported: Boolean = false, isUdfpsRunning: Boolean = false, isLockscreenDismissible: Boolean = false, hasTrust: Boolean = false, ) { if (isUdfpsSupported) { fingerprintPropertyRepository.supportsUdfps() Loading @@ -275,17 +247,17 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() { } else { fingerprintAuthRepository.setIsRunning(false) } if (isLockscreenDismissible) { setLockscreenDismissible() if (hasTrust) { setHasTrust() } else { if (!SceneContainerFlag.isEnabled) { keyguardRepository.setKeyguardDismissible(false) keyguardRepository.setHasTrust(false) } } runCurrent() } private suspend fun TestScope.setLockscreenDismissible() { private suspend fun TestScope.setHasTrust() { if (SceneContainerFlag.isEnabled) { // Need to set up a collection for the authentication to be propagated. val unused by collectLastValue(kosmos.deviceUnlockedInteractor.deviceUnlockStatus) Loading @@ -297,7 +269,7 @@ class DeviceEntryIconViewModelTest : SysuiTestCase() { ) .isEqualTo(AuthenticationResult.SUCCEEDED) } else { keyguardRepository.setKeyguardDismissible(true) keyguardRepository.setHasTrust(true) } advanceTimeBy(UNLOCKED_DELAY_MS * 2) // wait for unlocked delay } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/GoneToAodTransitionViewModelTest.kt +6 −9 Original line number Diff line number Diff line Loading @@ -227,20 +227,17 @@ class GoneToAodTransitionViewModelTest : SysuiTestCase() { val deviceEntryParentViewAlpha by collectLastValue(underTest.deviceEntryParentViewAlpha) runCurrent() // animation doesn't start until the end // immediately 1f repository.sendTransitionStep(step(0f, TransitionState.STARTED)) assertThat(deviceEntryParentViewAlpha).isEqualTo(0f) assertThat(deviceEntryParentViewAlpha).isEqualTo(1f) repository.sendTransitionStep(step(0.5f)) assertThat(deviceEntryParentViewAlpha).isEqualTo(0f) repository.sendTransitionStep(step(0.4f)) assertThat(deviceEntryParentViewAlpha).isEqualTo(1f) repository.sendTransitionStep(step(.95f)) assertThat(deviceEntryParentViewAlpha).isIn(Range.closed(.01f, 1f)) repository.sendTransitionStep(step(.85f)) assertThat(deviceEntryParentViewAlpha).isEqualTo(1f) repository.sendTransitionStep(step(1f)) assertThat(deviceEntryParentViewAlpha).isIn(Range.closed(.99f, 1f)) repository.sendTransitionStep(step(1f, TransitionState.FINISHED)) assertThat(deviceEntryParentViewAlpha).isEqualTo(1f) } Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryIconViewModel.kt +1 −1 Original line number Diff line number Diff line Loading @@ -191,7 +191,7 @@ constructor( if (SceneContainerFlag.isEnabled) { deviceEntryInteractor.isUnlocked } else { keyguardInteractor.isKeyguardDismissible keyguardInteractor.hasTrust } .flatMapLatest { isUnlocked -> if (!isUnlocked) { Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/GoneToAodTransitionViewModel.kt +1 −9 Original line number Diff line number Diff line Loading @@ -108,15 +108,7 @@ constructor( override val deviceEntryParentViewAlpha: Flow<Float> = deviceEntryUdfpsInteractor.isUdfpsEnrolledAndEnabled.flatMapLatest { udfpsEnrolled -> if (udfpsEnrolled) { // fade in at the end of the transition to give time for FP to start running // and avoid a flicker of the unlocked icon transitionAnimation.sharedFlow( startTime = 1100.milliseconds, duration = 200.milliseconds, onStep = { it }, onCancel = { 1f }, onFinish = { 1f }, ) transitionAnimation.immediatelyTransitionTo(1f) } else { emptyFlow() } Loading