Companion

object Companion

Built-in matchers, and the entry point for building others with and, or and not.

Functions

Link copied to clipboard

Matches a component whose accessible description equals description, read from its java.awt.Component.getAccessibleContext.

Link copied to clipboard

Matches a component whose accessible name equals name, read from its java.awt.Component.getAccessibleContext.

Link copied to clipboard

Matches a component whose accessible role equals role, read from its java.awt.Component.getAccessibleContext.

Link copied to clipboard

Matches a component with at least one ancestor satisfying matcher. The whole parent chain is considered, so this scopes a query to a subtree: it keeps the components that sit anywhere below the container matcher describes.

Link copied to clipboard

Matches a component with at least one direct child satisfying matcher.

Link copied to clipboard

Matches a component with at least one descendant, at any depth, satisfying matcher.

Link copied to clipboard

Matches a component with at least one sibling satisfying matcher. A sibling is any other child of the same parent.

Link copied to clipboard

Matches a component whose Component.getName equals name.

Link copied to clipboard

Matches a component whose parent satisfies matcher. A component with no parent never matches.

Link copied to clipboard

Matches a component tagged with tag via SwingModifier.testTag.

Link copied to clipboard
fun hasText(text: @Nls String, substring: Boolean = false): SwingMatcher

Matches a component whose textual content equals text, or contains it when substring is true. Text is read from javax.swing.JLabel.getText, AbstractButton.getText, or JTextComponent.getText depending on the component type. A password field carries no readable text and never matches.

Link copied to clipboard
fun hasTitle(title: @Nls String): SwingMatcher

Matches a component whose title equals title, read from Frame.getTitle, Dialog.getTitle or JInternalFrame.getTitle. Use it with ComposeSwingTest.onWindow to pick one window out of several, and with a node query to assert the title of a frame standing on a desktop.

Link copied to clipboard
fun isEditable(editable: Boolean = true): SwingMatcher

Matches a component whose editable state equals editable, read from JTextComponent.isEditable for a text component and JComboBox.isEditable for a combo box. A component that carries no editable state never matches, in either direction; see isSelected for what that means for the negated form.

Link copied to clipboard
fun isEnabled(enabled: Boolean = true): SwingMatcher

Matches a component whose enabled state equals enabled. A disabled component takes no user input and raises no events; components start out enabled.

Link copied to clipboard
inline fun <T : Component> isOfType(): SwingMatcher

Matches a component that is an instance of T.

Link copied to clipboard
fun isSelected(selected: Boolean = true): SwingMatcher

Matches a component whose selected state equals selected, read from AbstractButton.isSelected - the state a check box, radio button, toggle button or checkable menu item carries. A component that carries no selected state never matches, in either direction, so isSelected(false) asserts "carries a selection and is off" while !isSelected() also admits a component that cannot be selected at all.