SwingNodeInteractionCollection

A lazy handle to the set of components matched by a query. The match set is resolved against the live AWT tree each time it is needed, so it reflects the current tree.

T is the component type the query names - onAllNodesOfType<JLabel>() matches JLabels - and every step that keeps matching the same set keeps it, so fetchAll and the single-node handles get, onFirst, onLast and filterToOne carry it on. A query that names no type matches Components.

All methods are intended to be called from a org.jetbrains.compose.swing.test.runComposeSwingTest body, which runs on the EDT.

Functions

Link copied to clipboard

Asserts that every matched node satisfies matcher. An empty match set satisfies this, as there is no node that violates the matcher; pin the size with assertCountEquals where that matters.

Link copied to clipboard

Asserts that at least one matched node satisfies matcher. An empty match set fails.

Link copied to clipboard

Asserts that exactly expected nodes match.

Link copied to clipboard

Renders each matched component to its own off-screen image, in depth-first pre-order.

Link copied to clipboard
fun fetchAll(): List<T>

Resolves every matching component and returns them as the T the query named, in depth-first pre-order, for reading or driving each component's own API (e.g. a JList's model, a JSplitPane's divider). A query that named the type does not name it again:

@JvmName(name = "fetchAllOfType")
inline fun <R : Component> fetchAll(): List<R>

Resolves every matching component and returns them typed as R, in depth-first pre-order, for a query that named no type of its own - or that named a wider one than the components to be driven.

Link copied to clipboard
fun fetchSize(): Int

Returns the number of currently matching nodes.

Link copied to clipboard

Returns a collection of the matches that also satisfy matcher. Like every interaction, the returned handle re-resolves against the live tree on each use, so it tracks recomposition.

Link copied to clipboard

Returns a lazy handle to the single match that also satisfies matcher; it fails on use when the filtered set does not hold exactly one node.

Link copied to clipboard
operator fun get(index: Int): SwingNodeInteraction<T>

Returns a lazy handle to the match at index, in depth-first pre-order. Like every interaction, the handle re-resolves against the live tree on each use, so it tracks matches added or removed by recomposition; it fails on use when fewer than index + 1 nodes match.

Link copied to clipboard

Returns a lazy handle to the first match, in depth-first pre-order. Convenience for get(0).

Link copied to clipboard

Returns a lazy handle to the last match, in depth-first pre-order. The handle re-resolves against the live tree on each use, so it tracks the current last match across recomposition; it fails on use when nothing matches.