@InternalApi public class JComponentDriver extends ContainerDriver
Supports functional testing of JComponent
s.
Note: This class is intended for internal use only. Please use the classes in the package
org.assertj.swing.fixture
in your tests.
robot
Constructor and Description |
---|
JComponentDriver(Robot robot)
Creates a new
JComponentDriver . |
Modifier and Type | Method and Description |
---|---|
Object |
clientProperty(JComponent c,
Object key)
Returns the client property stored in the given
JComponent , under the given key. |
protected void |
invokeAction(JComponent c,
String name)
Invokes an
javax.swing.Action from the JComponent 's javax.swing.ActionMap . |
protected boolean |
isVisible(JComponent c,
Point p)
|
protected static boolean |
isVisible(JComponent c,
Rectangle r)
Indicates whether the given
JComponent 's visible Rectangle contains the given one. |
void |
requireToolTip(JComponent c,
Pattern pattern)
Asserts that the toolTip in the given
JComponent matches the given regular expression pattern. |
void |
requireToolTip(JComponent c,
String expected)
Asserts that the toolTip in the given
JComponent matches the given value. |
protected void |
scrollToVisible(JComponent c,
Rectangle r)
Invokes
JComponent.scrollRectToVisible(Rectangle) on the given JComponent . |
doResizeHeight, doResizeWidth, isResizable, move, resize
backgroundOf, checkClickAllowed, checkInEdtEnabledAndShowing, checkInEdtShowing, click, click, click, click, click, doubleClick, drag, dragOver, drop, drop, focus, focusAndWaitForFocusGain, fontOf, foregroundOf, invokePopupMenu, invokePopupMenu, moveMouseIgnoringAnyError, moveMouseIgnoringAnyError, performAccessibleActionOf, pressAndReleaseKey, pressAndReleaseKey, pressAndReleaseKeys, pressKey, pressKeyWhileRunning, propertyName, releaseKey, requireDisabled, requireEnabled, requireEnabled, requireFocused, requireNotVisible, requireSize, requireVisible, rightClick, settings, waitForShowing
public JComponentDriver(@Nonnull Robot robot)
JComponentDriver
.robot
- the robot the robot to use to simulate user input.@RunsInCurrentThread protected final void scrollToVisible(@Nonnull JComponent c, @Nonnull Rectangle r)
Invokes JComponent.scrollRectToVisible(Rectangle)
on the given JComponent
.
Note: This method is accessed in the current executing thread. Such thread may or may not be the event dispatch thread (EDT). Client code must call this method from the EDT.
c
- the given JComponent
.r
- the visible Rectangle
.@RunsInCurrentThread protected static boolean isVisible(@Nonnull JComponent c, @Nonnull Rectangle r)
Indicates whether the given JComponent
's visible Rectangle
contains the given one.
Note: This method is accessed in the current executing thread. Such thread may or may not be the event dispatch thread (EDT). Client code must call this method from the EDT.
c
- the given JComponent
.r
- the Rectangle
to verify.true
if the given Rectangle
is contained in the given JComponent
's visible
Rectangle
.@RunsInCurrentThread protected final boolean isVisible(@Nonnull JComponent c, @Nonnull Point p)
Indicates whether the given JComponent
's visible Rectangle
contains the given Point
.
Note: This method is accessed in the current executing thread. Such thread may or may not be the event dispatch thread (EDT). Client code must call this method from the EDT.
c
- the given JComponent
.p
- the Point
to verify.true
if the given Point
is contained in the given JComponent
's visible
Rectangle
.@RunsInEDT protected final void invokeAction(@Nonnull JComponent c, @Nonnull String name)
javax.swing.Action
from the JComponent
's javax.swing.ActionMap
.c
- the given JComponent
.name
- the name of the Action
to invoke.ActionFailedException
- if an Action
cannot be found under the given
name. Or if a KeyStroke
cannot be found for the Action
under the given name. Or if it is
not possible to type any of the found KeyStroke
s.@RunsInEDT public void requireToolTip(@Nonnull JComponent c, @Nullable String expected)
JComponent
matches the given value.c
- the given JComponent
.expected
- the expected toolTip. It can be a regular expression.AssertionError
- if the toolTip of the given JComponent
does not match the given value.@RunsInEDT public void requireToolTip(@Nonnull JComponent c, @Nonnull Pattern pattern)
JComponent
matches the given regular expression pattern.c
- the given JComponent
.pattern
- the regular expression pattern to match.NullPointerException
- if the given regular expression pattern is null
.AssertionError
- if the toolTip of the given JComponent
does not match the given value.@RunsInEDT @Nullable public Object clientProperty(@Nonnull JComponent c, @Nonnull Object key)
JComponent
, under the given key.c
- the given JComponent
.key
- the key to use to retrieve the client property.null
if the property was not found.NullPointerException
- if the given key is null
.Copyright © 2014–2019 AssertJ. All rights reserved.