TestOwner


Provides necessary services to facilitate testing.

This is typically implemented by entities like test rule.

Summary

Public functions

Set<RootForTest>
getRoots(atLeastOneRootExpected: Boolean)

Collects all RootForTests from all compose hierarchies.

Cmn
T
<T : Any?> runOnUiThread(action: () -> T)

Runs the given action on the ui thread.

Cmn

Public properties

MainTestClock

Clock that drives frames and recompositions in compose tests.

Cmn

Public functions

getRoots

fun getRoots(atLeastOneRootExpected: Boolean): Set<RootForTest>

Collects all RootForTests from all compose hierarchies.

This is a blocking call. Returns only after compose is idle.

Can crash in case it hits time out. This is not supposed to be handled as it surfaces only in incorrect tests.

Parameters
atLeastOneRootExpected: Boolean

Whether the caller expects that at least one compose root is present in the tested app. This affects synchronization efforts / timeouts of this API.

runOnUiThread

fun <T : Any?> runOnUiThread(action: () -> T): T

Runs the given action on the ui thread.

This is a blocking call.

Public properties

mainClock

val mainClockMainTestClock

Clock that drives frames and recompositions in compose tests.