---
title: "SubspaceSemanticsMatcher"
description: "Wrapper for semantics matcher lambdas that allows building a description string explaining to the developer what conditions were being tested."
type: "class"
lastmod: "2026-06-18T10:32:52.444471Z"
---
## API Reference

> Source set: Android

```kotlin
public class SubspaceSemanticsMatcher(
    internal val description: String,
    private val matcher: (SubspaceSemanticsInfo) -> Boolean,
)
```

Wrapper for semantics matcher lambdas that allows building a description string explaining to the
developer what conditions were being tested.

This class encapsulates a predicate that evaluates a [SubspaceSemanticsInfo](/jetpack-compose/androidx.xr.compose/compose/interfaces/SubspaceSemanticsInfo) node to verify
whether it matches the expected semantic properties. It is primarily used by the testing
framework to locate nodes within a Subspace hierarchy.

#### Parameters

| | |
| --- | --- |
| description | A human-readable explanation of the condition being tested, used in test failure messages. |
| matcher | The predicate function that evaluates a given [SubspaceSemanticsInfo](/jetpack-compose/androidx.xr.compose/compose/interfaces/SubspaceSemanticsInfo). |

## Companion Object

## Code Examples

### subspaceNodeMatcherProperties
```kotlin
public fun subspaceNodeMatcherProperties() {
    composeTestRule.setContent {
        Subspace {
            SpatialPanel(SubspaceModifier.width(100.dp).height(100.dp).testTag("myPanel")) {}
        }
    }
    // Check existence and exact spatial dimensions in DP using semantic matchers
    composeTestRule
        .onSubspaceNodeWithTag("myPanel")
        .assertExists()
        .assertPositionInRootIsEqualTo(0.dp, 0.dp, 0.dp)
        .assertWidthIsEqualTo(100.toDp())
        .assertHeightIsEqualTo(100.toDp())
}
```

### subspacePanelRenderedAndInteractive
```kotlin
public fun subspacePanelRenderedAndInteractive() {
    var count = 0
    composeTestRule.setContent {
        Subspace {
            SpatialPanel(SubspaceModifier.testTag("spatialPanel")) {
                Button(onClick = { count++ }) { Text("Increment") }
            }
        }
    }
    // Assert subspace node existence, position, and dimensions in the Spatial hierarchy
    composeTestRule
        .onSubspaceNodeWithTag("spatialPanel")
        .assertExists()
        .assertPositionInRootIsEqualTo(0.toDp(), 0.toDp(), 0.toDp())
    // Interact with the 2D Compose node nested within the Spatial container
    composeTestRule.onNodeWithText("Increment").performClick()
    composeTestRule.waitForIdle()
    // Verify outcomes
    assert(count == 1)
}
```
