performGesture
Deprecated Replaced by performTouchInput
fun SemanticsNodeInteraction.performGesture(
block: GestureScope.() -> Unit
): SemanticsNodeInteraction
Executes the (partial) gesture specified in the given block
. The gesture doesn't need to be
complete and can be resumed in a later invocation of performGesture
. The event time is
initialized to the current time of the MainTestClock
.
Be aware that if you split a gesture over multiple invocations of performGesture
, everything
that happens in between will run as if the gesture is still ongoing (imagine a finger still
touching the screen).
All events that are injected from the block
are batched together and sent after block
is
complete. This method blocks while the events are injected. If an error occurs during execution
of block
or injection of the events, all (subsequent) events are dropped and the error is
thrown here.
Due to the batching of events, all events in a block are sent together and no recomposition will take place in between events. Additionally all events will be generated before any of the events take effect. This means that the screen coordinates of all events are resolved before any of the events can cause the position of the node being injected into to change. This has certain advantages, for example, in the cases of nested scrolling or dragging an element around, it prevents the injection of events into a moving target since all events are enqueued before any of them has taken effect.
Example of performing a click:
Parameters
block | A lambda with GestureScope as receiver that describes the gesture by sending all touch events. |
Returns
The SemanticsNodeInteraction that is the receiver of this method |