S - used to simulate "self types." For more information please read "Emulating 'self types' using Java Generics to simplify fluent API implementation."C - the type of Component that this fixture can manage.D - the type of ComponentDriver that this fixture uses internally.public abstract class AbstractComponentFixture<S,C extends Component,D extends ComponentDriver> extends Object implements MouseInputSimulationFixture<S>
Components.| Modifier and Type | Field and Description |
|---|---|
protected static String |
BACKGROUND_PROPERTY
Name of the property "background".
|
protected static String |
FONT_PROPERTY
Name of the property "font".
|
protected static String |
FOREGROUND_PROPERTY
Name of the property "foreground".
|
| Constructor and Description |
|---|
AbstractComponentFixture(Class<S> selfType,
Robot robot,
C target)
Creates a new
AbstractComponentFixture. |
AbstractComponentFixture(Class<S> selfType,
Robot robot,
Class<? extends C> type)
Creates a new
AbstractComponentFixture. |
AbstractComponentFixture(Class<S> selfType,
Robot robot,
String name,
Class<? extends C> type)
Creates a new
AbstractComponentFixture. |
| Modifier and Type | Method and Description |
|---|---|
ColorFixture |
background() |
S |
click()
Simulates a user clicking this fixture's
Component. |
S |
click(MouseButton button)
Simulates a user clicking this fixture's
Component. |
S |
click(MouseClickInfo mouseClickInfo)
Simulates a user clicking this fixture's
Component. |
protected abstract D |
createDriver(Robot robot) |
S |
doubleClick()
Simulates a user double-clicking this fixture's
Component. |
protected D |
driver() |
S |
focus()
Gives input focus to this fixture's
Component. |
FontFixture |
font() |
ColorFixture |
foreground() |
boolean |
isEnabled()
Indicates whether this fixture's
Component is enabled. |
protected S |
myself() |
S |
pressAndReleaseKey(KeyPressInfo keyPressInfo)
Simulates a user pressing given key with the given modifiers on this fixture's
Component. |
S |
pressAndReleaseKeys(int... keyCodes)
Simulates a user pressing and releasing the given keys on this fixture's
Component. |
S |
pressKey(int keyCode)
Simulates a user pressing the given key on this fixture's
Component. |
S |
releaseKey(int keyCode)
Simulates a user releasing the given key on this fixture's
Component. |
void |
replaceDriverWith(D driver) |
S |
requireDisabled()
Asserts that this fixture's
Component is disabled. |
S |
requireEnabled()
Asserts that this fixture's
Component is enabled. |
S |
requireEnabled(Timeout timeout)
Asserts that this fixture's
Component is enabled. |
S |
requireFocused()
Asserts that this fixture's
Component has input focus. |
S |
requireNotVisible()
Asserts that this fixture's
Component is not visible. |
protected boolean |
requireShowing()
Returns whether showing components are the only ones participating in a component lookup.
|
S |
requireVisible()
Asserts that this fixture's
Component is visible. |
S |
rightClick()
Simulates a user right-clicking this fixture's
Component. |
protected Robot |
robot() |
C |
target()
Returns the GUI component in this fixture.
|
<T extends C> |
targetCastedTo(Class<T> type)
Returns this fixture's
Component casted to the given sub-type. |
protected static final String FONT_PROPERTY
protected static final String BACKGROUND_PROPERTY
protected static final String FOREGROUND_PROPERTY
public AbstractComponentFixture(@Nonnull Class<S> selfType, @Nonnull Robot robot, @Nonnull Class<? extends C> type)
AbstractComponentFixture.selfType - the "self type."robot - performs simulation of user events on a Component.type - the type of the Component to find using the given Robot.NullPointerException - if robot is null.NullPointerException - if type is null.ComponentLookupException - if a matching component could not be found.ComponentLookupException - if more than one matching component is found.public AbstractComponentFixture(@Nonnull Class<S> selfType, @Nonnull Robot robot, @Nullable String name, @Nonnull Class<? extends C> type)
AbstractComponentFixture.selfType - the "self type."robot - performs simulation of user events on a Component.name - the name of the Component to find using the given Robot.type - the type of the Component to find using the given Robot.NullPointerException - if robot is null.NullPointerException - if type is null.ComponentLookupException - if a matching component could not be found.ComponentLookupException - if more than one matching component is found.public AbstractComponentFixture(@Nonnull Class<S> selfType, @Nonnull Robot robot, @Nonnull C target)
AbstractComponentFixture.selfType - the "self type."robot - performs simulation of user events on the given Component.target - the Component to be managed by this fixture.NullPointerException - if selfType is null.NullPointerException - if robot is null.NullPointerException - if target is null.@Nonnull public final S click()
Component.click in interface MouseInputSimulationFixture<S>IllegalStateException - if this fixture's Component is disabled.IllegalStateException - if this fixture's Component is not showing on the screen.@Nonnull public final S click(@Nonnull MouseButton button)
Component.click in interface MouseInputSimulationFixture<S>button - the button to click.NullPointerException - if the given MouseButton is null.IllegalStateException - if this fixture's Component is disabled.IllegalStateException - if this fixture's Component is not showing on the screen.@Nonnull public final S click(@Nonnull MouseClickInfo mouseClickInfo)
Component.click in interface MouseInputSimulationFixture<S>mouseClickInfo - specifies the button to click and the times the button should be clicked.NullPointerException - if the given MouseClickInfo is null.IllegalStateException - if this fixture's Component is disabled.IllegalStateException - if this fixture's Component is not showing on the screen.@Nonnull public final S doubleClick()
Component.doubleClick in interface MouseInputSimulationFixture<S>IllegalStateException - if this fixture's Component is disabled.IllegalStateException - if this fixture's Component is not showing on the screen.@Nonnull public final S rightClick()
Component.rightClick in interface MouseInputSimulationFixture<S>IllegalStateException - if this fixture's Component is disabled.IllegalStateException - if this fixture's Component is not showing on the screen.@Nonnull public final S focus()
Component.IllegalStateException - if this fixture's Component is disabled.IllegalStateException - if this fixture's Component is not showing on the screen.@Nonnull public final S pressAndReleaseKey(@Nonnull KeyPressInfo keyPressInfo)
Component. Modifiers is a
mask from the available AWT InputEvent masks.keyPressInfo - specifies the key and modifiers to press.NullPointerException - if the given KeyPressInfo is null.IllegalArgumentException - if the given code is not a valid key code.IllegalStateException - if this fixture's Component is disabled.IllegalStateException - if this fixture's Component is not showing on the screen.KeyPressInfo@Nonnull public final S pressAndReleaseKeys(@Nonnull int... keyCodes)
Component.keyCodes - one or more codes of the keys to press.NullPointerException - if the given array of codes is null.IllegalArgumentException - if any of the given code is not a valid key code.IllegalStateException - if this fixture's Component is disabled.IllegalStateException - if this fixture's Component is not showing on the screen.KeyEvent@Nonnull public final S pressKey(int keyCode)
Component.keyCode - the code of the key to press.IllegalArgumentException - if any of the given code is not a valid key code.IllegalStateException - if this fixture's Component is disabled.IllegalStateException - if this fixture's Component is not showing on the screen.KeyEvent@Nonnull public final S releaseKey(int keyCode)
Component.keyCode - the code of the key to release.IllegalArgumentException - if any of the given code is not a valid key code.IllegalStateException - if this fixture's Component is disabled.IllegalStateException - if this fixture's Component is not showing on the screen.KeyEvent@Nonnull public final S requireFocused()
Component has input focus.AssertionError - if this fixture's Component does not have input focus.@Nonnull public final S requireEnabled()
Component is enabled.AssertionError - if this fixture's Component is disabled.@Nonnull public final S requireEnabled(@Nonnull Timeout timeout)
Component is enabled.timeout - the time this fixture will wait for the component to be enabled.WaitTimedOutError - if this fixture's Component is never enabled.@Nonnull public final S requireDisabled()
Component is disabled.AssertionError - if this fixture's Component is enabled.@Nonnull public final S requireVisible()
Component is visible.AssertionError - if this fixture's Component is not visible.@Nonnull public final S requireNotVisible()
Component is not visible.AssertionError - if this fixture's Component is visible.protected boolean requireShowing()
component lookup scope stored in this fixture's
Robot.true if only showing components can participate in a component lookup, false otherwise.@Nonnull public final FontFixture font()
Component.@Nonnull public final ColorFixture background()
Component.@Nonnull public final ColorFixture foreground()
Component.public final boolean isEnabled()
Component is enabled.true if this fixture's Component is enabled; false otherwise.@Nonnull public final <T extends C> T targetCastedTo(@Nonnull Class<T> type)
Component casted to the given sub-type.type - the type that the managed Component will be casted to.Component casted to the given sub-type.AssertionError - if this fixture's Component is not an instance of the given type.@Nonnull public final C target()
Returns the GUI component in this fixture.
Note: Access to the GUI component returned by this method must be executed in the event
dispatch thread (EDT.) To do so, please execute a GuiQuery or
GuiTask (depending on what you need to do,) inside a GuiActionRunner. To
learn more about Swing threading, please read the Swing
Threading Policy.
Copyright © 2014 AssertJ. All rights reserved.