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

AndroidComposeTestRule

class AndroidComposeTestRule<T : ComponentActivity> : ComposeTestRule
kotlin.Any
   ↳ androidx.ui.test.android.AndroidComposeTestRule

Android specific implementation of ComposeTestRule.

If recomposer is null the thread-specific Recomposer.current will be used when setContent is called.

Summary

Nested classes
inner

Public constructors
<init>(activityRule: ActivityScenarioRule<T>, recomposer: Recomposer? = null, disableTransitions: Boolean = false, disableBlinkingCursor: Boolean = true)

Android specific implementation of ComposeTestRule.

Public methods
Statement
apply(base: Statement, description: Description?)

ComposeTestCaseSetup

Takes the given test case and prepares it for execution-controlled test via ComposeTestCaseSetup.

Unit
setContent(composable: () -> Unit)

Inherited extension functions
From androidx.ui.test
CollectedSizes
ComposeTestRule.setContentAndCollectSizes(parentConstraints: DpConstraints = BigTestConstraints, children: () -> Unit)

Set content as with ComposeTestRule.setContent, but return CollectedSizes to assert width and height of this content

Size
ComposeTestRule.setContentAndGetPixelSize(parentConstraints: DpConstraints = BigTestConstraints, performSetContent: (() -> Unit) -> Unit = { setContent(it) }, children: () -> Unit)

Set content as with ComposeTestRule.setContent, but return sizes of this content

Properties
ActivityScenarioRule<T>

AnimationClockTestRule

A test rule that allows you to control the animation clock

Density

Current device screen's density.

DisplayMetrics

Recomposer?

Public constructors

<init>

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

Android specific implementation of ComposeTestRule.

If recomposer is null the thread-specific Recomposer.current will be used when setContent is called.

Public methods

apply

fun apply(
    base: Statement,
    description: Description?
): Statement

forGivenTestCase

fun forGivenTestCase(testCase: ComposeTestCase): ComposeTestCaseSetup

Takes the given test case and prepares it for execution-controlled test via ComposeTestCaseSetup.

setContent

fun setContent(composable: () -> Unit): Unit
Exceptions
IllegalStateException if called more than once per test.

Properties

activityRule

val activityRule: ActivityScenarioRule<T>

clockTestRule

val clockTestRule: AnimationClockTestRule

A test rule that allows you to control the animation clock

density

val density: Density

Current device screen's density.

displayMetrics

val displayMetrics: DisplayMetrics

recomposer

val recomposer: Recomposer?