org.fest.swing.fixture
Class JCheckBoxFixture

java.lang.Object
  extended by org.fest.swing.fixture.ComponentFixture<JCheckBox>
      extended by org.fest.swing.fixture.JCheckBoxFixture
All Implemented Interfaces:
ClientPropertyStorageFixture, CommonComponentFixture, FocusableComponentFixture, JComponentFixture, JPopupMenuInvokerFixture, KeyboardInputSimulationFixture, MouseInputSimulationFixture, StateVerificationFixture, TextDisplayFixture, ToolTipDisplayFixture, TwoStateButtonFixture

public class JCheckBoxFixture
extends ComponentFixture<JCheckBox>
implements CommonComponentFixture, JComponentFixture, JPopupMenuInvokerFixture, TextDisplayFixture, TwoStateButtonFixture

Understands functional testing of JCheckBoxes:

Author:
Alex Ruiz

Field Summary
 
Fields inherited from class org.fest.swing.fixture.ComponentFixture
BACKGROUND_PROPERTY, FONT_PROPERTY, FOREGROUND_PROPERTY, robot, target
 
Constructor Summary
JCheckBoxFixture(Robot robot, JCheckBox target)
          Creates a new JCheckBoxFixture.
JCheckBoxFixture(Robot robot, String checkBoxName)
          Creates a new JCheckBoxFixture.
 
Method Summary
 JCheckBoxFixture check()
          Checks (or selects) this fixture's JCheckBox only it is not already checked.
 JCheckBoxFixture click()
          Simulates a user clicking this fixture's JCheckBox.
 JCheckBoxFixture click(MouseButton button)
          Simulates a user clicking this fixture's JCheckBox.
 JCheckBoxFixture click(MouseClickInfo mouseClickInfo)
          Simulates a user clicking this fixture's JCheckBox.
 Object clientProperty(Object key)
          Returns the client property stored in this fixture's JCheckBox, under the given key.
 JCheckBoxFixture doubleClick()
          Simulates a user double-clicking this fixture's JCheckBox.
protected  void driver(AbstractButtonDriver newDriver)
          Sets the AbstractButtonDriver to be used by this fixture.
 JCheckBoxFixture focus()
          Gives input focus to this fixture's JCheckBox.
 JCheckBoxFixture pressAndReleaseKey(KeyPressInfo keyPressInfo)
          Simulates a user pressing given key with the given modifiers on this fixture's JCheckBox.
 JCheckBoxFixture pressAndReleaseKeys(int... keyCodes)
          Simulates a user pressing and releasing the given keys on this fixture's JCheckBox.
 JCheckBoxFixture pressKey(int keyCode)
          Simulates a user pressing the given key on this fixture's JCheckBox.
 JCheckBoxFixture releaseKey(int keyCode)
          Simulates a user releasing the given key on this fixture's JCheckBox.
 JCheckBoxFixture requireDisabled()
          Asserts that this fixture's JCheckBox is disabled.
 JCheckBoxFixture requireEnabled()
          Asserts that this fixture's JCheckBox is enabled.
 JCheckBoxFixture requireEnabled(Timeout timeout)
          Asserts that this fixture's JCheckBox is enabled.
 JCheckBoxFixture requireFocused()
          Asserts that this fixture's JCheckBox has input focus.
 JCheckBoxFixture requireNotSelected()
          Verifies that this fixture's JCheckBox is not selected.
 JCheckBoxFixture requireNotVisible()
          Asserts that this fixture's JCheckBox is not visible.
 JCheckBoxFixture requireSelected()
          Verifies that this fixture's JCheckBox is selected.
 JCheckBoxFixture requireText(Pattern pattern)
          Asserts that the text of this fixture's JCheckBox matches the given regular expression pattern.
 JCheckBoxFixture requireText(String expected)
          Asserts that the text of this fixture's JCheckBox is equal to or matches the specified String.
 JCheckBoxFixture requireToolTip(Pattern pattern)
          Asserts that the toolTip in this fixture's JCheckBox matches the given regular expression pattern.
 JCheckBoxFixture requireToolTip(String expected)
          Asserts that the toolTip in this fixture's JCheckBox matches the given value.
 JCheckBoxFixture requireVisible()
          Asserts that this fixture's JCheckBox is visible.
 JCheckBoxFixture rightClick()
          Simulates a user right-clicking this fixture's JCheckBox.
 JPopupMenuFixture showPopupMenu()
          Shows a pop-up menu using this fixture's JCheckBox 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 JCheckBox as the invoker of the pop-up menu.
 String text()
          Returns the text of this fixture's JCheckBox.
 JCheckBoxFixture uncheck()
          Unchecks this fixture's JCheckBox only if it is checked.
 
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

JCheckBoxFixture

public JCheckBoxFixture(Robot robot,
                        JCheckBox target)
Creates a new JCheckBoxFixture.

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

JCheckBoxFixture

public JCheckBoxFixture(Robot robot,
                        String checkBoxName)
Creates a new JCheckBoxFixture.

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

driver

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

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

text

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

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

check

public JCheckBoxFixture check()
Checks (or selects) this fixture's JCheckBox only it is not already checked.

Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JCheckBox is disabled.
IllegalStateException - if this fixture's JCheckBox is not showing on the screen.

uncheck

public JCheckBoxFixture uncheck()
Unchecks this fixture's JCheckBox only if it is checked.

Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JCheckBox is disabled.
IllegalStateException - if this fixture's JCheckBox is not showing on the screen.

click

public JCheckBoxFixture click()
Simulates a user clicking this fixture's JCheckBox.

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

click

public JCheckBoxFixture click(MouseButton button)
Simulates a user clicking this fixture's JCheckBox.

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 JCheckBox is disabled.
IllegalStateException - if this fixture's JCheckBox is not showing on the screen.

click

public JCheckBoxFixture click(MouseClickInfo mouseClickInfo)
Simulates a user clicking this fixture's JCheckBox.

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 JCheckBox is disabled.
IllegalStateException - if this fixture's JCheckBox is not showing on the screen.

doubleClick

public JCheckBoxFixture doubleClick()
Simulates a user double-clicking this fixture's JCheckBox.

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

rightClick

public JCheckBoxFixture rightClick()
Simulates a user right-clicking this fixture's JCheckBox.

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

focus

public JCheckBoxFixture focus()
Gives input focus to this fixture's JCheckBox.

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

pressAndReleaseKey

public JCheckBoxFixture pressAndReleaseKey(KeyPressInfo keyPressInfo)
Simulates a user pressing given key with the given modifiers on this fixture's JCheckBox. 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 JCheckBox is disabled.
IllegalStateException - if this fixture's JCheckBox is not showing on the screen.
See Also:
KeyPressInfo

pressAndReleaseKeys

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

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 JCheckBox is disabled.
IllegalStateException - if this fixture's JCheckBox is not showing on the screen.
See Also:
KeyEvent

pressKey

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

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 JCheckBox is disabled.
IllegalStateException - if this fixture's JCheckBox is not showing on the screen.
See Also:
KeyEvent

releaseKey

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

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 JCheckBox is disabled.
IllegalStateException - if this fixture's JCheckBox is not showing on the screen.
See Also:
KeyEvent

requireFocused

public JCheckBoxFixture requireFocused()
Asserts that this fixture's JCheckBox has input focus.

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

requireEnabled

public JCheckBoxFixture requireEnabled()
Asserts that this fixture's JCheckBox is enabled.

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

requireEnabled

public JCheckBoxFixture requireEnabled(Timeout timeout)
Asserts that this fixture's JCheckBox 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 JCheckBox is never enabled.

requireDisabled

public JCheckBoxFixture requireDisabled()
Asserts that this fixture's JCheckBox is disabled.

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

requireSelected

public JCheckBoxFixture requireSelected()
Verifies that this fixture's JCheckBox is selected.

Specified by:
requireSelected in interface TwoStateButtonFixture
Returns:
this fixture.
Throws:
AssertionError - if the JCheckBox managed by this fixture is not selected.

requireNotSelected

public JCheckBoxFixture requireNotSelected()
Verifies that this fixture's JCheckBox is not selected.

Specified by:
requireNotSelected in interface TwoStateButtonFixture
Returns:
this fixture.
Throws:
AssertionError - if the JCheckBox managed by this fixture is selected.

requireVisible

public JCheckBoxFixture requireVisible()
Asserts that this fixture's JCheckBox is visible.

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

requireNotVisible

public JCheckBoxFixture requireNotVisible()
Asserts that this fixture's JCheckBox is not visible.

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

requireText

public JCheckBoxFixture requireText(String expected)
Asserts that the text of this fixture's JCheckBox is equal to or matches the specified String.

Specified by:
requireText in interface TextDisplayFixture
Parameters:
expected - the text to match. It can be a regular expression.
Returns:
this fixture.
Throws:
AssertionError - if the text of the target JCheckBox is not equal to or does not match the given one.

requireText

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

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

requireToolTip

public JCheckBoxFixture requireToolTip(String expected)
Asserts that the toolTip in this fixture's JCheckBox 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 JCheckBox does not match the given value.
Since:
1.2

requireToolTip

public JCheckBoxFixture requireToolTip(Pattern pattern)
Asserts that the toolTip in this fixture's JCheckBox 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 JCheckBox does not match the given regular expression.
Since:
1.2

clientProperty

public Object clientProperty(Object key)
Returns the client property stored in this fixture's JCheckBox, 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 JCheckBox 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 JCheckBox is disabled.
IllegalStateException - if this fixture's JCheckBox 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 JCheckBox 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 JCheckBox is disabled.
IllegalStateException - if this fixture's JCheckBox 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.