injecting-touch-gestures
Installation
SKILL.md
Injecting Touch Gestures — performTouchInput, Not performGesture
performTouchInput { … } is the single entry point for synthetic touch events in Compose tests. It runs a block in a TouchInjectionScope whose coordinate system is node-local (origin at the node's top-left), batches every event the block enqueues, and flushes them as a single non-recomposing burst when the block returns. The legacy performGesture { … } is @Deprecated("Replaced by performTouchInput") (Actions.kt:337-355) — MUST NOT appear in any new code.
When to use this skill
- The test must simulate a partial gesture, multi-touch, fling with controlled velocity, or pinch-to-zoom — anything richer than a single tap.
- The developer needs precise coordinates relative to a node (e.g. drag by exactly 100 px from
center). - A gesture must be split across two
performTouchInputblocks while a finger is still "down". - A test currently uses
performGesture { }and must be migrated. - A test simulates touch with hardcoded screen coordinates and is flaky on different display sizes.
When NOT to use this skill
- A simple tap on a node — use
performClick()from../clicking-and-scrolling/SKILL.md. It is platform-appropriate and shorter. - The gesture is a hover, right-click, or scroll wheel — use
../injecting-mouse-and-keyboard/SKILL.md. - The flow is "tap a button, then assert a Snackbar appears" — assert via
../../assertions/asserting-node-state-and-text/SKILL.md, not by inspecting touch state. - The test is fighting a fling animation — pause the clock first per
../../synchronization/testing-animations-deterministically/SKILL.md.