Function

assertContentDescriptionEquals

Asserts that the node's list of content descriptions contains exactly the given values and nothing else.

assertContentDescriptionEqualsSample

@Sampled
fun assertContentDescriptionEqualsSample() {
    composeTestRule.setContent {
        // Explicitly merging descendants to demonstrate list semantics
        Row(Modifier.semantics(mergeDescendants = true) { testTag = "iconRow" }) {
            Icon(ColorPainter(Color.Red), contentDescription = "Navigate Up")
            Icon(ColorPainter(Color.Yellow), contentDescription = "Go Home")
        }
    }

    // The merged content description list is: ["Navigate Up", "Go Home"]

    // We provide all items exactly as they appear in the merged list.
    // Order does not matter.
    composeTestRule
        .onNodeWithTag("iconRow")
        .assertContentDescriptionEquals("Go Home", "Navigate Up")
}
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: