Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ad1f8438 authored by Omar Miatello's avatar Omar Miatello
Browse files

Add test for scene animation when distance is not specified yet

If the SwipeAnimation's distance hasn't been calculated, the animation
shouldn't start.
Instead, the scene should remain as it is.

Test: atest DraggableHandlerTest
Bug: 388803469
Flag: com.android.systemui.scene_container
Change-Id: I26f51e4b2155e57c4cbd9b69ec17b4b1ab342d1c
parent 95b947a4
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import com.android.compose.animation.scene.TestScenes.SceneA
import com.android.compose.animation.scene.TestScenes.SceneB
import com.android.compose.animation.scene.TestScenes.SceneC
import com.android.compose.animation.scene.content.state.TransitionState
import com.android.compose.animation.scene.content.state.TransitionState.Companion.DistanceUnspecified
import com.android.compose.animation.scene.content.state.TransitionState.Transition
import com.android.compose.animation.scene.subjects.assertThat
import com.android.compose.gesture.NestedDraggable
@@ -784,6 +785,29 @@ class DraggableHandlerTest {
        assertIdle(SceneB)
    }

    @Test
    fun animateWhenDistanceUnspecified() = runGestureTest {
        layoutState.transitions = transitions {
            from(SceneA, to = SceneB) {
                distance = UserActionDistance { _, _, _ -> DistanceUnspecified }
            }
        }

        val controller = onDragStarted(overSlop = up(fractionOfScreen = 0.9f))

        // The distance is not computed yet, so we don't know the "progress" value yet.
        assertTransition(fromScene = SceneA, toScene = SceneB, progress = 0.0f)

        controller.onDragStoppedAnimateNow(
            // We are animating from SceneA to SceneA, when the distance is still unspecified.
            velocity = velocityThreshold,
            onAnimationStart = {
                assertTransition(fromScene = SceneA, toScene = SceneB, progress = 0.0f)
            },
        )
        assertIdle(SceneA)
    }

    @Test
    fun showOverlay() = runGestureTest {
        mutableUserActionsA = mapOf(Swipe.Down to UserActionResult.ShowOverlay(OverlayA))