org.fest.swing.fixture
Class JToolBarFixture

java.lang.Object
  extended by org.fest.swing.fixture.ComponentFixture<T>
      extended by org.fest.swing.fixture.ContainerFixture<JToolBar>
          extended by org.fest.swing.fixture.JToolBarFixture
All Implemented Interfaces:
ClientPropertyStorageFixture, CommonComponentFixture, ComponentContainerFixture, FocusableComponentFixture, JComponentFixture, JPopupMenuInvokerFixture, KeyboardInputSimulationFixture, MouseInputSimulationFixture, StateVerificationFixture, ToolTipDisplayFixture

public class JToolBarFixture
extends ContainerFixture<JToolBar>
implements CommonComponentFixture, JComponentFixture, JPopupMenuInvokerFixture

Understands functional testing of JToolBars:

Author:
Alex Ruiz

Nested Class Summary
static class JToolBarFixture.UnfloatConstraint
          Understands constraints used to unfloat a floating JToolBar.
 
Field Summary
 
Fields inherited from class org.fest.swing.fixture.ComponentFixture
BACKGROUND_PROPERTY, FONT_PROPERTY, FOREGROUND_PROPERTY, robot, target
 
Fields inherited from interface org.fest.swing.fixture.ComponentContainerFixture
DEFAULT_DIALOG_LOOKUP_TIMEOUT
 
Constructor Summary
JToolBarFixture(Robot robot, JToolBar target)
          Creates a new JToolBarFixture.
JToolBarFixture(Robot robot, String toolbarName)
          Creates a new JToolBarFixture.
 
Method Summary
 JToolBarFixture click()
          Simulates a user clicking this fixture's JToolBar.
 JToolBarFixture click(MouseButton button)
          Simulates a user clicking this fixture's JToolBar.
 JToolBarFixture click(MouseClickInfo mouseClickInfo)
          Simulates a user clicking this fixture's JToolBar.
 Object clientProperty(Object key)
          Returns the client property stored in this fixture's JToolBarFixture, under the given key.
 JToolBarFixture doubleClick()
          Simulates a user double-clicking this fixture's JToolBar.
protected  void driver(JToolBarDriver newDriver)
          Sets the JToolBarDriver to be used by this fixture.
 JToolBarFixture floatTo(Point point)
          Simulates a user dragging this fixture's JToolBar to the given location, causing it to float.
 JToolBarFixture focus()
          Gives input focus to this fixture's JToolBar.
 JToolBarFixture pressAndReleaseKey(KeyPressInfo keyPressInfo)
          Simulates a user pressing given key with the given modifiers on this fixture's JToolBar.
 JToolBarFixture pressAndReleaseKeys(int... keyCodes)
          Simulates a user pressing and releasing the given keys in this fixture's JToolBar.
 JToolBarFixture pressKey(int keyCode)
          Simulates a user pressing the given key on this fixture's JToolBar.
 JToolBarFixture releaseKey(int keyCode)
          Simulates a user releasing the given key on this fixture's JToolBar.
 JToolBarFixture requireDisabled()
          Asserts that this fixture's JToolBar is disabled.
 JToolBarFixture requireEnabled()
          Asserts that this fixture's JToolBar is enabled.
 JToolBarFixture requireEnabled(Timeout timeout)
          Asserts that this fixture's JToolBar is enabled.
 JToolBarFixture requireFocused()
          Asserts that this fixture's JToolBar has input focus.
 JToolBarFixture requireNotVisible()
          Asserts that this fixture's JToolBar is not visible.
 JToolBarFixture requireToolTip(Pattern pattern)
          Asserts that the toolTip in this fixture's JToolBar matches the given regular expression pattern.
 JToolBarFixture requireToolTip(String expected)
          Asserts that the toolTip in this fixture's JToolBar matches the given value.
 JToolBarFixture requireVisible()
          Asserts that this fixture's JToolBar is visible.
 JToolBarFixture rightClick()
          Simulates a user right-clicking this fixture's JToolBar.
 JPopupMenuFixture showPopupMenu()
          Shows a pop-up menu using this fixture's JToolBar 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 JToolBar as the invoker of the pop-up menu.
 JToolBarFixture unfloat()
          Simulates a user unfloating this fixture's JToolBar.
 JToolBarFixture unfloat(JToolBarFixture.UnfloatConstraint constraint)
          Simulates a user dropping this fixture's JToolBar to the requested constraint position.
 
Methods inherited from class org.fest.swing.fixture.ContainerFixture
button, button, button, checkBox, checkBox, checkBox, comboBox, comboBox, comboBox, dialog, dialog, dialog, dialog, dialog, dialog, fileChooser, fileChooser, fileChooser, fileChooser, fileChooser, fileChooser, find, findByName, findByType, finder, label, label, label, list, list, list, menuItem, menuItem, menuItemWithPath, optionPane, optionPane, panel, panel, panel, progressBar, progressBar, progressBar, radioButton, radioButton, radioButton, scrollBar, scrollBar, scrollBar, scrollPane, scrollPane, scrollPane, slider, slider, slider, spinner, spinner, spinner, splitPane, splitPane, splitPane, tabbedPane, tabbedPane, tabbedPane, table, table, table, textBox, textBox, textBox, toggleButton, toggleButton, toggleButton, toolBar, toolBar, toolBar, tree, tree, tree, with
 
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

JToolBarFixture

public JToolBarFixture(Robot robot,
                       JToolBar target)
Creates a new JToolBarFixture.

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

JToolBarFixture

public JToolBarFixture(Robot robot,
                       String toolbarName)
Creates a new JToolBarFixture.

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

driver

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

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

floatTo

public JToolBarFixture floatTo(Point point)
Simulates a user dragging this fixture's JToolBar to the given location, causing it to float.

Parameters:
point - the point where the JToolBar will be floating to.
Returns:
this fixture.
Throws:
ActionFailedException - if the JToolBar is not floatable.
ActionFailedException - if the JToolBar cannot be dragged.

unfloat

public JToolBarFixture unfloat()
Simulates a user unfloating this fixture's JToolBar.

Returns:
this fixture.
Throws:
ActionFailedException - if the dock container cannot be found.

unfloat

public JToolBarFixture unfloat(JToolBarFixture.UnfloatConstraint constraint)
Simulates a user dropping this fixture's JToolBar to the requested constraint position.

Parameters:
constraint - the constraint position.
Returns:
this fixture.
Throws:
ActionFailedException - if the dock container cannot be found.

click

public JToolBarFixture click()
Simulates a user clicking this fixture's JToolBar.

Specified by:
click in interface MouseInputSimulationFixture
Returns:
this fixture.

click

public JToolBarFixture click(MouseButton button)
Simulates a user clicking this fixture's JToolBar.

Specified by:
click in interface MouseInputSimulationFixture
Parameters:
button - the button to click.
Returns:
this fixture.

click

public JToolBarFixture click(MouseClickInfo mouseClickInfo)
Simulates a user clicking this fixture's JToolBar.

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.

doubleClick

public JToolBarFixture doubleClick()
Simulates a user double-clicking this fixture's JToolBar.

Specified by:
doubleClick in interface MouseInputSimulationFixture
Returns:
this fixture.

rightClick

public JToolBarFixture rightClick()
Simulates a user right-clicking this fixture's JToolBar.

Specified by:
rightClick in interface MouseInputSimulationFixture
Returns:
this fixture.

focus

public JToolBarFixture focus()
Gives input focus to this fixture's JToolBar.

Specified by:
focus in interface FocusableComponentFixture
Returns:
this fixture.

pressAndReleaseKey

public JToolBarFixture pressAndReleaseKey(KeyPressInfo keyPressInfo)
Simulates a user pressing given key with the given modifiers on this fixture's JToolBar. 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.
See Also:
KeyPressInfo

pressAndReleaseKeys

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

Specified by:
pressAndReleaseKeys in interface KeyboardInputSimulationFixture
Parameters:
keyCodes - the 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.
See Also:
KeyEvent

pressKey

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

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.
See Also:
KeyEvent

releaseKey

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

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.
See Also:
KeyEvent

requireFocused

public JToolBarFixture requireFocused()
Asserts that this fixture's JToolBar has input focus.

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

requireEnabled

public JToolBarFixture requireEnabled()
Asserts that this fixture's JToolBar is enabled.

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

requireEnabled

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

requireDisabled

public JToolBarFixture requireDisabled()
Asserts that this fixture's JToolBar is disabled.

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

requireVisible

public JToolBarFixture requireVisible()
Asserts that this fixture's JToolBar is visible.

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

requireNotVisible

public JToolBarFixture requireNotVisible()
Asserts that this fixture's JToolBar is not visible.

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

requireToolTip

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

requireToolTip

public JToolBarFixture requireToolTip(Pattern pattern)
Asserts that the toolTip in this fixture's JToolBar 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 JToolBar 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 JToolBarFixture, 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 JToolBar 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 JToolBar is disabled.
IllegalStateException - if this fixture's JToolBar 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 JToolBar 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 JToolBar is disabled.
IllegalStateException - if this fixture's JToolBar 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.