MultiModalInjectionScope


The receiver scope of the multi-modal input injection lambda from performMultiModalInput.

MultiModalInjectionScope brings together the receiver scopes of all individual modalities, allowing you to inject gestures that consist of events from different modalities, like touch and mouse. For each modality, there is a function to which you pass a lambda in which you can inject events for that modality: currently, we have touch, mouse and key functions. See their respective docs for more information.

Note that all events generated by the gesture methods are batched together and sent as a whole after performMultiModalInput has executed its code block.

Example of performing a click via touch input followed by drag and drop via mouse input:

import androidx.compose.ui.test.click
import androidx.compose.ui.test.dragAndDrop
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performMultiModalInput

composeTestRule.onNodeWithTag("myComponent").performMultiModalInput {
    touch { click(center) }
    advanceEventTime(500)
    mouse { dragAndDrop(topLeft, bottomRight) }
}

Summary

Public functions

Unit

Injects all key events sent by the given block

Cmn
Unit

Injects all mouse events sent by the given block

Cmn
Unit

Injects all rotary events sent by the given block

Cmn
Unit

Injects all touch events sent by the given block

Cmn

Inherited functions

From androidx.compose.ui.unit.Density
open Int

Convert Dp to Int by rounding

Cmn
open Int

Convert Sp to Int by rounding

Cmn
open Dp

Convert an Int pixel value to Dp.

Cmn
open Dp

Convert a Float pixel value to a Dp

Cmn
open DpSize

Convert a Size to a DpSize.

Cmn
open Float

Convert Dp to pixels.

Cmn
open Float

Convert Sp to pixels.

Cmn
open Rect

Convert a DpRect to a Rect.

Cmn
open Size

Convert a DpSize to a Size.

Cmn
open TextUnit

Convert an Int pixel value to Sp.

Cmn
open TextUnit

Convert a Float pixel value to a Sp

Cmn
From androidx.compose.ui.unit.FontScaling
open Dp

Convert Sp to Dp.

Cmn
open TextUnit

Convert Dp to Sp.

Cmn
From androidx.compose.ui.test.InjectionScope
Unit
advanceEventTime(durationMillis: Long)

Adds the given durationMillis to the current event time, delaying the next event by that time.

Cmn
open Offset

Creates an Offset relative to the size of the node we're interacting with.

Cmn

Inherited properties

From androidx.compose.ui.unit.Density
Float

The logical density of the display.

Cmn
From androidx.compose.ui.unit.FontScaling
Float

Current user preference for the scaling factor for fonts.

Cmn
From androidx.compose.ui.test.InjectionScope
open Float

The y-coordinate for the bottom of the node we're interacting with in px, in the node's local coordinate system, where (0, 0) is the top left corner of the node.

Cmn
open Offset

The center of the bottom edge of the node we're interacting with, in the node's local coordinate system, where (0, 0) is the top left corner of the node.

Cmn
open Offset

The bottom left corner of the node we're interacting with, in the node's local coordinate system, where (0, 0) is the top left corner of the node.

Cmn
open Offset

The bottom right corner of the node we're interacting with, in the node's local coordinate system, where (0, 0) is the top left corner of the node.

Cmn
open Offset

The center of the node we're interacting with, in the node's local coordinate system, where (0, 0) is the top left corner of the node.

Cmn
open Offset

The center of the left edge of the node we're interacting with, in the node's local coordinate system, where (0, 0) is the top left corner of the node.

Cmn
open Offset

The center of the right edge of the node we're interacting with, in the node's local coordinate system, where (0, 0) is the top left corner of the node.

Cmn
open Float

The x-coordinate for the center of the node we're interacting with in px, in the node's local coordinate system, where (0, 0) is the top left corner of the node.

Cmn
open Float

The y-coordinate for the center of the node we're interacting with in px, in the node's local coordinate system, where (0, 0) is the top left corner of the node.

Cmn
open Long

The default time between two successive events.

Cmn
open Int

The height of the node in px.

Cmn
open Float

The x-coordinate for the left edge of the node we're interacting with in px, in the node's local coordinate system, where (0, 0) is the top left corner of the node.

Cmn
open Float

The x-coordinate for the right edge of the node we're interacting with in px, in the node's local coordinate system, where (0, 0) is the top left corner of the node.

Cmn
open Float

The y-coordinate for the bottom of the node we're interacting with in px, in the node's local coordinate system, where (0, 0) is the top left corner of the node.

Cmn
open Offset

The center of the top edge of the node we're interacting with, in the node's local coordinate system, where (0, 0) is the top left corner of the node.

Cmn
open Offset

The top left corner of the node we're interacting with, in the node's local coordinate system, where (0, 0) is the top left corner of the node.

Cmn
open Offset

The top right corner of the node we're interacting with, in the node's local coordinate system, where (0, 0) is the top left corner of the node.

Cmn
ViewConfiguration

The ViewConfiguration in use by the SemanticsNode from the SemanticsNodeInteraction on which the input injection method is called.

Cmn
IntSize

The size of the visible part of the node we're interacting with in px, i.e. its clipped bounds.

Cmn
open Int

The width of the node in px.

Cmn

Public functions

key

@ExperimentalTestApi
fun key(block: KeyInjectionScope.() -> Unit): Unit

Injects all key events sent by the given block

mouse

fun mouse(block: MouseInjectionScope.() -> Unit): Unit

Injects all mouse events sent by the given block

rotary

@ExperimentalTestApi
fun rotary(block: RotaryInjectionScope.() -> Unit): Unit

Injects all rotary events sent by the given block

touch

fun touch(block: TouchInjectionScope.() -> Unit): Unit

Injects all touch events sent by the given block