# RotaryInjectionScope

Artifact: [androidx.compose.ui:ui-test](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/test/RotaryInjectionScope.kt+class:androidx.compose.ui.test.RotaryInjectionScope) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.0) Common/AllAndroid/JVM
- Cmn

  ```
  interface RotaryInjectionScope : InjectionScope
  ```

*** ** * ** ***

The receiver scope of rotary input injection lambda from `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.SemanticsNodeInteraction).performRotaryScrollInput(kotlin.Function1)`.

A rotary event can be sent with `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/RotaryInjectionScope#rotateToScrollVertically(kotlin.Float)` or `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/RotaryInjectionScope#rotateToScrollHorizontally(kotlin.Float)`. All events sent by these methods are batched together and sent as a whole after `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.SemanticsNodeInteraction).performRotaryScrollInput(kotlin.Function1)` has executed its code block.

Example of performing a scroll with three events:

```kotlin
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performRotaryScrollInput

composeTestRule.onNodeWithTag("myComponent").performRotaryScrollInput {
    rotateToScrollVertically(3.0f)
    rotateToScrollVertically(10.0f)
    rotateToScrollVertically(2.0f)
}
```

## Summary

| ### Public functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/RotaryInjectionScope#rotateToScrollHorizontally(kotlin.Float)(horizontalScrollPixels: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Sends a scroll event that represents a rotation that will result in a scroll distance of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/RotaryInjectionScope#rotateToScrollHorizontally(kotlin.Float)`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/RotaryInjectionScope#rotateToScrollVertically(kotlin.Float)(verticalScrollPixels: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Sends a scroll event that represents a rotation that will result in a scroll distance of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/RotaryInjectionScope#rotateToScrollVertically(kotlin.Float)`. | Cmn |

| ### Inherited functions |
|---|
| From [androidx.compose.ui.unit.Density](https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density) |---|---|---| | `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(androidx.compose.ui.unit.Dp).roundToPx()()` Convert `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` to `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` by rounding | Cmn | | `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(androidx.compose.ui.unit.TextUnit).roundToPx()()` Convert Sp to `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` by rounding | Cmn | | `open https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(kotlin.Int).toDp()()` Convert an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` pixel value to `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp`. | Cmn | | `open https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(kotlin.Float).toDp()()` Convert a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` pixel value to a Dp | Cmn | | `open https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpSize` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(androidx.compose.ui.geometry.Size).toDpSize()()` Convert a `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` to a `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpSize`. | Cmn | | `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(androidx.compose.ui.unit.Dp).toPx()()` Convert `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` to pixels. | Cmn | | `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(androidx.compose.ui.unit.TextUnit).toPx()()` Convert Sp to pixels. | Cmn | | `open https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Rect` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpRect.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(androidx.compose.ui.unit.DpRect).toRect()()` Convert a `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpRect` to a `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Rect`. | Cmn | | `open https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpSize.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(androidx.compose.ui.unit.DpSize).toSize()()` Convert a `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpSize` to a `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size`. | Cmn | | `open https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(kotlin.Int).toSp()()` Convert an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` pixel value to Sp. | Cmn | | `open https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(kotlin.Float).toSp()()` Convert a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` pixel value to a Sp | Cmn | |
| From [androidx.compose.ui.unit.FontScaling](https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/FontScaling) |---|---|---| | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/FontScaling#(androidx.compose.ui.unit.TextUnit).toDp()()` Convert Sp to `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp`. | Cmn | | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/FontScaling#(androidx.compose.ui.unit.Dp).toSp()()` Convert `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` to Sp. | Cmn | |
| From [androidx.compose.ui.test.InjectionScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope) |---|---|---| | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#advanceEventTime(kotlin.Long)(durationMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Adds the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#advanceEventTime(kotlin.Long)` to the current event time, delaying the next event by that time. | Cmn | | `open https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#percentOffset(kotlin.Float,kotlin.Float)(x: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, y: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Creates an `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` relative to the size of the node we're interacting with. | Cmn | |

| ### Inherited properties |
|---|
| From [androidx.compose.ui.unit.Density](https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density) |---|---|---| | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#density()` The logical density of the display. | Cmn | |
| From [androidx.compose.ui.unit.FontScaling](https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/FontScaling) |---|---|---| | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/FontScaling#fontScale()` Current user preference for the scaling factor for fonts. | Cmn | |
| From [androidx.compose.ui.test.InjectionScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope) |---|---|---| | `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#bottom()` 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 https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#bottomCenter()` 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 https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#bottomLeft()` 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 https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#bottomRight()` 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 https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#center()` 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 https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#centerLeft()` 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 https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#centerRight()` 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 https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#centerX()` 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 https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#centerY()` 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 https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#eventPeriodMillis()` The default time between two successive events. | Cmn | | `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#height()` The height of the node in px. | Cmn | | `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#left()` 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 https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#right()` 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 https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#top()` The y-coordinate for the top 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 https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#topCenter()` 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 https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#topLeft()` 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 https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#topRight()` 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 | | `https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ViewConfiguration` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#viewConfiguration()` The `https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ViewConfiguration` in use by the `https://developer.android.com/reference/kotlin/androidx/compose/ui/semantics/SemanticsNode` from the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/SemanticsNodeInteraction` on which the input injection method is called. | Cmn | | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntSize` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#visibleSize()` The size of the visible part of the node we're interacting with in px, i.e. its clipped bounds. | Cmn | | `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#width()` The width of the node in px. | Cmn | |

## Public functions

### rotateToScrollHorizontally

Cmn Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.0)

```
fun rotateToScrollHorizontally(horizontalScrollPixels: Float): Unit
```

Sends a scroll event that represents a rotation that will result in a scroll distance of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/RotaryInjectionScope#rotateToScrollHorizontally(kotlin.Float)`. The event will be sent at the current event time. Positive `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/RotaryInjectionScope#rotateToScrollHorizontally(kotlin.Float)` values will correspond to rotating the scroll wheel clockwise, negative values correspond to rotating the scroll wheel anticlockwise.

| Parameters |
|---|---|
| `horizontalScrollPixels: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The amount of scroll, in pixels |

### rotateToScrollVertically

Cmn Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.0)

```
fun rotateToScrollVertically(verticalScrollPixels: Float): Unit
```

Sends a scroll event that represents a rotation that will result in a scroll distance of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/RotaryInjectionScope#rotateToScrollVertically(kotlin.Float)`. The event will be sent at the current event time. Positive `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/RotaryInjectionScope#rotateToScrollVertically(kotlin.Float)` values will correspond to rotating the scroll wheel clockwise, negative values correspond to rotating the scroll wheel anticlockwise.

| Parameters |
|---|---|
| `verticalScrollPixels: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The amount of scroll, in pixels |