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

SubspaceSemanticsNodeInteractionCollection

Represents a collection of semantics nodes and the path to fetch them from the subspace semantics tree.

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

Represents a collection of semantics nodes and the path to fetch them from the subspace semantics tree.

One can interact with these nodes by fetching their semantics information or accessing a specific node via its index. An instance of this collection can be obtained from onAllSubspaceNodes and convenience methods that use a specific filter, such as onAllSubspaceNodesWithTag.

Secondary Constructors

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

Functions

fetchSemanticsNodes

public fun fetchSemanticsNodes(
        atLeastOneRootRequired: Boolean = true,
        errorMessageOnFail: String? = null,
    ): List<SubspaceSemanticsInfo>

Returns the list of semantics nodes captured by this collection.

This operation involves synchronization with the UI to fetch the latest node data. If accessed multiple times in a single atomic operation, caching the result is recommended to avoid performance overhead.

Parameters

atLeastOneRootRequired whether to throw an error if there is no compose content found in the current test application.
errorMessageOnFail the prefix to be added to the error message if the fetch operation fails.

Returns

the list of matched SubspaceSemanticsInfo instances.

get

public operator fun get(index: Int): SubspaceSemanticsNodeInteraction

Retrieves the interaction for the node at the given index in this collection.

Any subsequent operation on the returned interaction will expect exactly one element to be found (unless SubspaceSemanticsNodeInteraction.assertDoesNotExist is used) and will fail if zero or multiple elements are found.

Parameters

index the zero-based index of the node to retrieve from the matched collection.

Returns

the interaction corresponding to the node at the specified index.

Last updated: