SwingNodeInteraction
A lazy handle to the single component targeted by a query. The target is resolved against the live AWT tree each time it is needed, so it always reflects the current tree after recomposition.
T is the component type the query names: onNodeOfType<JTable>() targets a JTable, and every step that keeps targeting the same node keeps that type, so fetch returns it without being told it again. A query that names no type - onNodeWithText, onNodeWithTag, onParent - targets a Component, and a narrower type is named at the fetch that needs it.
All methods are intended to be called from a org.jetbrains.compose.swing.test.runComposeSwingTest body, which runs on the EDT. Resolution fails with a readable tree dump when the query does not resolve to a single component.
Functions
Asserts that the matched node satisfies matcher, and returns this interaction for chaining.
Asserts that the query resolves to no node.
Asserts that the query resolves to a node. Returns this interaction for chaining.
Captures the matched component and asserts it matches the stored golden image identified by goldenIdentifier, failing the test on a visual difference.
Asserts the matched node is displayed, with off-screen semantics.
Asserts the matched node is enabled.
Asserts that the matched node is the current focus owner, and returns this interaction for chaining.
Asserts the matched node is not enabled.
Asserts that the matched node is not the current focus owner, and returns this interaction for chaining. See assertIsFocusOwner for what ownership means.
Asserts the matched node is not visible - it, or an ancestor up to the query's root, is hidden. See assertIsVisible for what visibility means here.
Asserts the matched node is visible: neither it nor any ancestor up to the query's root has been hidden with java.awt.Component.setVisible. That is the state a container's own layout drives when it shows one child at a time - a CardPanel shows a card by hiding the others - so it is what to assert on for anything a layout switches between.
Asserts the matched node is placed under the layout constraint expected by its parent, and returns this interaction for chaining.
Asserts the matched node's text equals expected. A password field carries no readable text, so this assertion always fails against one.
Asserts that the matched node and expected describe the same user interface - the same widgets, nested the same way, holding the same state - and returns this interaction for chaining.
Renders the matched component, together with everything drawn inside it, to an off-screen image.
Resolves the matched component and returns it as the T the query named, for driving the component's own API directly (e.g. a JTable's model, a JTree's selection, a JList's model). A query that named the type does not name it again:
Resolves the matched component and returns it typed as R, for a query that named no type of its own, or that named a wider one than the component to be driven.
Returns a handle to the matched node's ancestors, nearest first, up to and including the root the node was found under. A node that is itself a root yields an empty collection.
Returns a handle to the matched node's only direct child. Resolution fails unless the node holds exactly one child.
Returns a handle to the matched node's direct child at index. Convenience for onChildren()[index].
Returns a handle to the matched node's children, in their container's order. A node with no children yields an empty collection.
Returns a handle to every component below the matched node, at any depth, in depth-first pre-order. The node itself is excluded, which is how a query scopes to one subtree:
Returns a handle to the parent of the matched node.
Returns a handle to the matched node's only sibling. Resolution fails unless the node's parent holds exactly two children.
Returns a handle to the matched node's siblings: every other child of its parent, in the parent's order. A node with no parent yields an empty collection.
Delivers the event event builds for the matched node, then settles the composition.
Delivers a focus-gained notification to the matched node and settles the composition.
Delivers a focus-lost notification to the matched node and settles the composition.
Clicks the tab at index on the matched JTabbedPane and settles the composition.
Types text onto the end of the matched JTextComponent's current content, then settles the composition.
Pastes text into the matched JTextComponent over its current selection, then settles the composition.
Replaces the matched JTextComponent's entire content with text, then settles the composition.
Types text on the matched node one character at a time, then settles the composition.