Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/KeyguardTransitionAnimationFlowTest.kt +25 −31 Original line number Diff line number Diff line Loading @@ -57,9 +57,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { duration = 1000.milliseconds, edge = Edge.create(from = Scenes.Gone, to = DREAMING), ) .setupWithoutSceneContainer( edge = Edge.create(from = GONE, to = DREAMING), ) .setupWithoutSceneContainer(edge = Edge.create(from = GONE, to = DREAMING)) } @Test(expected = IllegalArgumentException::class) Loading @@ -75,7 +73,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { underTest.sharedFlow( startTime = 300.milliseconds, duration = 800.milliseconds, onStep = { it } onStep = { it }, ) } Loading Loading @@ -111,6 +109,17 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { assertThat(animationValues()).isEqualTo(100f) } @Test fun onStepReturnsNullEmitsNothing() = testScope.runTest { val flow = underTest.sharedFlow(duration = 100.milliseconds, onStep = { null }) var animationValues = collectLastValue(flow) runCurrent() repository.sendTransitionStep(step(0.5f, TransitionState.RUNNING)) assertThat(animationValues()).isNull() } @Test fun usesStartTime() = testScope.runTest { Loading Loading @@ -166,11 +175,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { @Test fun usesOnStepToDoubleValue() = testScope.runTest { val flow = underTest.sharedFlow( duration = 1000.milliseconds, onStep = { it * 2 }, ) val flow = underTest.sharedFlow(duration = 1000.milliseconds, onStep = { it * 2 }) val animationValues by collectLastValue(flow) runCurrent() Loading @@ -190,10 +195,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { fun usesOnStepToDoubleValueWithState() = testScope.runTest { val flow = underTest.sharedFlowWithState( duration = 1000.milliseconds, onStep = { it * 2 }, ) underTest.sharedFlowWithState(duration = 1000.milliseconds, onStep = { it * 2 }) val animationValues by collectLastValue(flow) runCurrent() Loading @@ -204,7 +206,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { from = GONE, to = DREAMING, transitionState = TransitionState.STARTED, value = 0f value = 0f, ) ) repository.sendTransitionStep(step(0.3f, TransitionState.RUNNING)) Loading @@ -214,7 +216,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { from = GONE, to = DREAMING, transitionState = TransitionState.RUNNING, value = 0.6f value = 0.6f, ) ) repository.sendTransitionStep(step(0.6f, TransitionState.RUNNING)) Loading @@ -224,7 +226,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { from = GONE, to = DREAMING, transitionState = TransitionState.RUNNING, value = 1.2f value = 1.2f, ) ) repository.sendTransitionStep(step(0.8f, TransitionState.RUNNING)) Loading @@ -234,7 +236,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { from = GONE, to = DREAMING, transitionState = TransitionState.RUNNING, value = 1.6f value = 1.6f, ) ) repository.sendTransitionStep(step(1f, TransitionState.RUNNING)) Loading @@ -244,7 +246,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { from = GONE, to = DREAMING, transitionState = TransitionState.RUNNING, value = 2f value = 2f, ) ) repository.sendTransitionStep(step(1f, TransitionState.FINISHED)) Loading @@ -254,7 +256,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { from = GONE, to = DREAMING, transitionState = TransitionState.FINISHED, value = null value = null, ) ) } Loading @@ -262,11 +264,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { @Test fun sameFloatValueWithTheSameTransitionStateDoesNotEmitTwice() = testScope.runTest { val flow = underTest.sharedFlow( duration = 1000.milliseconds, onStep = { it }, ) val flow = underTest.sharedFlow(duration = 1000.milliseconds, onStep = { it }) val values by collectValues(flow) runCurrent() Loading @@ -280,11 +278,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { @Test fun sameFloatValueWithADifferentTransitionStateDoesEmitTwice() = testScope.runTest { val flow = underTest.sharedFlow( duration = 1000.milliseconds, onStep = { it }, ) val flow = underTest.sharedFlow(duration = 1000.milliseconds, onStep = { it }) val values by collectValues(flow) runCurrent() Loading @@ -302,14 +296,14 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { private fun step( value: Float, state: TransitionState = TransitionState.RUNNING state: TransitionState = TransitionState.RUNNING, ): TransitionStep { return TransitionStep( from = GONE, to = DREAMING, value = value, transitionState = state, ownerName = "GoneToDreamingTransitionViewModelTest" ownerName = "GoneToDreamingTransitionViewModelTest", ) } } packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryBackgroundViewModelTest.kt +10 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import com.android.systemui.coroutines.collectLastValue 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.keyguard.shared.model.TransitionState.FINISHED import com.android.systemui.keyguard.shared.model.TransitionState.RUNNING import com.android.systemui.keyguard.shared.model.TransitionState.STARTED import com.android.systemui.keyguard.shared.model.TransitionStep Loading Loading @@ -63,7 +64,15 @@ class DeviceEntryBackgroundViewModelTest : SysuiTestCase() { ) runCurrent() assertThat(alpha).isEqualTo(0.0f) assertThat(alpha).isEqualTo(1.0f) kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps( listOf(lockscreenToDozing(1f, FINISHED)), testScope, ) runCurrent() assertThat(alpha).isEqualTo(0f) } private fun lockscreenToDozing(value: Float, state: TransitionState = RUNNING): TransitionStep { Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/KeyguardTransitionAnimationFlow.kt +5 −2 Original line number Diff line number Diff line Loading @@ -66,11 +66,14 @@ constructor( * range. This function maps the [startTime] and [duration] into [0, 1], when this subset is * valid. * * Note that [onStep] accepts a null return value. When null, no animation information will * be emitted, effectively saying "do not change the value on this frame" * * Note that [onCancel] isn't used when the scene framework is enabled. */ fun sharedFlow( duration: Duration = transitionDuration, onStep: (Float) -> Float, onStep: (Float) -> Float?, startTime: Duration = 0.milliseconds, onStart: (() -> Unit)? = null, onCancel: (() -> Float)? = null, Loading Loading @@ -102,7 +105,7 @@ constructor( */ fun sharedFlowWithState( duration: Duration, onStep: (Float) -> Float, onStep: (Float) -> Float?, startTime: Duration = 0.milliseconds, onStart: (() -> Unit)? = null, onCancel: (() -> Float)? = null, Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenToDozingTransitionViewModel.kt +6 −1 Original line number Diff line number Diff line Loading @@ -54,7 +54,12 @@ constructor( ) val deviceEntryBackgroundViewAlpha: Flow<Float> = transitionAnimation.immediatelyTransitionTo(0f) transitionAnimation.sharedFlow( duration = TO_DOZING_DURATION, onStep = { null }, onFinish = { 0f }, onCancel = { 0f }, ) override val deviceEntryParentViewAlpha: Flow<Float> = deviceEntryUdfpsInteractor.isUdfpsEnrolledAndEnabled.flatMapLatest { Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/KeyguardTransitionAnimationFlowTest.kt +25 −31 Original line number Diff line number Diff line Loading @@ -57,9 +57,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { duration = 1000.milliseconds, edge = Edge.create(from = Scenes.Gone, to = DREAMING), ) .setupWithoutSceneContainer( edge = Edge.create(from = GONE, to = DREAMING), ) .setupWithoutSceneContainer(edge = Edge.create(from = GONE, to = DREAMING)) } @Test(expected = IllegalArgumentException::class) Loading @@ -75,7 +73,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { underTest.sharedFlow( startTime = 300.milliseconds, duration = 800.milliseconds, onStep = { it } onStep = { it }, ) } Loading Loading @@ -111,6 +109,17 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { assertThat(animationValues()).isEqualTo(100f) } @Test fun onStepReturnsNullEmitsNothing() = testScope.runTest { val flow = underTest.sharedFlow(duration = 100.milliseconds, onStep = { null }) var animationValues = collectLastValue(flow) runCurrent() repository.sendTransitionStep(step(0.5f, TransitionState.RUNNING)) assertThat(animationValues()).isNull() } @Test fun usesStartTime() = testScope.runTest { Loading Loading @@ -166,11 +175,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { @Test fun usesOnStepToDoubleValue() = testScope.runTest { val flow = underTest.sharedFlow( duration = 1000.milliseconds, onStep = { it * 2 }, ) val flow = underTest.sharedFlow(duration = 1000.milliseconds, onStep = { it * 2 }) val animationValues by collectLastValue(flow) runCurrent() Loading @@ -190,10 +195,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { fun usesOnStepToDoubleValueWithState() = testScope.runTest { val flow = underTest.sharedFlowWithState( duration = 1000.milliseconds, onStep = { it * 2 }, ) underTest.sharedFlowWithState(duration = 1000.milliseconds, onStep = { it * 2 }) val animationValues by collectLastValue(flow) runCurrent() Loading @@ -204,7 +206,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { from = GONE, to = DREAMING, transitionState = TransitionState.STARTED, value = 0f value = 0f, ) ) repository.sendTransitionStep(step(0.3f, TransitionState.RUNNING)) Loading @@ -214,7 +216,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { from = GONE, to = DREAMING, transitionState = TransitionState.RUNNING, value = 0.6f value = 0.6f, ) ) repository.sendTransitionStep(step(0.6f, TransitionState.RUNNING)) Loading @@ -224,7 +226,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { from = GONE, to = DREAMING, transitionState = TransitionState.RUNNING, value = 1.2f value = 1.2f, ) ) repository.sendTransitionStep(step(0.8f, TransitionState.RUNNING)) Loading @@ -234,7 +236,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { from = GONE, to = DREAMING, transitionState = TransitionState.RUNNING, value = 1.6f value = 1.6f, ) ) repository.sendTransitionStep(step(1f, TransitionState.RUNNING)) Loading @@ -244,7 +246,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { from = GONE, to = DREAMING, transitionState = TransitionState.RUNNING, value = 2f value = 2f, ) ) repository.sendTransitionStep(step(1f, TransitionState.FINISHED)) Loading @@ -254,7 +256,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { from = GONE, to = DREAMING, transitionState = TransitionState.FINISHED, value = null value = null, ) ) } Loading @@ -262,11 +264,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { @Test fun sameFloatValueWithTheSameTransitionStateDoesNotEmitTwice() = testScope.runTest { val flow = underTest.sharedFlow( duration = 1000.milliseconds, onStep = { it }, ) val flow = underTest.sharedFlow(duration = 1000.milliseconds, onStep = { it }) val values by collectValues(flow) runCurrent() Loading @@ -280,11 +278,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { @Test fun sameFloatValueWithADifferentTransitionStateDoesEmitTwice() = testScope.runTest { val flow = underTest.sharedFlow( duration = 1000.milliseconds, onStep = { it }, ) val flow = underTest.sharedFlow(duration = 1000.milliseconds, onStep = { it }) val values by collectValues(flow) runCurrent() Loading @@ -302,14 +296,14 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { private fun step( value: Float, state: TransitionState = TransitionState.RUNNING state: TransitionState = TransitionState.RUNNING, ): TransitionStep { return TransitionStep( from = GONE, to = DREAMING, value = value, transitionState = state, ownerName = "GoneToDreamingTransitionViewModelTest" ownerName = "GoneToDreamingTransitionViewModelTest", ) } }
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryBackgroundViewModelTest.kt +10 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import com.android.systemui.coroutines.collectLastValue 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.keyguard.shared.model.TransitionState.FINISHED import com.android.systemui.keyguard.shared.model.TransitionState.RUNNING import com.android.systemui.keyguard.shared.model.TransitionState.STARTED import com.android.systemui.keyguard.shared.model.TransitionStep Loading Loading @@ -63,7 +64,15 @@ class DeviceEntryBackgroundViewModelTest : SysuiTestCase() { ) runCurrent() assertThat(alpha).isEqualTo(0.0f) assertThat(alpha).isEqualTo(1.0f) kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps( listOf(lockscreenToDozing(1f, FINISHED)), testScope, ) runCurrent() assertThat(alpha).isEqualTo(0f) } private fun lockscreenToDozing(value: Float, state: TransitionState = RUNNING): TransitionStep { Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/KeyguardTransitionAnimationFlow.kt +5 −2 Original line number Diff line number Diff line Loading @@ -66,11 +66,14 @@ constructor( * range. This function maps the [startTime] and [duration] into [0, 1], when this subset is * valid. * * Note that [onStep] accepts a null return value. When null, no animation information will * be emitted, effectively saying "do not change the value on this frame" * * Note that [onCancel] isn't used when the scene framework is enabled. */ fun sharedFlow( duration: Duration = transitionDuration, onStep: (Float) -> Float, onStep: (Float) -> Float?, startTime: Duration = 0.milliseconds, onStart: (() -> Unit)? = null, onCancel: (() -> Float)? = null, Loading Loading @@ -102,7 +105,7 @@ constructor( */ fun sharedFlowWithState( duration: Duration, onStep: (Float) -> Float, onStep: (Float) -> Float?, startTime: Duration = 0.milliseconds, onStart: (() -> Unit)? = null, onCancel: (() -> Float)? = null, Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenToDozingTransitionViewModel.kt +6 −1 Original line number Diff line number Diff line Loading @@ -54,7 +54,12 @@ constructor( ) val deviceEntryBackgroundViewAlpha: Flow<Float> = transitionAnimation.immediatelyTransitionTo(0f) transitionAnimation.sharedFlow( duration = TO_DOZING_DURATION, onStep = { null }, onFinish = { 0f }, onCancel = { 0f }, ) override val deviceEntryParentViewAlpha: Flow<Float> = deviceEntryUdfpsInteractor.isUdfpsEnrolledAndEnabled.flatMapLatest { Loading