# ViewRootForTest

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

  ```
  @VisibleForTesting
  interface ViewRootForTest : RootForTest
  ```

*** ** * ** ***

The marker interface to be implemented by the `https://developer.android.com/reference/android/view/View.html` backing the composition. To be used in tests.

## Summary

| ### Public companion properties |
|---|---|---|
| `((https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ViewRootForTest) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)?` | `@https://developer.android.com/reference/kotlin/androidx/annotation/VisibleForTesting https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ViewRootForTest#onViewCreatedCallback()` Called after a View implementing `https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ViewRootForTest` is created. | android |

| ### Public functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ViewRootForTest#invalidateDescendants()()` Called to invalidate the Android `https://developer.android.com/reference/android/view/View.html` sub-hierarchy handled by this `https://developer.android.com/reference/android/view/View.html`. | android |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ViewRootForTest#hasPendingMeasureOrLayout()` Whether the Owner has pending layout work. | android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ViewRootForTest#isLifecycleInResumedState()` Returns true when the associated LifecycleOwner is in the resumed state | android |
| `https://developer.android.com/reference/android/view/View.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ViewRootForTest#view()` The view backing this Owner. | android |

### Inherited functions

From [androidx.compose.ui.node.RootForTest](https://developer.android.com/reference/kotlin/androidx/compose/ui/node/RootForTest) `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/node/RootForTest#forceAccessibilityForTesting(kotlin.Boolean)(enable: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

Force accessibility to be enabled for testing.
android `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/node/RootForTest#measureAndLayoutForTest()()`

Requests another layout (measure + placement) pass be performed for any nodes that need it.
android `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/node/RootForTest#runAndClearPendingCallbacks()()`

Unregisters callbacks scheduled by delegating to the event queue (e.g. Handler on Android) and runs them immediately.
android `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/node/RootForTest#sendIndirectPointerEvent(androidx.compose.ui.input.indirect.IndirectPointerEvent)(indirectPointerEvent: https://developer.android.com/reference/kotlin/androidx/compose/ui/input/indirect/IndirectPointerEvent)`

Sends `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/indirect/IndirectPointerEvent` to the focused component in this `https://developer.android.com/reference/kotlin/androidx/compose/ui/node/Owner` for testing.
android `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/node/RootForTest#sendKeyEvent(androidx.compose.ui.input.key.KeyEvent)(keyEvent: https://developer.android.com/reference/kotlin/androidx/compose/ui/input/key/KeyEvent)`

Send this `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/key/KeyEvent` to the focused component in this `https://developer.android.com/reference/kotlin/androidx/compose/ui/node/Owner`.
android `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/node/RootForTest#setAccessibilityEventBatchIntervalMillis(kotlin.Long)(intervalMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`

Set the time interval between sending accessibility events in milliseconds.
android `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/node/RootForTest#setUncaughtExceptionHandler(androidx.compose.ui.node.RootForTest.UncaughtExceptionHandler)(
handler: https://developer.android.com/reference/kotlin/androidx/compose/ui/node/RootForTest.UncaughtExceptionHandler?
)`

Sets the `https://developer.android.com/reference/kotlin/androidx/compose/ui/node/RootForTest.UncaughtExceptionHandler` callback to dispatch layout, measure, and draw exceptions from this Composition to.
android `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/node/RootForTest#updateSemanticsForTest()()`

Recalculates semantic node bounds for previously measured and laid out nodes.
android

### Inherited properties

From [androidx.compose.ui.node.RootForTest](https://developer.android.com/reference/kotlin/androidx/compose/ui/node/RootForTest) `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density` `https://developer.android.com/reference/kotlin/androidx/compose/ui/node/RootForTest#density()`

Current device density.
android `https://developer.android.com/reference/kotlin/androidx/compose/ui/semantics/SemanticsOwner` `https://developer.android.com/reference/kotlin/androidx/compose/ui/node/RootForTest#semanticsOwner()`

Semantics owner for this root.
android `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputService` `https://developer.android.com/reference/kotlin/androidx/compose/ui/node/RootForTest#textInputService()`

**This property is deprecated.** Use PlatformTextInputModifierNode instead.
android

## Public companion properties

### onViewCreatedCallback

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

```
@VisibleForTesting
var onViewCreatedCallback: ((ViewRootForTest) -> Unit)?
```

Called after a View implementing `https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ViewRootForTest` is created. Used by AndroidComposeTestRule to keep track of all attached ComposeViews. Not to be set or used by any other component.

## Public functions

### invalidateDescendants

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

```
fun invalidateDescendants(): Unit
```

Called to invalidate the Android `https://developer.android.com/reference/android/view/View.html` sub-hierarchy handled by this `https://developer.android.com/reference/android/view/View.html`.

## Public properties

### hasPendingMeasureOrLayout

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

```
val hasPendingMeasureOrLayout: Boolean
```

Whether the Owner has pending layout work.

### isLifecycleInResumedState

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

```
val isLifecycleInResumedState: Boolean
```

Returns true when the associated LifecycleOwner is in the resumed state

### view

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

```
val view: View
```

The view backing this Owner.