Compose Unstyled 2.0 is out! Check the official announcement blog ->
Class

SubspaceSemanticsNodeInteraction

Represents a semantics node and the path to fetch it from the subspace semantics tree.

Source set: Android
public class SubspaceSemanticsNodeInteraction
internal constructor(
    private val testContext: SubspaceTestContext,
    private val selector: SubspaceSemanticsSelector,
)

Represents a semantics node and the path to fetch it from the subspace semantics tree.

Allows performing assertions or retrieving the underlying semantics node information. An instance of this class can be obtained from onSubspaceNode or convenience methods that use a specific filter, such as onSubspaceNodeWithTag.

For real usage patterns and explicit semantic properties validation, see the referenced samples.

Secondary Constructors

public constructor(
    testContext: SubspaceTestContext,
    matcher: SubspaceSemanticsMatcher,
) : this(testContext, SubspaceSemanticsSelector(matcher))

Functions

fetchSemanticsNode

public fun fetchSemanticsNode(errorMessageOnFail: String? = null): SubspaceSemanticsInfo

Returns the semantics node captured by this interaction.

This operation synchronizes with the UI to ensure the latest semantics tree data is fetched. Since synchronization introduces performance overhead, it is recommended to cache the result if accessed multiple times within a single atomic operation.

Parameters

errorMessageOnFail the prefix to be added to the error message if the fetch operation fails. Typically used by higher-level operations that rely on this fetch.

Returns

the underlying SubspaceSemanticsInfo corresponding to the matched node.

assertDoesNotExist

public fun assertDoesNotExist()

Asserts that no matching item was found or that the item is no longer in the hierarchy.

This operation synchronizes with the UI and fetches all nodes to ensure it has the latest data. It is useful for verifying that an element has been correctly removed or was never present.

assertExists

@CanIgnoreReturnValue
public fun assertExists(errorMessageOnFail: String? = null): SubspaceSemanticsNodeInteraction

Asserts that the component was found and is part of the component tree.

This operation synchronizes with the UI and fetches all nodes to ensure it has the latest data. Note that if you are already calling fetchSemanticsNode, calling this method is redundant and introduces unnecessary overhead.

Parameters

errorMessageOnFail the prefix to be added to the error message if the assertion fails. Typically used by operations that rely on this assertion.

Returns

this interaction object to allow chaining of further assertions.

Last updated: