org.fest.swing.driver
Class JSpinnerDriver

java.lang.Object
  extended by org.fest.swing.driver.ComponentDriver
      extended by org.fest.swing.driver.ContainerDriver
          extended by org.fest.swing.driver.JComponentDriver
              extended by org.fest.swing.driver.JSpinnerDriver

public class JSpinnerDriver
extends JComponentDriver

Understands functional testing of JSpinners:

This class is intended for internal use only. Please use the classes in the package org.fest.swing.fixture in your tests.

Author:
Alex Ruiz, Yvonne Wang

Field Summary
 
Fields inherited from class org.fest.swing.driver.ComponentDriver
robot
 
Constructor Summary
JSpinnerDriver(Robot robot)
          Creates a new JSpinnerDriver.
 
Method Summary
 void decrement(JSpinner spinner)
          Decrements the value of the JSpinner.
 void decrement(JSpinner spinner, int times)
          Decrements the value of the JSpinner the given number of times.
 JTextComponent editor(JSpinner spinner)
          Returns the JTextComponent used as editor in the given JSpinner.
 void enterText(JSpinner spinner, String text)
          Enters the given text in the JSpinner, assuming its editor has a JTextComponent under it.
 void enterTextAndCommit(JSpinner spinner, String text)
          Enters and commits the given text in the JSpinner, assuming its editor has a JTextComponent under it.
 void increment(JSpinner spinner)
          Increments the value of the JSpinner.
 void increment(JSpinner spinner, int times)
          Increments the value of the JSpinner the given number of times.
 void requireValue(JSpinner spinner, Object value)
          Verifies that the value of the JSpinner is equal to the given one.
 void selectValue(JSpinner spinner, Object value)
          Selects the given value in the given JSpinner.
 String textOf(JSpinner spinner)
          Returns the text displayed in the given JSpinner.
 
Methods inherited from class org.fest.swing.driver.JComponentDriver
clientProperty, invokeAction, isVisible, isVisible, requireToolTip, requireToolTip, scrollToVisible
 
Methods inherited from class org.fest.swing.driver.ContainerDriver
move, resize, resizeHeight, resizeWidth
 
Methods inherited from class org.fest.swing.driver.ComponentDriver
assertIsEnabledAndShowing, click, click, click, click, click, doubleClick, drag, dragOver, drop, focus, focusAndWaitForFocusGain, invokePopupMenu, invokePopupMenu, moveMouseIgnoringAnyError, moveMouseIgnoringAnyError, performAccessibleActionOf, pressAndReleaseKey, pressAndReleaseKey, pressAndReleaseKeys, pressKey, propertyName, releaseKey, requireDisabled, requireEnabled, requireEnabled, requireFocused, requireNotVisible, requireSize, requireVisible, rightClick, settings, waitForShowing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSpinnerDriver

public JSpinnerDriver(Robot robot)
Creates a new JSpinnerDriver.

Parameters:
robot - the robot to use to simulate user input.
Method Detail

increment

@RunsInEDT
public void increment(JSpinner spinner,
                                int times)
Increments the value of the JSpinner the given number of times.

Parameters:
spinner - the target JSpinner.
times - how many times the value of this fixture's JSpinner should be incremented.
Throws:
IllegalArgumentException - if times is less than or equal to zero.
IllegalStateException - if the JSpinner is disabled.
IllegalStateException - if the JSpinner is not showing on the screen.

increment

@RunsInEDT
public void increment(JSpinner spinner)
Increments the value of the JSpinner.

Parameters:
spinner - the target JSpinner.
Throws:
IllegalStateException - if the JSpinner is disabled.
IllegalStateException - if the JSpinner is not showing on the screen.

decrement

@RunsInEDT
public void decrement(JSpinner spinner,
                                int times)
Decrements the value of the JSpinner the given number of times.

Parameters:
spinner - the target JSpinner.
times - how many times the value of this fixture's JSpinner should be decremented.
Throws:
IllegalArgumentException - if times is less than or equal to zero.
IllegalStateException - if the JSpinner is disabled.
IllegalStateException - if the JSpinner is not showing on the screen.

decrement

@RunsInEDT
public void decrement(JSpinner spinner)
Decrements the value of the JSpinner.

Parameters:
spinner - the target JSpinner.
Throws:
IllegalStateException - if the JSpinner is disabled.
IllegalStateException - if the JSpinner is not showing on the screen.

textOf

@RunsInEDT
public String textOf(JSpinner spinner)
Returns the text displayed in the given JSpinner. This method first tries to get the text displayed in the JSpinner's editor, assuming it is a JTextComponent. If the text from the editor cannot be retrieved, it will return the String representation of the value in the JSpinner's model.

Parameters:
spinner - the target JSpinner.
Returns:
the text displayed in the given JSpinner.
Since:
1.2

enterTextAndCommit

@RunsInEDT
public void enterTextAndCommit(JSpinner spinner,
                                         String text)
Enters and commits the given text in the JSpinner, assuming its editor has a JTextComponent under it.

Parameters:
spinner - the target JSpinner.
text - the text to enter.
Throws:
IllegalStateException - if the JSpinner is disabled.
IllegalStateException - if the JSpinner is not showing on the screen.
ActionFailedException - if the editor of the JSpinner is not a JTextComponent or cannot be found.
UnexpectedException - if entering the text in the JSpinner's editor fails.

enterText

@RunsInEDT
public void enterText(JSpinner spinner,
                                String text)
Enters the given text in the JSpinner, assuming its editor has a JTextComponent under it. This method does not commit the value to the JSpinner.

Parameters:
spinner - the target JSpinner.
text - the text to enter.
Throws:
IllegalStateException - if the JSpinner is disabled.
IllegalStateException - if the JSpinner is not showing on the screen.
ActionFailedException - if the editor of the JSpinner is not a JTextComponent or cannot be found.
UnexpectedException - if entering the text in the JSpinner's editor fails.
See Also:
enterTextAndCommit(JSpinner, String)

selectValue

@RunsInEDT
public void selectValue(JSpinner spinner,
                                  Object value)
Selects the given value in the given JSpinner.

Parameters:
spinner - the target JSpinner.
value - the value to select.
Throws:
IllegalStateException - if the JSpinner is disabled.
IllegalStateException - if the JSpinner is not showing on the screen.
IllegalArgumentException - if the given JSpinner does not support the given value.

editor

@RunsInEDT
public JTextComponent editor(JSpinner spinner)
Returns the JTextComponent used as editor in the given JSpinner.

Parameters:
spinner - the target JSpinner.
Returns:
the JTextComponent used as editor in the given JSpinner.
Throws:
ComponentLookupException - if the given JSpinner does not have a JTextComponent as editor.

requireValue

@RunsInEDT
public void requireValue(JSpinner spinner,
                                   Object value)
Verifies that the value of the JSpinner is equal to the given one.

Parameters:
spinner - the target JSpinner.
value - the expected value.
Throws:
AssertionError - if the value of the JSpinner is not equal to the given one.


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