Function

animateMoveTo

Move the mouse from the current position to the given position, sending a stream of move events to get an animated path of durationMillis milliseconds.

mouseInputAnimateMoveTo

@Sampled
fun mouseInputAnimateMoveTo() {
    composeTestRule.onNodeWithTag("myComponent").performMouseInput {
        // Hover over the node, making an X shape
        moveTo(topLeft)
        animateMoveTo(bottomRight)
        // Note that an actual user wouldn't be able to instantly
        // move from the bottom right to the top right
        advanceEventTime()
        moveTo(topRight)
        animateMoveTo(bottomLeft)
    }
}

trackpadInputAnimateMoveTo

@Sampled
fun trackpadInputAnimateMoveTo() {
    composeTestRule.onNodeWithTag("myComponent").performTrackpadInput {
        // Hover over the node, making an X shape
        moveTo(topLeft)
        animateMoveTo(bottomRight)
        // Note that an actual user wouldn't be able to instantly
        // move from the bottom right to the top right
        advanceEventTime()
        moveTo(topRight)
        animateMoveTo(bottomLeft)
    }
}
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: