Package org.fest.swing.fixture
Class JMenuItemFixture
- All Implemented Interfaces:
KeyboardInputSimulationFixture
,StateVerificationFixture
public class JMenuItemFixture
extends ComponentFixture<JMenuItem>
implements KeyboardInputSimulationFixture, StateVerificationFixture
Understands functional testing of
JMenuItem
s:
- user input simulation
- state verification
- property value query
-
Field Summary
FieldsFields inherited from class org.fest.swing.fixture.ComponentFixture
BACKGROUND_PROPERTY, FONT_PROPERTY, FOREGROUND_PROPERTY, robot, target
-
Constructor Summary
ConstructorsConstructorDescriptionJMenuItemFixture
(Robot robot, String menuItemName) Creates a new
.JMenuItemFixture
JMenuItemFixture
(Robot robot, JMenuItem target) Creates a new
.JMenuItemFixture
-
Method Summary
Modifier and TypeMethodDescriptionclick()
Simulates a user selecting this fixture's
.JMenuItem
protected final void
driver
(JMenuItemDriver newDriver) Sets the
to be used by this fixture.JMenuItemDriver
focus()
Gives input focus to this fixture's
.JMenuItem
pressAndReleaseKey
(KeyPressInfo keyPressInfo) Simulates a user pressing given key with the given modifiers on this fixture's
.JMenuItem
pressAndReleaseKeys
(int... keyCodes) Simulates a user pressing and releasing the given keys on this fixture's
.JMenuItem
pressKey
(int keyCode) Simulates a user pressing the given key on this fixture's
.JMenuItem
releaseKey
(int keyCode) Simulates a user releasing the given key on this fixture's
.JMenuItem
Asserts that this fixture's
is disabled.JMenuItem
Asserts that this fixture's
is enabled.JMenuItem
requireEnabled
(Timeout timeout) Asserts that this fixture's
is enabled.JMenuItem
Asserts that this fixture's
is not visible.JMenuItem
Asserts that this fixture's
is visible.JMenuItem
Methods inherited from class org.fest.swing.fixture.ComponentFixture
background, component, font, foreground, requireShowing, targetCastedTo, validateNotNull
-
Field Details
-
driver
-
-
Constructor Details
-
JMenuItemFixture
Creates a new
.JMenuItemFixture
- Parameters:
robot
- performs simulation of user events on aJMenuItem
.menuItemName
- the name of theJMenuItem
to find using the givenRobot
.- Throws:
NullPointerException
- ifrobot
isnull
.ComponentLookupException
- if a matchingJMenuItem
could not be found.ComponentLookupException
- if more than one matchingJMenuItem
is found.
-
JMenuItemFixture
Creates a new
.JMenuItemFixture
- Parameters:
robot
- performs simulation of user events on the givenJMenuItem
.target
- theJMenuItem
to be managed by this fixture.- Throws:
NullPointerException
- ifrobot
isnull
.NullPointerException
- iftarget
isnull
.
-
-
Method Details
-
driver
Sets the
to be used by this fixture.JMenuItemDriver
- Parameters:
newDriver
- the newJMenuItemDriver
.- Throws:
NullPointerException
- if the given driver isnull
.
-
click
Simulates a user selecting this fixture's
.JMenuItem
- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJMenuItem
is disabled.IllegalStateException
- if this fixture'sJMenuItem
is not showing on the screen.ActionFailedException
- if the menu has a pop-up and it fails to show up.
-
focus
Gives input focus to this fixture's
.JMenuItem
- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJMenuItem
is disabled.IllegalStateException
- if this fixture'sJMenuItem
is not showing on the screen.
-
pressAndReleaseKey
Simulates a user pressing given key with the given modifiers on this fixture's
. Modifiers is a mask from the availableJMenuItem
masks.InputEvent
- Specified by:
pressAndReleaseKey
in interfaceKeyboardInputSimulationFixture
- Parameters:
keyPressInfo
- specifies the key and modifiers to press.- Returns:
- this fixture.
- Throws:
NullPointerException
- if the givenKeyPressInfo
isnull
.IllegalArgumentException
- if the given code is not a valid key code.IllegalStateException
- if this fixture'sJMenuItem
is disabled.IllegalStateException
- if this fixture'sJMenuItem
is not showing on the screen.- See Also:
-
pressAndReleaseKeys
Simulates a user pressing and releasing the given keys on this fixture's
.JMenuItem
- Specified by:
pressAndReleaseKeys
in interfaceKeyboardInputSimulationFixture
- Parameters:
keyCodes
- one or more codes of the keys to press.- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJMenuItem
is disabled.IllegalStateException
- if this fixture'sJMenuItem
is not showing on the screen.- See Also:
-
pressKey
Simulates a user pressing the given key on this fixture's
.JMenuItem
- Specified by:
pressKey
in interfaceKeyboardInputSimulationFixture
- Parameters:
keyCode
- the code of the key to press.- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJMenuItem
is disabled.IllegalStateException
- if this fixture'sJMenuItem
is not showing on the screen.- See Also:
-
releaseKey
Simulates a user releasing the given key on this fixture's
.JMenuItem
- Specified by:
releaseKey
in interfaceKeyboardInputSimulationFixture
- Parameters:
keyCode
- the code of the key to release.- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJMenuItem
is disabled.IllegalStateException
- if this fixture'sJMenuItem
is not showing on the screen.- See Also:
-
requireEnabled
Asserts that this fixture's
is enabled.JMenuItem
- Specified by:
requireEnabled
in interfaceStateVerificationFixture
- Returns:
- this fixture.
- Throws:
AssertionError
- if this fixture'sJMenuItem
is disabled.
-
requireEnabled
Asserts that this fixture's
is enabled.JMenuItem
- Specified by:
requireEnabled
in interfaceStateVerificationFixture
- Parameters:
timeout
- the time this fixture will wait for the component to be enabled.- Returns:
- this fixture.
- Throws:
WaitTimedOutError
- if this fixture'sJMenuItem
is never enabled.
-
requireDisabled
Asserts that this fixture's
is disabled.JMenuItem
- Specified by:
requireDisabled
in interfaceStateVerificationFixture
- Returns:
- this fixture.
- Throws:
AssertionError
- if this fixture'sJMenuItem
is enabled.
-
requireVisible
Asserts that this fixture's
is visible.JMenuItem
- Specified by:
requireVisible
in interfaceStateVerificationFixture
- Returns:
- this fixture.
- Throws:
AssertionError
- if this fixture'sJMenuItem
is not visible.
-
requireNotVisible
Asserts that this fixture's
is not visible.JMenuItem
- Specified by:
requireNotVisible
in interfaceStateVerificationFixture
- Returns:
- this fixture.
- Throws:
AssertionError
- if this fixture'sJMenuItem
is visible.
-