IndirectPointerEvent
Allows creation of a [IndirectPointerEvent] from a [MotionEvent] for cross module testing.
IndirectPointerEvent
@ExperimentalIndirectPointerApi
fun IndirectPointerEvent(
motionEvent: MotionEvent,
primaryDirectionalMotionAxis: IndirectPointerEventPrimaryDirectionalMotionAxis =
IndirectPointerEventPrimaryDirectionalMotionAxis.None,
previousMotionEvent: MotionEvent? = null,
): IndirectPointerEvent
Allows creation of a IndirectPointerEvent from a MotionEvent for cross module testing.
IMPORTANT NOTE 1: Primary axis is determined by properties of the InputDevice contained within
the MotionEvent. However, when manually creating a MotionEvent, there is no way to set the
InputDevice. Therefore, this function allows you to manually set the primary axis for testing.
If you have a system created MotionEvent, you can call
convertActionToIndirectPointerEventType() on your MotionEvent to get the primary axis.
IMPORTANT NOTE 2: Since this is just a test function that doesn't maintain state for previous
MotionEvents (like the Android Compose system does), you will need to pass a separate
MotionEvent to populate IndirectPointerInputChange's "previous" parameters (time, position, and
pressed).
Parameters
| motionEvent | The MotionEvent to convert to an IndirectPointerEvent. |
| primaryDirectionalMotionAxis | Primary directional motion axis for testing. |
| previousMotionEvent | The MotionEvent for previous values (time, position, and pressed). |