org.fest.swing.fixture
Class JLabelFixture

java.lang.Object
  extended by org.fest.swing.fixture.ComponentFixture<JLabel>
      extended by org.fest.swing.fixture.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:

Author:
Alex Ruiz

Field Summary
 
Fields inherited from class org.fest.swing.fixture.ComponentFixture
BACKGROUND_PROPERTY, FONT_PROPERTY, FOREGROUND_PROPERTY, robot, target
 
Constructor Summary
JLabelFixture(Robot robot, JLabel target)
          Creates a new JLabelFixture.
JLabelFixture(Robot robot, String labelName)
          Creates a new JLabelFixture.
 
Method Summary
 JLabelFixture click()
          Simulates a user clicking this fixture's JLabel.
 JLabelFixture click(MouseButton button)
          Simulates a user clicking this fixture's JLabel.
 JLabelFixture click(MouseClickInfo mouseClickInfo)
          Simulates a user clicking this fixture's JLabel.
 Object clientProperty(Object key)
          Returns the client property stored in this fixture's JLabel, under the given key.
 JLabelFixture doubleClick()
          Simulates a user double-clicking this fixture's JLabel.
protected  void driver(JLabelDriver newDriver)
          Sets the JLabelDriver to be used by this fixture.
 JLabelFixture focus()
          Gives input focus to this fixture's JLabel.
 JLabelFixture pressAndReleaseKey(KeyPressInfo keyPressInfo)
          Simulates a user pressing given key with the given modifiers on this fixture's JLabel.
 JLabelFixture pressAndReleaseKeys(int... keyCodes)
          Simulates a user pressing and releasing the given keys on this fixture's JLabel.
 JLabelFixture pressKey(int keyCode)
          Simulates a user pressing the given key on this fixture's JLabel.
 JLabelFixture releaseKey(int keyCode)
          Simulates a user releasing the given key on this fixture's JLabel.
 JLabelFixture requireDisabled()
          Asserts that this fixture's JLabel is disabled.
 JLabelFixture requireEnabled()
          Asserts that this fixture's JLabel is enabled.
 JLabelFixture requireEnabled(Timeout timeout)
          Asserts that this fixture's JLabel is enabled.
 JLabelFixture requireFocused()
          Asserts that this fixture's JLabel has input focus.
 JLabelFixture requireNotVisible()
          Asserts that this fixture's JLabel is not visible.
 JLabelFixture requireText(Pattern pattern)
          Asserts that the text of this fixture's JLabel matches the given regular expression pattern.
 JLabelFixture requireText(String expected)
          Asserts that the text of this fixture's JLabel is equal to the specified String.
 JLabelFixture requireToolTip(Pattern pattern)
          Asserts that the toolTip in this fixture's JLabel matches the given regular expression pattern.
 JLabelFixture requireToolTip(String expected)
          Asserts that the toolTip in this fixture's JLabel matches the given value.
 JLabelFixture requireVisible()
          Asserts that this fixture's JLabel is visible.
 JLabelFixture rightClick()
          Simulates a user right-clicking this fixture's JLabel.
 JPopupMenuFixture showPopupMenu()
          Shows a pop-up menu using this fixture's JLabel as the invoker of the pop-up menu.
 JPopupMenuFixture showPopupMenuAt(Point p)
          Shows a pop-up menu at the given point using this fixture's JLabel as the invoker of the pop-up menu.
 String text()
          Returns the text of this fixture's JLabel.
 
Methods inherited from class org.fest.swing.fixture.ComponentFixture
background, component, font, foreground, requireShowing, targetCastedTo, validateNotNull
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JLabelFixture

public JLabelFixture(Robot robot,
                     JLabel target)
Creates a new JLabelFixture.

Parameters:
robot - performs simulation of user events on the given JLabel.
target - the JLabel to be managed by this fixture.
Throws:
NullPointerException - if robot is null.
NullPointerException - if target is null.

JLabelFixture

public JLabelFixture(Robot robot,
                     String labelName)
Creates a new JLabelFixture.

Parameters:
robot - performs simulation of user events on a JLabel.
labelName - the name of the JLabel to find using the given Robot.
Throws:
NullPointerException - if robot is null.
ComponentLookupException - if a matching JLabel could not be found.
ComponentLookupException - if more than one matching JLabel is found.
Method Detail

driver

protected final void driver(JLabelDriver newDriver)
Sets the JLabelDriver to be used by this fixture.

Parameters:
newDriver - the new JLabelDriver.
Throws:
NullPointerException - if the given driver is null.

text

public String text()
Returns the text of this fixture's JLabel.

Specified by:
text in interface TextDisplayFixture
Returns:
the text of this fixture's JLabel.

click

public JLabelFixture click()
Simulates a user clicking this fixture's JLabel.

Specified by:
click in interface MouseInputSimulationFixture
Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JLabel is disabled.
IllegalStateException - if this fixture's JLabel is not showing on the screen.

click

public JLabelFixture click(MouseButton button)
Simulates a user clicking this fixture's JLabel.

Specified by:
click in interface MouseInputSimulationFixture
Parameters:
button - the button to click.
Returns:
this fixture.
Throws:
NullPointerException - if the given MouseButton is null.
IllegalStateException - if this fixture's JLabel is disabled.
IllegalStateException - if this fixture's JLabel is not showing on the screen.

click

public JLabelFixture click(MouseClickInfo mouseClickInfo)
Simulates a user clicking this fixture's JLabel.

Specified by:
click in interface MouseInputSimulationFixture
Parameters:
mouseClickInfo - specifies the button to click and the times the button should be clicked.
Returns:
this fixture.
Throws:
NullPointerException - if the given MouseClickInfo is null.
IllegalStateException - if this fixture's JLabel is disabled.
IllegalStateException - if this fixture's JLabel is not showing on the screen.

doubleClick

public JLabelFixture doubleClick()
Simulates a user double-clicking this fixture's JLabel.

Specified by:
doubleClick in interface MouseInputSimulationFixture
Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JLabel is disabled.
IllegalStateException - if this fixture's JLabel is not showing on the screen.

rightClick

public JLabelFixture rightClick()
Simulates a user right-clicking this fixture's JLabel.

Specified by:
rightClick in interface MouseInputSimulationFixture
Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JLabel is disabled.
IllegalStateException - if this fixture's JLabel is not showing on the screen.

focus

public JLabelFixture focus()
Gives input focus to this fixture's JLabel.

Specified by:
focus in interface FocusableComponentFixture
Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JLabel is disabled.
IllegalStateException - if this fixture's JLabel is not showing on the screen.

pressAndReleaseKey

public JLabelFixture pressAndReleaseKey(KeyPressInfo keyPressInfo)
Simulates a user pressing given key with the given modifiers on this fixture's JLabel. Modifiers is a mask from the available InputEvent masks.

Specified by:
pressAndReleaseKey in interface KeyboardInputSimulationFixture
Parameters:
keyPressInfo - specifies the key and modifiers to press.
Returns:
this fixture.
Throws:
NullPointerException - if the given KeyPressInfo is null.
IllegalArgumentException - if the given code is not a valid key code.
IllegalStateException - if this fixture's JLabel is disabled.
IllegalStateException - if this fixture's JLabel is not showing on the screen.
See Also:
KeyPressInfo

pressAndReleaseKeys

public JLabelFixture pressAndReleaseKeys(int... keyCodes)
Simulates a user pressing and releasing the given keys on this fixture's JLabel.

Specified by:
pressAndReleaseKeys in interface KeyboardInputSimulationFixture
Parameters:
keyCodes - one or more codes of the keys to press.
Returns:
this fixture.
Throws:
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 JLabel is disabled.
IllegalStateException - if this fixture's JLabel is not showing on the screen.
See Also:
KeyEvent

pressKey

public JLabelFixture pressKey(int keyCode)
Simulates a user pressing the given key on this fixture's JLabel.

Specified by:
pressKey in interface KeyboardInputSimulationFixture
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's JLabel is disabled.
IllegalStateException - if this fixture's JLabel is not showing on the screen.
See Also:
KeyEvent

releaseKey

public JLabelFixture releaseKey(int keyCode)
Simulates a user releasing the given key on this fixture's JLabel.

Specified by:
releaseKey in interface KeyboardInputSimulationFixture
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's JLabel is disabled.
IllegalStateException - if this fixture's JLabel is not showing on the screen.
See Also:
KeyEvent

requireText

public JLabelFixture requireText(String expected)
Asserts that the text of this fixture's JLabel is equal to the specified String.

Specified by:
requireText in interface TextDisplayFixture
Parameters:
expected - the text to match.
Returns:
this fixture.
Throws:
AssertionError - if the text of this fixture's JLabel is not equal to the given one.

requireText

public JLabelFixture requireText(Pattern pattern)
Asserts that the text of this fixture's JLabel matches the given regular expression pattern.

Specified by:
requireText in interface TextDisplayFixture
Parameters:
pattern - the regular expression pattern to match.
Returns:
this fixture.
Throws:
AssertionError - if the text of this fixture's JLabel does not match the given regular expression pattern.
NullPointerException - if the given regular expression pattern is null.
Since:
1.2

requireToolTip

public JLabelFixture requireToolTip(String expected)
Asserts that the toolTip in this fixture's JLabel matches the given value.

Specified by:
requireToolTip in interface ToolTipDisplayFixture
Parameters:
expected - the given value. It can be a regular expression.
Returns:
this fixture.
Throws:
AssertionError - if the toolTip in this fixture's JLabel does not match the given value.
Since:
1.2

requireToolTip

public JLabelFixture requireToolTip(Pattern pattern)
Asserts that the toolTip in this fixture's JLabel matches the given regular expression pattern.

Specified by:
requireToolTip in interface ToolTipDisplayFixture
Parameters:
pattern - the regular expression pattern to match.
Returns:
this fixture.
Throws:
NullPointerException - if the given regular expression pattern is null.
AssertionError - if the toolTip in this fixture's JLabel does not match the given regular expression pattern.
Since:
1.2

requireFocused

public JLabelFixture requireFocused()
Asserts that this fixture's JLabel has input focus.

Specified by:
requireFocused in interface FocusableComponentFixture
Returns:
this fixture.
Throws:
AssertionError - if this fixture's JLabel does not have input focus.

requireEnabled

public JLabelFixture requireEnabled()
Asserts that this fixture's JLabel is enabled.

Specified by:
requireEnabled in interface StateVerificationFixture
Returns:
this fixture.
Throws:
AssertionError - if this fixture's JLabel is disabled.

requireEnabled

public JLabelFixture requireEnabled(Timeout timeout)
Asserts that this fixture's JLabel is enabled.

Specified by:
requireEnabled in interface StateVerificationFixture
Parameters:
timeout - the time this fixture will wait for the component to be enabled.
Returns:
this fixture.
Throws:
WaitTimedOutError - if this fixture's JLabel is never enabled.

requireDisabled

public JLabelFixture requireDisabled()
Asserts that this fixture's JLabel is disabled.

Specified by:
requireDisabled in interface StateVerificationFixture
Returns:
this fixture.
Throws:
AssertionError - if this fixture's JLabel is enabled.

requireVisible

public JLabelFixture requireVisible()
Asserts that this fixture's JLabel is visible.

Specified by:
requireVisible in interface StateVerificationFixture
Returns:
this fixture.
Throws:
AssertionError - if this fixture's JLabel is not visible.

requireNotVisible

public JLabelFixture requireNotVisible()
Asserts that this fixture's JLabel is not visible.

Specified by:
requireNotVisible in interface StateVerificationFixture
Returns:
this fixture.
Throws:
AssertionError - if this fixture's JLabel is visible.

clientProperty

public Object clientProperty(Object key)
Returns the client property stored in this fixture's JLabel, under the given key.

Specified by:
clientProperty in interface ClientPropertyStorageFixture
Parameters:
key - the key to use to retrieve the client property.
Returns:
the value of the client property stored under the given key, or null if the property was not found.
Throws:
NullPointerException - if the given key is null.
Since:
1.2

showPopupMenu

public JPopupMenuFixture showPopupMenu()
Shows a pop-up menu using this fixture's JLabel as the invoker of the pop-up menu.

Specified by:
showPopupMenu in interface JPopupMenuInvokerFixture
Returns:
a fixture that manages the displayed pop-up menu.
Throws:
IllegalStateException - if this fixture's JLabel is disabled.
IllegalStateException - if this fixture's JLabel is not showing on the screen.
ComponentLookupException - if a pop-up menu cannot be found.

showPopupMenuAt

public JPopupMenuFixture showPopupMenuAt(Point p)
Shows a pop-up menu at the given point using this fixture's JLabel as the invoker of the pop-up menu.

Specified by:
showPopupMenuAt in interface JPopupMenuInvokerFixture
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's JLabel is disabled.
IllegalStateException - if this fixture's JLabel is not showing on the screen.
ComponentLookupException - if a pop-up menu cannot be found.


Copyright © 2007-2011 FEST (Fixtures for Easy Software Testing). All Rights Reserved.