AndroidComposeUiTest



Variant of ComposeUiTest for when you want to have access to the current activity of type A. The activity might not always be available, for example if the test navigates to another activity. In such cases, activity will return null.

An instance of AndroidComposeUiTest can be obtained by calling runAndroidComposeUiTest, the argument to which will have it as the receiver scope.

Note that any Compose content can be found and tested, regardless if it is hosted by activity or not. What is important, is that the content is set during the lambda passed to runAndroidComposeUiTest (not before, and not after), and that the activity that is actually hosting the Compose content is in resumed state.

Parameters
<A : ComponentActivity>

The Activity type to be interacted with, which typically (but not necessarily) is the activity that was launched and hosts the Compose content

Summary

Public properties

A?

Returns the current activity of type A used in this ComposeUiTest.

android

Inherited functions

From androidx.compose.ui.test.ComposeUiTest
suspend Unit
android
Unit
android
T
<T : Any?> runOnIdle(action: () -> T)
android
T
<T : Any?> runOnUiThread(action: () -> T)
android
Unit
setContent(composable: @Composable () -> Unit)
android
Unit
android
Unit
android
Unit
waitUntil(
    conditionDescription: String?,
    timeoutMillis: Long,
    condition: () -> Boolean
)
android
From androidx.compose.ui.test.SemanticsNodeInteractionsProvider
SemanticsNodeInteractionCollection
onAllNodes(matcher: SemanticsMatcher, useUnmergedTree: Boolean)

Finds all semantics nodes that match the given condition.

android
SemanticsNodeInteraction
onNode(matcher: SemanticsMatcher, useUnmergedTree: Boolean)

Finds a semantics node that matches the given condition.

android

Public properties

activity

val activity: A?

Returns the current activity of type A used in this ComposeUiTest. If no such activity is available, for example if you've navigated to a different activity and the original host has now been destroyed, this will return null.

Note that you should never hold on to a reference to the Activity, always use activity to interact with the Activity.