AndroidComposeTestRule

class AndroidComposeTestRule : ComposeTestRule
kotlin.Any
   ↳ androidx.ui.test.android.AndroidComposeTestRule

Android specific implementation of ComposeTestRule.

Summary

Nested classes

inner

Public constructors

<init>(disableTransitions: Boolean = false, shouldThrowOnRecomposeTimeout: Boolean = false)

Android specific implementation of ComposeTestRule.

Public methods

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

ComposeTestCaseSetup
forGivenContent(composable: () -> Unit)

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

ComposeTestCaseSetup

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

Unit
runOnUiThread(action: () -> Unit)

Runs action on UI thread with a guarantee that any operations modifying Compose data model are safe to do in this block.

Unit
setContent(composable: () -> Unit)

Use this in your tests to setup the UI content to be tested.

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

PxSize
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

ActivityTestRule<Activity>

Density

Current device screen's density.

DisplayMetrics

Public constructors

<init>

AndroidComposeTestRule(
    disableTransitions: Boolean = false,
    shouldThrowOnRecomposeTimeout: Boolean = false)

Android specific implementation of ComposeTestRule.

Public methods

apply

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

forGivenContent

fun forGivenContent(composable: () -> Unit): ComposeTestCaseSetup

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

forGivenTestCase

fun forGivenTestCase(testCase: ComposeTestCase): ComposeTestCaseSetup

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

runOnUiThread

fun runOnUiThread(action: () -> Unit): Unit

Runs action on UI thread with a guarantee that any operations modifying Compose data model are safe to do in this block.

setContent

fun setContent(composable: () -> Unit): Unit

Use this in your tests to setup the UI content to be tested. This should be called exactly once per test.

Properties

activityTestRule

val activityTestRule: ActivityTestRule<Activity>

density

val density: Density

Current device screen's density.

displayMetrics

val displayMetrics: DisplayMetrics