org.fest.swing.fixture
Class JSliderFixture

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

public class JSliderFixture
extends ComponentFixture<JSlider>
implements CommonComponentFixture, JComponentFixture, JPopupMenuInvokerFixture

Understands functional testing of JSliders:

Author:
Yvonne Wang, Alex Ruiz

Field Summary
 
Fields inherited from class org.fest.swing.fixture.ComponentFixture
BACKGROUND_PROPERTY, FONT_PROPERTY, FOREGROUND_PROPERTY, robot, target
 
Constructor Summary
JSliderFixture(Robot robot, JSlider target)
          Creates a new JSliderFixture.
JSliderFixture(Robot robot, String sliderName)
          Creates a new JSliderFixture.
 
Method Summary
 JSliderFixture click()
          Simulates a user clicking this fixture's JSlider.
 JSliderFixture click(MouseButton button)
          Simulates a user clicking this fixture's JSlider.
 JSliderFixture click(MouseClickInfo mouseClickInfo)
          Simulates a user clicking this fixture's JSlider.
 Object clientProperty(Object key)
          Returns the client property stored in this fixture's JSlider, under the given key.
 JSliderFixture doubleClick()
          Simulates a user double-clicking this fixture's JSlider.
protected  void driver(JSliderDriver newDriver)
          Sets the JSliderDriver to be used by this fixture.
 JSliderFixture focus()
          Gives input focus to this fixture's JSlider.
 JSliderFixture pressAndReleaseKey(KeyPressInfo keyPressInfo)
          Simulates a user pressing given key with the given modifiers on this fixture's JSlider.
 JSliderFixture pressAndReleaseKeys(int... keyCodes)
          Simulates a user pressing and releasing the given keys on this fixture's JSlider.
 JSliderFixture pressKey(int keyCode)
          Simulates a user pressing the given key on this fixture's JSlider.
 JSliderFixture releaseKey(int keyCode)
          Simulates a user releasing the given key on this fixture's JSlider.
 JSliderFixture requireDisabled()
          Asserts that this fixture's JSlider is disabled.
 JSliderFixture requireEnabled()
          Asserts that this fixture's JSlider is enabled.
 JSliderFixture requireEnabled(Timeout timeout)
          Asserts that this fixture's JSlider is enabled.
 JSliderFixture requireFocused()
          Asserts that this fixture's JSlider has input focus.
 JSliderFixture requireNotVisible()
          Asserts that this fixture's JSlider is not visible.
 JSliderFixture requireToolTip(Pattern pattern)
          Asserts that the toolTip in this fixture's JSlider matches the given regular expression pattern.
 JSliderFixture requireToolTip(String expected)
          Asserts that the toolTip in this fixture's JSlider matches the given value.
 JSliderFixture requireVisible()
          Asserts that this fixture's JSlider.
 JSliderFixture rightClick()
          Simulates a user right-clicking this fixture's JSlider.
 JPopupMenuFixture showPopupMenu()
          Shows a pop-up menu using this fixture's JSlider 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 JSlider as the invoker of the pop-up menu.
 JSliderFixture slideTo(int value)
          Simulates a user sliding this fixture's JSlider to the given value.
 JSliderFixture slideToMaximum()
          Simulates a user sliding this fixture's JSlider to its maximum value.
 JSliderFixture slideToMinimum()
          Simulates a user sliding this fixture's JSlider to its minimum value.
 
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

JSliderFixture

public JSliderFixture(Robot robot,
                      JSlider target)
Creates a new JSliderFixture.

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

JSliderFixture

public JSliderFixture(Robot robot,
                      String sliderName)
Creates a new JSliderFixture.

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

driver

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

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

slideTo

public JSliderFixture slideTo(int value)
Simulates a user sliding this fixture's JSlider to the given value.

Parameters:
value - the value to slide the JSlider to.
Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JSlider is disabled.
IllegalStateException - if this fixture's JSlider is not showing on the screen.
IllegalArgumentException - if the given position is not within the JSlider bounds.

slideToMaximum

public JSliderFixture slideToMaximum()
Simulates a user sliding this fixture's JSlider to its maximum value.

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

slideToMinimum

public JSliderFixture slideToMinimum()
Simulates a user sliding this fixture's JSlider to its minimum value.

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

click

public JSliderFixture click()
Simulates a user clicking this fixture's JSlider.

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

click

public JSliderFixture click(MouseButton button)
Simulates a user clicking this fixture's JSlider.

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

click

public JSliderFixture click(MouseClickInfo mouseClickInfo)
Simulates a user clicking this fixture's JSlider.

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

doubleClick

public JSliderFixture doubleClick()
Simulates a user double-clicking this fixture's JSlider.

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

rightClick

public JSliderFixture rightClick()
Simulates a user right-clicking this fixture's JSlider.

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

focus

public JSliderFixture focus()
Gives input focus to this fixture's JSlider.

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

pressAndReleaseKey

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

pressAndReleaseKeys

public JSliderFixture pressAndReleaseKeys(int... keyCodes)
Simulates a user pressing and releasing the given keys on this fixture's JSlider. This method does not affect the current focus.

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

pressKey

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

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

releaseKey

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

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

requireFocused

public JSliderFixture requireFocused()
Asserts that this fixture's JSlider has input focus.

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

requireEnabled

public JSliderFixture requireEnabled()
Asserts that this fixture's JSlider is enabled.

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

requireEnabled

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

requireDisabled

public JSliderFixture requireDisabled()
Asserts that this fixture's JSlider is disabled.

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

requireVisible

public JSliderFixture requireVisible()
Asserts that this fixture's JSlider.

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

requireNotVisible

public JSliderFixture requireNotVisible()
Asserts that this fixture's JSlider is not visible.

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

requireToolTip

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

requireToolTip

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

clientProperty

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