T - the type of Component that this fixture can manage.public abstract class GenericComponentFixture<T extends Component> extends ComponentFixture<T> implements CommonComponentFixture
Example:
public class MyWidget extends JComponent {
...
public void paintComponent(Graphics g) {
...
}
...
}
public class MyWidgetFixture extends GenericComponentFixture<MyWidget> {
public MyWidgetFixture(Robot robot, MyWidget target) {
super(robot, target);
}
public void clickAndDrag(Point start, Point end) {
robot.pressMouse(target, start);
robot.moveMouse(target, end);
robot.releaseAllMouseButtons();
}
}
BACKGROUND_PROPERTY, FONT_PROPERTY, FOREGROUND_PROPERTY, robot, target| Constructor and Description |
|---|
GenericComponentFixture(Robot robot,
ComponentDriver driver,
T target)
Creates a new
using a provided driver. |
GenericComponentFixture(Robot robot,
T target)
Creates a new
. |
| Modifier and Type | Method and Description |
|---|---|
GenericComponentFixture<T> |
click()
Simulates a user clicking this fixture's GUI component.
|
GenericComponentFixture<T> |
click(MouseButton button)
Simulates a user clicking this fixture's GUI component.
|
GenericComponentFixture<T> |
click(MouseClickInfo mouseClickInfo)
Simulates a user clicking this fixture's GUI component.
|
GenericComponentFixture<T> |
doubleClick()
Simulates a user double-clicking this fixture's GUI component.
|
protected ComponentDriver |
driver()
Returns the
used by this fixture. |
protected void |
driver(ComponentDriver newDriver)
Sets the
to be used by this fixture. |
GenericComponentFixture<T> |
focus()
Gives input focus to this fixture's GUI component.
|
GenericComponentFixture<T> |
pressAndReleaseKey(KeyPressInfo keyPressInfo)
Simulates a user pressing given key with the given modifiers on this fixture's GUI component.
|
GenericComponentFixture<T> |
pressAndReleaseKeys(int... keyCodes)
Simulates a user pressing and releasing the given keys on this fixture's GUI component.
|
GenericComponentFixture<T> |
pressKey(int keyCode)
Simulates a user pressing given key on this fixture's GUI component.
|
GenericComponentFixture<T> |
releaseKey(int keyCode)
Simulates a user releasing the given key on this fixture's GUI component.
|
GenericComponentFixture<T> |
requireDisabled()
Asserts that this fixture's GUI component is disabled.
|
GenericComponentFixture<T> |
requireEnabled()
Asserts that this fixture's GUI component is enabled.
|
GenericComponentFixture<T> |
requireEnabled(Timeout timeout)
Asserts that this fixture's GUI component is enabled.
|
GenericComponentFixture<T> |
requireFocused()
Asserts that this fixture's GUI component has input focus.
|
GenericComponentFixture<T> |
requireNotVisible()
Asserts that this fixture's GUI component is not visible.
|
GenericComponentFixture<T> |
requireVisible()
Asserts that this fixture's GUI component is visible.
|
GenericComponentFixture<T> |
rightClick()
Simulates a user right-clicking this fixture's GUI component.
|
background, component, font, foreground, requireShowing, targetCastedTo, validateNotNullpublic GenericComponentFixture(Robot robot, T target)
GenericComponentFixture.robot - performs simulation of user events on the given target component.target - the target Component to be managed by this fixture.NullPointerException - if robot is null.NullPointerException - if target is null.public GenericComponentFixture(Robot robot, ComponentDriver driver, T target)
GenericComponentFixture using a provided driver.robot - performs simulation of user events on the given target component.driver - provided driver to handle input requests.target - the target Component to be managed by this fixture.NullPointerException - if robot is null.NullPointerException - if driver is null.NullPointerException - if target is null.protected final void driver(ComponentDriver newDriver)
ComponentDriver to be used by this fixture.newDriver - the new ComponentDriver.NullPointerException - if the given driver is null.protected final ComponentDriver driver()
ComponentDriver used by this fixture.public GenericComponentFixture<T> click()
click in interface MouseInputSimulationFixturepublic GenericComponentFixture<T> click(MouseButton button)
click in interface MouseInputSimulationFixturebutton - the button to click.public GenericComponentFixture<T> click(MouseClickInfo mouseClickInfo)
click in interface MouseInputSimulationFixturemouseClickInfo - specifies the button to click and the times the button should be clicked.public GenericComponentFixture<T> doubleClick()
doubleClick in interface MouseInputSimulationFixturepublic GenericComponentFixture<T> rightClick()
rightClick in interface MouseInputSimulationFixturepublic GenericComponentFixture<T> focus()
focus in interface FocusableComponentFixturepublic GenericComponentFixture<T> pressAndReleaseKey(KeyPressInfo keyPressInfo)
InputEvent masks.
The following code listing shows how to press 'CTRL' + 'C' in a platform-safe way:
JTextComponentFixture textBox = dialog.textBox("username");
textBox.selectAll()
.pressAndReleaseKey(key(VK_C).modifiers(controlOrCommandMask()));
pressAndReleaseKey in interface KeyboardInputSimulationFixturekeyPressInfo - specifies the key and modifiers to press.public GenericComponentFixture<T> pressAndReleaseKeys(int... keyCodes)
pressAndReleaseKeys in interface KeyboardInputSimulationFixturekeyCodes - one or more codes of the keys to press.KeyEventpublic GenericComponentFixture<T> pressKey(int keyCode)
pressKey in interface KeyboardInputSimulationFixturekeyCode - the code of the key to press.KeyEventpublic GenericComponentFixture<T> releaseKey(int keyCode)
releaseKey in interface KeyboardInputSimulationFixturekeyCode - the code of the key to release.KeyEventpublic GenericComponentFixture<T> requireEnabled()
requireEnabled in interface StateVerificationFixturepublic GenericComponentFixture<T> requireEnabled(Timeout timeout)
requireEnabled in interface StateVerificationFixturetimeout - the time this fixture will wait for the component to be enabled.public GenericComponentFixture<T> requireDisabled()
requireDisabled in interface StateVerificationFixturepublic GenericComponentFixture<T> requireVisible()
requireVisible in interface StateVerificationFixturepublic GenericComponentFixture<T> requireNotVisible()
requireNotVisible in interface StateVerificationFixturepublic GenericComponentFixture<T> requireFocused()
requireFocused in interface FocusableComponentFixtureCopyright © 2007-2012 FEST (Fixtures for Easy Software Testing). All Rights Reserved.