The second Android 11 Developer Preview is now available, test it out and share your feedback.

GestureScope

class GestureScope
kotlin.Any
   ↳ androidx.ui.test.GestureScope

An object that has an associated component in which one can inject gestures. The gestures can be injected by calling methods defined on GestureScope, such as sendSwipeUp. The associated component is the SemanticsNodeInteraction found by one of the finder methods such as findByTag.

Example usage: findByTag("myWidget") .doGesture { sendSwipeUp() }

Summary

Extension functions

From androidx.ui.test
PxPosition

Transforms the position to global coordinates, as defined by globalBounds

Unit

Performs a click gesture on the given position on the associated component.

Unit

Performs a click gesture on the associated component.

Unit

Performs a double click gesture on the given position on the associated component.

Unit

Performs a double click gesture on the associated component.

Unit

Performs a long click gesture on the given position on the associated component.

Unit

Performs a long click gesture on the middle of the associated component.

Unit
GestureScope.sendSwipe(start: PxPosition, end: PxPosition, duration: Duration = 200.milliseconds)

Performs the swipe gesture on the associated component.

Unit

Performs a swipe down gesture on the associated component.

Unit

Performs a swipe left gesture on the associated component.

Unit

Performs a swipe right gesture on the associated component.

Unit

Performs a swipe up gesture on the associated component.

Unit
GestureScope.sendSwipeWithVelocity(start: PxPosition, end: PxPosition, endVelocity: Float, duration: Duration = 200.milliseconds)

Performs the swipe gesture on the associated component, such that the velocity when the gesture is finished is roughly equal to endVelocity.

Extension properties

From androidx.ui.test
PxPosition

Returns the center of the component we're interacting with, in the component's local coordinate system, where (0.

PxBounds

Returns the global bounds of the component we're interacting with

IntPxSize

Returns the size of the component we're interacting with