---
title: "RootForTest"
description: "The marker interface to be implemented by the root backing the composition. To be used in tests."
type: "interface"
---

<div class='type'>Interface</div>


<a id='references'></a>

<div class='sourceset sourceset-common'>Common</div>



```kotlin
interface RootForTest
```


The marker interface to be implemented by the root backing the composition. To be used in tests.


## Properties

<div class='sourceset sourceset-common'>Common</div>


```kotlin
val density: Density
```


Current device density.



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val semanticsOwner: SemanticsOwner
```


Semantics owner for this root. Manages all the semantics nodes.



<div class='sourceset sourceset-common'>Common</div>


> **Deprecated** Use PlatformTextInputModifierNode instead.

```kotlin
val textInputService: TextInputService
```


The service handling text input.



## Functions

```kotlin
fun sendKeyEvent(keyEvent: KeyEvent): Boolean
```


Send this `KeyEvent` to the focused component in this `Owner`.

#### Returns

| | |
| --- | --- |
|  | true if the event was consumed. False otherwise. |



```kotlin
@ExperimentalIndirectPointerApi
    fun sendIndirectPointerEvent(indirectPointerEvent: IndirectPointerEvent): Boolean
```


Send this `IndirectPointerEvent` to the focused component in this `Owner`.

#### Returns

| | |
| --- | --- |
|  | true if the event was consumed. False otherwise. |



```kotlin
fun forceAccessibilityForTesting(enable: Boolean)
```


Force accessibility to be enabled for testing.

#### Parameters

| | |
| --- | --- |
| enable | force enable accessibility if true. |



```kotlin
fun setAccessibilityEventBatchIntervalMillis(intervalMillis: Long)
```


Set the time interval between sending accessibility events in milliseconds.

This is the delay before dispatching a recurring accessibility event in milliseconds. It
delays the loop that sends events to the accessibility and content capture framework in
batches. A recurring event will be sent at most once during the `intervalMillis` timeframe.
The default time delay is 100 milliseconds.


```kotlin
fun measureAndLayoutForTest()
```


Requests another layout (measure + placement) pass be performed for any nodes that need it.
This doesn't force anything to be remeasured that wouldn't be if `requestLayout` were called.
However, unlike `requestLayout`, it doesn't merely _schedule_ another layout pass to be
performed, it actually performs it synchronously.

This method is used in UI tests to perform layout in between frames when pumping frames as
fast as possible (i.e. without waiting for the choreographer to schedule them) in order to
get to idle, e.g. during a `waitForIdle` call.


```kotlin
fun setUncaughtExceptionHandler(handler: UncaughtExceptionHandler?)
```


Sets the `UncaughtExceptionHandler` callback to dispatch layout, measure, and draw exceptions
from this Composition to. If this method is called multiple times, the previous callback is
discarded.

The default test runners that ship with the Compose UI test and associated JUnit variation
use this API to reroute exceptions back to the test under execution. Custom test runners may
need to associate their own exception handler to do the same. If the Compose UI Test runner's
exception handler is overwritten, it may lead to unhandled exceptions crashing the
instrumented process and terminating the entire test suite early.



