Package org.fest.swing.fixture
Class JLabelFixture
- All Implemented Interfaces:
ClientPropertyStorageFixture,CommonComponentFixture,FocusableComponentFixture,JComponentFixture,JPopupMenuInvokerFixture,KeyboardInputSimulationFixture,MouseInputSimulationFixture,StateVerificationFixture,TextDisplayFixture,ToolTipDisplayFixture
public class JLabelFixture
extends ComponentFixture<JLabel>
implements CommonComponentFixture, JComponentFixture, JPopupMenuInvokerFixture, TextDisplayFixture
Understands functional testing of
JLabels:
- 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
ConstructorsConstructorDescriptionJLabelFixture(Robot robot, String labelName) Creates a new.JLabelFixtureJLabelFixture(Robot robot, JLabel target) Creates a new.JLabelFixture -
Method Summary
Modifier and TypeMethodDescriptionclick()Simulates a user clicking this fixture's.JLabelclick(MouseButton button) Simulates a user clicking this fixture's.JLabelclick(MouseClickInfo mouseClickInfo) Simulates a user clicking this fixture's.JLabelclientProperty(Object key) Returns the client property stored in this fixture's, under the given key.JLabelprivate voidSimulates a user double-clicking this fixture's.JLabelprotected final voiddriver(JLabelDriver newDriver) Sets theto be used by this fixture.JLabelDriverfocus()Gives input focus to this fixture's.JLabelpressAndReleaseKey(KeyPressInfo keyPressInfo) Simulates a user pressing given key with the given modifiers on this fixture's.JLabelpressAndReleaseKeys(int... keyCodes) Simulates a user pressing and releasing the given keys on this fixture's.JLabelpressKey(int keyCode) Simulates a user pressing the given key on this fixture's.JLabelreleaseKey(int keyCode) Simulates a user releasing the given key on this fixture's.JLabelAsserts that this fixture'sis disabled.JLabelAsserts that this fixture'sis enabled.JLabelrequireEnabled(Timeout timeout) Asserts that this fixture'sis enabled.JLabelAsserts that this fixture'shas input focus.JLabelAsserts that this fixture'sis not visible.JLabelrequireText(String expected) Asserts that the text of this fixture'sis equal to the specifiedJLabelString.requireText(Pattern pattern) Asserts that the text of this fixture'smatches the given regular expression pattern.JLabelrequireToolTip(String expected) Asserts that the toolTip in this fixture'smatches the given value.JLabelrequireToolTip(Pattern pattern) Asserts that the toolTip in this fixture'smatches the given regular expression pattern.JLabelAsserts that this fixture'sis visible.JLabelSimulates a user right-clicking this fixture's.JLabelShows a pop-up menu using this fixture'sas the invoker of the pop-up menu.JLabelShows a pop-up menu at the given point using this fixture'sas the invoker of the pop-up menu.JLabeltext()Returns the text of this fixture's.JLabelMethods inherited from class org.fest.swing.fixture.ComponentFixture
background, component, font, foreground, requireShowing, targetCastedTo, validateNotNull
-
Field Details
-
driver
-
-
Constructor Details
-
JLabelFixture
Creates a new.JLabelFixture- Parameters:
robot- performs simulation of user events on the givenJLabel.target- theJLabelto be managed by this fixture.- Throws:
NullPointerException- ifrobotisnull.NullPointerException- iftargetisnull.
-
JLabelFixture
Creates a new.JLabelFixture- Parameters:
robot- performs simulation of user events on aJLabel.labelName- the name of theJLabelto find using the givenRobot.- Throws:
NullPointerException- ifrobotisnull.ComponentLookupException- if a matchingJLabelcould not be found.ComponentLookupException- if more than one matchingJLabelis found.
-
-
Method Details
-
createDriver
private void createDriver() -
driver
Sets theto be used by this fixture.JLabelDriver- Parameters:
newDriver- the newJLabelDriver.- Throws:
NullPointerException- if the given driver isnull.
-
text
Returns the text of this fixture's.JLabel- Specified by:
textin interfaceTextDisplayFixture- Returns:
- the text of this fixture's
JLabel.
-
click
Simulates a user clicking this fixture's.JLabel- Specified by:
clickin interfaceMouseInputSimulationFixture- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJLabelis disabled.IllegalStateException- if this fixture'sJLabelis not showing on the screen.
-
click
Simulates a user clicking this fixture's.JLabel- Specified by:
clickin interfaceMouseInputSimulationFixture- Parameters:
button- the button to click.- Returns:
- this fixture.
- Throws:
NullPointerException- if the givenMouseButtonisnull.IllegalStateException- if this fixture'sJLabelis disabled.IllegalStateException- if this fixture'sJLabelis not showing on the screen.
-
click
Simulates a user clicking this fixture's.JLabel- Specified by:
clickin interfaceMouseInputSimulationFixture- Parameters:
mouseClickInfo- specifies the button to click and the times the button should be clicked.- Returns:
- this fixture.
- Throws:
NullPointerException- if the givenMouseClickInfoisnull.IllegalStateException- if this fixture'sJLabelis disabled.IllegalStateException- if this fixture'sJLabelis not showing on the screen.
-
doubleClick
Simulates a user double-clicking this fixture's.JLabel- Specified by:
doubleClickin interfaceMouseInputSimulationFixture- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJLabelis disabled.IllegalStateException- if this fixture'sJLabelis not showing on the screen.
-
rightClick
Simulates a user right-clicking this fixture's.JLabel- Specified by:
rightClickin interfaceMouseInputSimulationFixture- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJLabelis disabled.IllegalStateException- if this fixture'sJLabelis not showing on the screen.
-
focus
Gives input focus to this fixture's.JLabel- Specified by:
focusin interfaceFocusableComponentFixture- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJLabelis disabled.IllegalStateException- if this fixture'sJLabelis 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 availableJLabelmasks.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'sJLabelis disabled.IllegalStateException- if this fixture'sJLabelis not showing on the screen.- See Also:
-
pressAndReleaseKeys
Simulates a user pressing and releasing the given keys on this fixture's.JLabel- Specified by:
pressAndReleaseKeysin interfaceKeyboardInputSimulationFixture- Parameters:
keyCodes- one or more codes of the keys to press.- Returns:
- this fixture.
- Throws:
NullPointerException- if the given array of codes isnull.IllegalArgumentException- if any of the given code is not a valid key code.IllegalStateException- if this fixture'sJLabelis disabled.IllegalStateException- if this fixture'sJLabelis not showing on the screen.- See Also:
-
pressKey
Simulates a user pressing the given key on this fixture's.JLabel- Specified by:
pressKeyin interfaceKeyboardInputSimulationFixture- Parameters:
keyCode- the code of the key to press.- Returns:
- this fixture.
- Throws:
IllegalArgumentException- if any of the given code is not a valid key code.IllegalStateException- if this fixture'sJLabelis disabled.IllegalStateException- if this fixture'sJLabelis not showing on the screen.- See Also:
-
releaseKey
Simulates a user releasing the given key on this fixture's.JLabel- Specified by:
releaseKeyin interfaceKeyboardInputSimulationFixture- Parameters:
keyCode- the code of the key to release.- Returns:
- this fixture.
- Throws:
IllegalArgumentException- if any of the given code is not a valid key code.IllegalStateException- if this fixture'sJLabelis disabled.IllegalStateException- if this fixture'sJLabelis not showing on the screen.- See Also:
-
requireText
Asserts that the text of this fixture'sis equal to the specifiedJLabelString.- Specified by:
requireTextin interfaceTextDisplayFixture- Parameters:
expected- the text to match.- Returns:
- this fixture.
- Throws:
AssertionError- if the text of this fixture'sJLabelis not equal to the given one.
-
requireText
Asserts that the text of this fixture'smatches the given regular expression pattern.JLabel- Specified by:
requireTextin interfaceTextDisplayFixture- Parameters:
pattern- the regular expression pattern to match.- Returns:
- this fixture.
- Throws:
AssertionError- if the text of this fixture'sJLabeldoes not match the given regular expression pattern.NullPointerException- if the given regular expression pattern isnull.- Since:
- 1.2
-
requireToolTip
Asserts that the toolTip in this fixture'smatches the given value.JLabel- Specified by:
requireToolTipin interfaceToolTipDisplayFixture- Parameters:
expected- the given value. It can be a regular expression.- Returns:
- this fixture.
- Throws:
AssertionError- if the toolTip in this fixture'sJLabeldoes not match the given value.- Since:
- 1.2
-
requireToolTip
Asserts that the toolTip in this fixture'smatches the given regular expression pattern.JLabel- Specified by:
requireToolTipin interfaceToolTipDisplayFixture- Parameters:
pattern- the regular expression pattern to match.- Returns:
- this fixture.
- Throws:
NullPointerException- if the given regular expression pattern isnull.AssertionError- if the toolTip in this fixture'sJLabeldoes not match the given regular expression pattern.- Since:
- 1.2
-
requireFocused
Asserts that this fixture'shas input focus.JLabel- Specified by:
requireFocusedin interfaceFocusableComponentFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJLabeldoes not have input focus.
-
requireEnabled
Asserts that this fixture'sis enabled.JLabel- Specified by:
requireEnabledin interfaceStateVerificationFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJLabelis disabled.
-
requireEnabled
Asserts that this fixture'sis enabled.JLabel- 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'sJLabelis never enabled.
-
requireDisabled
Asserts that this fixture'sis disabled.JLabel- Specified by:
requireDisabledin interfaceStateVerificationFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJLabelis enabled.
-
requireVisible
Asserts that this fixture'sis visible.JLabel- Specified by:
requireVisiblein interfaceStateVerificationFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJLabelis not visible.
-
requireNotVisible
Asserts that this fixture'sis not visible.JLabel- Specified by:
requireNotVisiblein interfaceStateVerificationFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJLabelis visible.
-
clientProperty
Returns the client property stored in this fixture's, under the given key.JLabel- Specified by:
clientPropertyin interfaceClientPropertyStorageFixture- Parameters:
key- the key to use to retrieve the client property.- Returns:
- the value of the client property stored under the given key, or
nullif the property was not found. - Throws:
NullPointerException- if the given key isnull.- Since:
- 1.2
-
showPopupMenu
Shows a pop-up menu using this fixture'sas the invoker of the pop-up menu.JLabel- Specified by:
showPopupMenuin interfaceJPopupMenuInvokerFixture- Returns:
- a fixture that manages the displayed pop-up menu.
- Throws:
IllegalStateException- if this fixture'sJLabelis disabled.IllegalStateException- if this fixture'sJLabelis not showing on the screen.ComponentLookupException- if a pop-up menu cannot be found.
-
showPopupMenuAt
Shows a pop-up menu at the given point using this fixture'sas the invoker of the pop-up menu.JLabel- Specified by:
showPopupMenuAtin interfaceJPopupMenuInvokerFixture- Parameters:
p- the given point where to show the pop-up menu.- Returns:
- a fixture that manages the displayed pop-up menu.
- Throws:
IllegalStateException- if this fixture'sJLabelis disabled.IllegalStateException- if this fixture'sJLabelis not showing on the screen.ComponentLookupException- if a pop-up menu cannot be found.
-