Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/KeyguardTransitionAnimationFlowTest.kt +39 −36 Original line number Diff line number Diff line Loading @@ -20,22 +20,22 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.app.animation.Interpolators.EMPHASIZED_ACCELERATE import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectValues import com.android.systemui.flags.DisableSceneContainer import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.shared.model.Edge import com.android.systemui.keyguard.shared.model.KeyguardState.DREAMING import com.android.systemui.keyguard.shared.model.KeyguardState.GONE import com.android.systemui.keyguard.shared.model.KeyguardState.LOCKSCREEN import com.android.systemui.keyguard.shared.model.TransitionState import com.android.systemui.keyguard.shared.model.TransitionStep import com.android.systemui.kosmos.testScope import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.collectValues import com.android.systemui.kosmos.runCurrent import com.android.systemui.kosmos.runTest import com.android.systemui.shade.shadeTestUtil import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlin.time.Duration.Companion.milliseconds import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Test import org.junit.runner.RunWith Loading @@ -43,34 +43,34 @@ import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { val kosmos = testKosmos() val testScope = kosmos.testScope val animationFlow = kosmos.keyguardTransitionAnimationFlow val repository = kosmos.fakeKeyguardTransitionRepository val shadeTestUtil by lazy { kosmos.shadeTestUtil } private val kosmos = testKosmos() private lateinit var animationFlow: KeyguardTransitionAnimationFlow private lateinit var repository: FakeKeyguardTransitionRepository private lateinit var underTest: KeyguardTransitionAnimationFlow.FlowBuilder @Before fun setUp() { animationFlow = kosmos.keyguardTransitionAnimationFlow repository = kosmos.fakeKeyguardTransitionRepository underTest = animationFlow .setup( duration = 1000.milliseconds, edge = Edge.create(from = Scenes.Gone, to = DREAMING), edge = Edge.create(from = LOCKSCREEN, to = DREAMING), ) .setupWithoutSceneContainer(edge = Edge.create(from = GONE, to = DREAMING)) .setupWithoutSceneContainer(edge = Edge.create(from = LOCKSCREEN, to = DREAMING)) } @Test(expected = IllegalArgumentException::class) fun zeroDurationThrowsException() = testScope.runTest { kosmos.runTest { val flow = underTest.sharedFlow(duration = 0.milliseconds, onStep = { it }) } @Test(expected = IllegalArgumentException::class) fun startTimePlusDurationGreaterThanTransitionDurationThrowsException() = testScope.runTest { kosmos.runTest { val flow = underTest.sharedFlow( startTime = 300.milliseconds, Loading @@ -81,7 +81,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { @Test fun onFinishRunsWhenSpecified() = testScope.runTest { kosmos.runTest { val flow = underTest.sharedFlow( duration = 100.milliseconds, Loading @@ -96,8 +96,9 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { } @Test @DisableSceneContainer // CANCELED steps are filtered out when the scene framework is enabled. fun onCancelRunsWhenSpecified() = testScope.runTest { kosmos.runTest { val flow = underTest.sharedFlow( duration = 100.milliseconds, Loading @@ -113,7 +114,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { @Test fun onStepReturnsNullEmitsNothing() = testScope.runTest { kosmos.runTest { val flow = underTest.sharedFlow(duration = 100.milliseconds, onStep = { null }) var animationValues = collectLastValue(flow) runCurrent() Loading @@ -124,7 +125,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { @Test fun usesStartTime() = testScope.runTest { kosmos.runTest { val flow = underTest.sharedFlow( startTime = 500.milliseconds, Loading Loading @@ -152,7 +153,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { @Test fun usesInterpolator() = testScope.runTest { kosmos.runTest { val flow = underTest.sharedFlow( duration = 1000.milliseconds, Loading @@ -176,7 +177,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { @Test fun usesOnStepToDoubleValue() = testScope.runTest { kosmos.runTest { val flow = underTest.sharedFlow(duration = 1000.milliseconds, onStep = { it * 2 }) val animationValues by collectLastValue(flow) runCurrent() Loading @@ -195,7 +196,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { @Test fun usesOnStepToDoubleValueWithState() = testScope.runTest { kosmos.runTest { val flow = underTest.sharedFlowWithState(duration = 1000.milliseconds, onStep = { it * 2 }) val animationValues by collectLastValue(flow) Loading @@ -205,7 +206,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { assertThat(animationValues) .isEqualTo( StateToValue( from = GONE, from = LOCKSCREEN, to = DREAMING, transitionState = TransitionState.STARTED, value = 0f, Loading @@ -215,7 +216,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { assertThat(animationValues) .isEqualTo( StateToValue( from = GONE, from = LOCKSCREEN, to = DREAMING, transitionState = TransitionState.RUNNING, value = 0.6f, Loading @@ -225,7 +226,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { assertThat(animationValues) .isEqualTo( StateToValue( from = GONE, from = LOCKSCREEN, to = DREAMING, transitionState = TransitionState.RUNNING, value = 1.2f, Loading @@ -235,7 +236,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { assertThat(animationValues) .isEqualTo( StateToValue( from = GONE, from = LOCKSCREEN, to = DREAMING, transitionState = TransitionState.RUNNING, value = 1.6f, Loading @@ -245,7 +246,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { assertThat(animationValues) .isEqualTo( StateToValue( from = GONE, from = LOCKSCREEN, to = DREAMING, transitionState = TransitionState.RUNNING, value = 2f, Loading @@ -255,7 +256,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { assertThat(animationValues) .isEqualTo( StateToValue( from = GONE, from = LOCKSCREEN, to = DREAMING, transitionState = TransitionState.FINISHED, value = null, Loading @@ -265,7 +266,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { @Test fun sameFloatValueWithTheSameTransitionStateDoesNotEmitTwice() = testScope.runTest { kosmos.runTest { val flow = underTest.sharedFlow(duration = 1000.milliseconds, onStep = { it }) val values by collectValues(flow) runCurrent() Loading @@ -279,7 +280,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { @Test fun sameFloatValueWithADifferentTransitionStateDoesEmitTwice() = testScope.runTest { kosmos.runTest { val flow = underTest.sharedFlow(duration = 1000.milliseconds, onStep = { it }) val values by collectValues(flow) runCurrent() Loading @@ -294,7 +295,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { @Test fun sharedFlowWithShadeExpanded() = testScope.runTest { kosmos.runTest { val flow = underTest.sharedFlowWithShade( duration = 1000.milliseconds, Loading @@ -313,7 +314,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { @Test fun sharedFlowWithShadeNotExpanded() = testScope.runTest { kosmos.runTest { val flow = underTest.sharedFlowWithShade( duration = 1000.milliseconds, Loading @@ -331,8 +332,9 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { } @Test @DisableSceneContainer // CANCELED steps are filtered out when the scene framework is enabled. fun sharedFlowWithShadeExpanded_onCancelRunsWhenSpecified() = testScope.runTest { kosmos.runTest { val flow = underTest.sharedFlowWithShade( duration = 100.milliseconds, Loading @@ -348,8 +350,9 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { } @Test @DisableSceneContainer // CANCELED steps are filtered out when the scene framework is enabled. fun sharedFlowWithShadeNotExpanded_onCancelRunsWhenSpecified() = testScope.runTest { kosmos.runTest { val flow = underTest.sharedFlowWithShade( duration = 100.milliseconds, Loading @@ -373,7 +376,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { state: TransitionState = TransitionState.RUNNING, ): TransitionStep { return TransitionStep( from = GONE, from = LOCKSCREEN, to = DREAMING, value = value, transitionState = state, Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/KeyguardTransitionAnimationFlowTest.kt +39 −36 Original line number Diff line number Diff line Loading @@ -20,22 +20,22 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.app.animation.Interpolators.EMPHASIZED_ACCELERATE import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectValues import com.android.systemui.flags.DisableSceneContainer import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.shared.model.Edge import com.android.systemui.keyguard.shared.model.KeyguardState.DREAMING import com.android.systemui.keyguard.shared.model.KeyguardState.GONE import com.android.systemui.keyguard.shared.model.KeyguardState.LOCKSCREEN import com.android.systemui.keyguard.shared.model.TransitionState import com.android.systemui.keyguard.shared.model.TransitionStep import com.android.systemui.kosmos.testScope import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.collectValues import com.android.systemui.kosmos.runCurrent import com.android.systemui.kosmos.runTest import com.android.systemui.shade.shadeTestUtil import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlin.time.Duration.Companion.milliseconds import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Test import org.junit.runner.RunWith Loading @@ -43,34 +43,34 @@ import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { val kosmos = testKosmos() val testScope = kosmos.testScope val animationFlow = kosmos.keyguardTransitionAnimationFlow val repository = kosmos.fakeKeyguardTransitionRepository val shadeTestUtil by lazy { kosmos.shadeTestUtil } private val kosmos = testKosmos() private lateinit var animationFlow: KeyguardTransitionAnimationFlow private lateinit var repository: FakeKeyguardTransitionRepository private lateinit var underTest: KeyguardTransitionAnimationFlow.FlowBuilder @Before fun setUp() { animationFlow = kosmos.keyguardTransitionAnimationFlow repository = kosmos.fakeKeyguardTransitionRepository underTest = animationFlow .setup( duration = 1000.milliseconds, edge = Edge.create(from = Scenes.Gone, to = DREAMING), edge = Edge.create(from = LOCKSCREEN, to = DREAMING), ) .setupWithoutSceneContainer(edge = Edge.create(from = GONE, to = DREAMING)) .setupWithoutSceneContainer(edge = Edge.create(from = LOCKSCREEN, to = DREAMING)) } @Test(expected = IllegalArgumentException::class) fun zeroDurationThrowsException() = testScope.runTest { kosmos.runTest { val flow = underTest.sharedFlow(duration = 0.milliseconds, onStep = { it }) } @Test(expected = IllegalArgumentException::class) fun startTimePlusDurationGreaterThanTransitionDurationThrowsException() = testScope.runTest { kosmos.runTest { val flow = underTest.sharedFlow( startTime = 300.milliseconds, Loading @@ -81,7 +81,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { @Test fun onFinishRunsWhenSpecified() = testScope.runTest { kosmos.runTest { val flow = underTest.sharedFlow( duration = 100.milliseconds, Loading @@ -96,8 +96,9 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { } @Test @DisableSceneContainer // CANCELED steps are filtered out when the scene framework is enabled. fun onCancelRunsWhenSpecified() = testScope.runTest { kosmos.runTest { val flow = underTest.sharedFlow( duration = 100.milliseconds, Loading @@ -113,7 +114,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { @Test fun onStepReturnsNullEmitsNothing() = testScope.runTest { kosmos.runTest { val flow = underTest.sharedFlow(duration = 100.milliseconds, onStep = { null }) var animationValues = collectLastValue(flow) runCurrent() Loading @@ -124,7 +125,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { @Test fun usesStartTime() = testScope.runTest { kosmos.runTest { val flow = underTest.sharedFlow( startTime = 500.milliseconds, Loading Loading @@ -152,7 +153,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { @Test fun usesInterpolator() = testScope.runTest { kosmos.runTest { val flow = underTest.sharedFlow( duration = 1000.milliseconds, Loading @@ -176,7 +177,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { @Test fun usesOnStepToDoubleValue() = testScope.runTest { kosmos.runTest { val flow = underTest.sharedFlow(duration = 1000.milliseconds, onStep = { it * 2 }) val animationValues by collectLastValue(flow) runCurrent() Loading @@ -195,7 +196,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { @Test fun usesOnStepToDoubleValueWithState() = testScope.runTest { kosmos.runTest { val flow = underTest.sharedFlowWithState(duration = 1000.milliseconds, onStep = { it * 2 }) val animationValues by collectLastValue(flow) Loading @@ -205,7 +206,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { assertThat(animationValues) .isEqualTo( StateToValue( from = GONE, from = LOCKSCREEN, to = DREAMING, transitionState = TransitionState.STARTED, value = 0f, Loading @@ -215,7 +216,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { assertThat(animationValues) .isEqualTo( StateToValue( from = GONE, from = LOCKSCREEN, to = DREAMING, transitionState = TransitionState.RUNNING, value = 0.6f, Loading @@ -225,7 +226,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { assertThat(animationValues) .isEqualTo( StateToValue( from = GONE, from = LOCKSCREEN, to = DREAMING, transitionState = TransitionState.RUNNING, value = 1.2f, Loading @@ -235,7 +236,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { assertThat(animationValues) .isEqualTo( StateToValue( from = GONE, from = LOCKSCREEN, to = DREAMING, transitionState = TransitionState.RUNNING, value = 1.6f, Loading @@ -245,7 +246,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { assertThat(animationValues) .isEqualTo( StateToValue( from = GONE, from = LOCKSCREEN, to = DREAMING, transitionState = TransitionState.RUNNING, value = 2f, Loading @@ -255,7 +256,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { assertThat(animationValues) .isEqualTo( StateToValue( from = GONE, from = LOCKSCREEN, to = DREAMING, transitionState = TransitionState.FINISHED, value = null, Loading @@ -265,7 +266,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { @Test fun sameFloatValueWithTheSameTransitionStateDoesNotEmitTwice() = testScope.runTest { kosmos.runTest { val flow = underTest.sharedFlow(duration = 1000.milliseconds, onStep = { it }) val values by collectValues(flow) runCurrent() Loading @@ -279,7 +280,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { @Test fun sameFloatValueWithADifferentTransitionStateDoesEmitTwice() = testScope.runTest { kosmos.runTest { val flow = underTest.sharedFlow(duration = 1000.milliseconds, onStep = { it }) val values by collectValues(flow) runCurrent() Loading @@ -294,7 +295,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { @Test fun sharedFlowWithShadeExpanded() = testScope.runTest { kosmos.runTest { val flow = underTest.sharedFlowWithShade( duration = 1000.milliseconds, Loading @@ -313,7 +314,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { @Test fun sharedFlowWithShadeNotExpanded() = testScope.runTest { kosmos.runTest { val flow = underTest.sharedFlowWithShade( duration = 1000.milliseconds, Loading @@ -331,8 +332,9 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { } @Test @DisableSceneContainer // CANCELED steps are filtered out when the scene framework is enabled. fun sharedFlowWithShadeExpanded_onCancelRunsWhenSpecified() = testScope.runTest { kosmos.runTest { val flow = underTest.sharedFlowWithShade( duration = 100.milliseconds, Loading @@ -348,8 +350,9 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { } @Test @DisableSceneContainer // CANCELED steps are filtered out when the scene framework is enabled. fun sharedFlowWithShadeNotExpanded_onCancelRunsWhenSpecified() = testScope.runTest { kosmos.runTest { val flow = underTest.sharedFlowWithShade( duration = 100.milliseconds, Loading @@ -373,7 +376,7 @@ class KeyguardTransitionAnimationFlowTest : SysuiTestCase() { state: TransitionState = TransitionState.RUNNING, ): TransitionStep { return TransitionStep( from = GONE, from = LOCKSCREEN, to = DREAMING, value = value, transitionState = state, Loading