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
JMenuItems:
- 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.JMenuItemFixtureJMenuItemFixture(Robot robot, JMenuItem target) Creates a new.JMenuItemFixture -
Method Summary
Modifier and TypeMethodDescriptionclick()Simulates a user selecting this fixture's.JMenuItemprotected final voiddriver(JMenuItemDriver newDriver) Sets theto be used by this fixture.JMenuItemDriverfocus()Gives input focus to this fixture's.JMenuItempressAndReleaseKey(KeyPressInfo keyPressInfo) Simulates a user pressing given key with the given modifiers on this fixture's.JMenuItempressAndReleaseKeys(int... keyCodes) Simulates a user pressing and releasing the given keys on this fixture's.JMenuItempressKey(int keyCode) Simulates a user pressing the given key on this fixture's.JMenuItemreleaseKey(int keyCode) Simulates a user releasing the given key on this fixture's.JMenuItemAsserts that this fixture'sis disabled.JMenuItemAsserts that this fixture'sis enabled.JMenuItemrequireEnabled(Timeout timeout) Asserts that this fixture'sis enabled.JMenuItemAsserts that this fixture'sis not visible.JMenuItemAsserts that this fixture'sis visible.JMenuItemMethods 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 theJMenuItemto find using the givenRobot.- Throws:
NullPointerException- ifrobotisnull.ComponentLookupException- if a matchingJMenuItemcould not be found.ComponentLookupException- if more than one matchingJMenuItemis found.
-
JMenuItemFixture
Creates a new.JMenuItemFixture- Parameters:
robot- performs simulation of user events on the givenJMenuItem.target- theJMenuItemto be managed by this fixture.- Throws:
NullPointerException- ifrobotisnull.NullPointerException- iftargetisnull.
-
-
Method Details
-
driver
Sets theto 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'sJMenuItemis disabled.IllegalStateException- if this fixture'sJMenuItemis 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'sJMenuItemis disabled.IllegalStateException- if this fixture'sJMenuItemis 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 availableJMenuItemmasks.InputEvent- Specified by:
pressAndReleaseKeyin interfaceKeyboardInputSimulationFixture- Parameters:
keyPressInfo- specifies the key and modifiers to press.- Returns:
- this fixture.
- Throws:
NullPointerException- if the givenKeyPressInfoisnull.IllegalArgumentException- if the given code is not a valid key code.IllegalStateException- if this fixture'sJMenuItemis disabled.IllegalStateException- if this fixture'sJMenuItemis not showing on the screen.- See Also:
-
pressAndReleaseKeys
Simulates a user pressing and releasing the given keys on this fixture's.JMenuItem- Specified by:
pressAndReleaseKeysin interfaceKeyboardInputSimulationFixture- Parameters:
keyCodes- one or more codes of the keys to press.- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJMenuItemis disabled.IllegalStateException- if this fixture'sJMenuItemis not showing on the screen.- See Also:
-
pressKey
Simulates a user pressing the given key on this fixture's.JMenuItem- Specified by:
pressKeyin interfaceKeyboardInputSimulationFixture- Parameters:
keyCode- the code of the key to press.- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJMenuItemis disabled.IllegalStateException- if this fixture'sJMenuItemis not showing on the screen.- See Also:
-
releaseKey
Simulates a user releasing the given key on this fixture's.JMenuItem- Specified by:
releaseKeyin interfaceKeyboardInputSimulationFixture- Parameters:
keyCode- the code of the key to release.- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJMenuItemis disabled.IllegalStateException- if this fixture'sJMenuItemis not showing on the screen.- See Also:
-
requireEnabled
Asserts that this fixture'sis enabled.JMenuItem- Specified by:
requireEnabledin interfaceStateVerificationFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJMenuItemis disabled.
-
requireEnabled
Asserts that this fixture'sis enabled.JMenuItem- Specified by:
requireEnabledin interfaceStateVerificationFixture- Parameters:
timeout- the time this fixture will wait for the component to be enabled.- Returns:
- this fixture.
- Throws:
WaitTimedOutError- if this fixture'sJMenuItemis never enabled.
-
requireDisabled
Asserts that this fixture'sis disabled.JMenuItem- Specified by:
requireDisabledin interfaceStateVerificationFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJMenuItemis enabled.
-
requireVisible
Asserts that this fixture'sis visible.JMenuItem- Specified by:
requireVisiblein interfaceStateVerificationFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJMenuItemis not visible.
-
requireNotVisible
Asserts that this fixture'sis not visible.JMenuItem- Specified by:
requireNotVisiblein interfaceStateVerificationFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJMenuItemis visible.
-