RotaryInjectionScope
@ExperimentalTestApi
interface RotaryInjectionScope : InjectionScope
The receiver scope of rotary input injection lambda from performRotaryScrollInput.
A rotary event can be sent with rotateToScrollVertically or rotateToScrollHorizontally. All
events sent by these methods are batched together and sent as a whole after
performRotaryScrollInput has executed its code block.
Example of performing a scroll with three events:
Functions
fun rotateToScrollHorizontally(horizontalScrollPixels: Float)
Sends a scroll event that represents a rotation that will result in a scroll distance of
horizontalScrollPixels. The event will be sent at the current event time. Positive
horizontalScrollPixels values will correspond to rotating the scroll wheel clockwise,
negative values correspond to rotating the scroll wheel anticlockwise.
Parameters
| horizontalScrollPixels | The amount of scroll, in pixels |
fun rotateToScrollVertically(verticalScrollPixels: Float)
Sends a scroll event that represents a rotation that will result in a scroll distance of
verticalScrollPixels. The event will be sent at the current event time. Positive
verticalScrollPixels values will correspond to rotating the scroll wheel clockwise,
negative values correspond to rotating the scroll wheel anticlockwise.
Parameters
| verticalScrollPixels | The amount of scroll, in pixels |
Code Examples
rotaryInputScroll
@OptIn(ExperimentalTestApi::class)
fun rotaryInputScroll() {
composeTestRule.onNodeWithTag("myComponent").performRotaryScrollInput {
rotateToScrollVertically(3.0f)
rotateToScrollVertically(10.0f)
rotateToScrollVertically(2.0f)
}
}
