SwingWindowInteraction
A lazy handle to the single top-level window targeted by a window query. The target is resolved against the current set of realized windows each time it is needed, so it always reflects windows appearing and disappearing across recomposition.
A window matches while its native peer is realized, whether or not it is currently shown, so a window declared visible = false is still matched once its peer is realized - AWT realizes a window when it is shown, and when it is packed to its content's preferred size. A window that leaves the composition is disposed, which retires its peer and drops it out of the match set; a disposed peer lingering in the global AWT window list is likewise excluded because it is no longer realized.
Beyond asserting on the window itself, the interaction scopes node queries to that window's own content - its content pane and its menu bar - so a test can assert on the content of each top-level peer independently:
onWindowWithTitle("Settings").onNodeWithText("Apply").assertIsEnabled()T is the window type the query names: onWindowOfType<JFrame>() targets a JFrame, and every step that keeps targeting the same window keeps that type. A query that names no type targets a Window, 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.
Functions
Asserts that no realized window matches.
Asserts that exactly one realized window matches. Returns this interaction for chaining.
Asserts the matched window is not visible.
Asserts the matched window is visible.
Suspends until the window system has sent this window no move, resize or paint event for quietPeriod, and returns this interaction. Use it before recording what a window paints.
Resolves the matched window and returns it typed as T. This is the last resort, for a call only the matched window itself takes (e.g. a JFrame's extended state) or for its identity. To read a value, use assertProperty or an assertion.
Resolves the matched window and returns it typed as R, for a query that named no type of its own, or that named a wider one than the window to be driven. Like fetch, it is the last resort; assertProperty or an assertion reads a value.
Finds all nodes matching matcher inside this window's content.
Finds all nodes inside this window's content tagged with tag via SwingModifier.testTag.
Finds the single node matching matcher inside this window's content. Both the window and the node are resolved lazily when the returned interaction is first used.
Finds the single node inside this window's content whose java.awt.Component.getName equals name.
Finds the single node inside this window's content tagged with tag via SwingModifier.testTag.