Interface

IndirectPointerInjectionScope

The receiver scope of the indirect pointer input injection lambda from performIndirectPointerInput.

indirectPointerInputAssertDuringClick

fun indirectPointerInputAssertDuringClick() {
    // Ensure the node is within the focus path (otherwise, you won't get the event).
    composeTestRule.onNodeWithTag("myComponent").requestFocus()
    composeTestRule.performIndirectPointerInput(
        indirectPointerEventPrimaryDirectionalMotionAxis =
            IndirectPointerEventPrimaryDirectionalMotionAxis.X,
        // Horizontal trackpad
        inputDeviceSize = IntSize(width = 5000, height = 1000),
    ) {
        down(position = Offset(x = inputDeviceCenterX, y = inputDeviceCenterY))
    }
    // Assert some pressed state is visible
    composeTestRule.performIndirectPointerInput(
        indirectPointerEventPrimaryDirectionalMotionAxis =
            IndirectPointerEventPrimaryDirectionalMotionAxis.X,
        // Horizontal trackpad
        inputDeviceSize = IntSize(width = 5000, height = 1000),
    ) {
        up()
    }
}

indirectPointerInputClick

// Click options:
fun indirectPointerInputClick() {
    // Ensure the node is within the focus path (otherwise, you won't get the event).
    composeTestRule.onNodeWithTag("myComponent").requestFocus()
    composeTestRule.performIndirectPointerInput(
        indirectPointerEventPrimaryDirectionalMotionAxis =
            IndirectPointerEventPrimaryDirectionalMotionAxis.X,
        // Horizontal trackpad
        inputDeviceSize = IntSize(width = 5000, height = 1000),
    ) {
        click()
    }
}

indirectPointerInputSwipeRight

// Swipe options
fun indirectPointerInputSwipeRight() {
    // Ensure your node is within the focus path (otherwise, you won't get the event).
    composeTestRule.onNodeWithTag("myComponent").requestFocus()
    composeTestRule.performIndirectPointerInput(
        indirectPointerEventPrimaryDirectionalMotionAxis =
            IndirectPointerEventPrimaryDirectionalMotionAxis.X,
        // Horizontal trackpad
        inputDeviceSize = IntSize(width = 5000, height = 1000),
    ) {
        swipeRight(startX = inputDeviceLeft, endX = inputDeviceRight)
    }
}

Last updated: