{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

RootForTest

public interface RootForTest

Known direct subclasses
ViewRootForTest

The marker interface to be implemented by the View backing the composition.


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

Summary

Public methods

abstract @NonNull Density

Current device density.

abstract @NonNull SemanticsOwner

Semantics owner for this root.

abstract @NonNull TextInputService

The service handling text input.

default void

Requests another layout (measure + placement) pass be performed for any nodes that need it.

abstract boolean

Send this KeyEvent to the focused component in this Owner.

Public methods

getDensity

abstract @NonNull Density getDensity()

Current device density.

getSemanticsOwner

abstract @NonNull SemanticsOwner getSemanticsOwner()

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

getTextInputService

abstract @NonNull TextInputService getTextInputService()

The service handling text input.

measureAndLayoutForTest

@ExperimentalComposeUiApi
default void 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.

sendKeyEvent

abstract boolean sendKeyEvent(@NonNull KeyEvent keyEvent)

Send this KeyEvent to the focused component in this Owner.

Returns
boolean

true if the event was consumed. False otherwise.