Google is committed to advancing racial equity for Black communities. See how.

androidx.ui.test.android

Classes

AndroidComposeTestCaseSetup

AndroidComposeTestRule

Android specific implementation of ComposeTestRule.

Top-level functions summary

AndroidComposeTestRule<T>
AndroidComposeTestRule(recomposer: Recomposer? = null, disableTransitions: Boolean = false, disableBlinkingCursor: Boolean = true)

Factory method to provide implementation of AndroidComposeTestRule.

ComposeBenchmarkScope<T>
createAndroidComposeBenchmarkRunner(testCaseFactory: () -> T, activity: ComponentActivity)

Factory method to provide implementation of ComposeBenchmarkScope.

Unit

Register compose's idling check to Espresso.

Unit

Registers the given clock so Espresso can await the animations subscribed to that clock.

Unit

Unregisters resource registered as part of registerComposeWithEspresso.

Unit

Unregisters the clock that was registered with registerTestClock.

Top-level functions

AndroidComposeTestRule

inline fun <reified T : ComponentActivity> AndroidComposeTestRule(
    recomposer: Recomposer? = null,
    disableTransitions: Boolean = false,
    disableBlinkingCursor: Boolean = true
): AndroidComposeTestRule<T>

Factory method to provide implementation of AndroidComposeTestRule.

This method is useful for tests that require a custom Activity. This is usually the case for app tests. Make sure that you add the provided activity into your app's manifest file (usually in main/AndroidManifest.xml).

If you don't care about specific activity and just want to test composables in general, see AndroidComposeTestRule.

createAndroidComposeBenchmarkRunner

fun <T : ComposeTestCase> createAndroidComposeBenchmarkRunner(
    testCaseFactory: () -> T,
    activity: ComponentActivity
): ComposeBenchmarkScope<T>

Factory method to provide implementation of ComposeBenchmarkScope.

registerComposeWithEspresso

fun registerComposeWithEspresso(): Unit

Register compose's idling check to Espresso.

This makes sure that Espresso is able to wait for any pending changes in Compose. This resource is automatically registered when any compose testing APIs are used including AndroidComposeTestRule. If you for some reasons want to only use Espresso but still have it wait for Compose being idle you can use this function.

registerTestClock

fun registerTestClock(clock: TestAnimationClock): Unit

Registers the given clock so Espresso can await the animations subscribed to that clock.

unregisterComposeFromEspresso

fun unregisterComposeFromEspresso(): Unit

Unregisters resource registered as part of registerComposeWithEspresso.

unregisterTestClock

fun unregisterTestClock(clock: TestAnimationClock): Unit

Unregisters the clock that was registered with registerTestClock.