org.fest.swing.fixture
Class JPanelFixture

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

public class JPanelFixture
extends ContainerFixture<JPanel>
implements CommonComponentFixture, JComponentFixture, JPopupMenuInvokerFixture

Understands functional testing of JPanels:

Author:
Alex Ruiz, Yvonne Wang

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
JPanelFixture(Robot robot, JPanel target)
          Creates a new JPanelFixture.
JPanelFixture(Robot robot, String panelName)
          Creates a new JPanelFixture.
 
Method Summary
 JPanelFixture click()
          Simulates a user clicking this fixture's JPanel.
 JPanelFixture click(MouseButton button)
          Simulates a user clicking this fixture's JPanel.
 JPanelFixture click(MouseClickInfo mouseClickInfo)
          Simulates a user clicking this fixture's JPanel.
 Object clientProperty(Object key)
          Returns the client property stored in this fixture's JPanel, under the given key.
 JPanelFixture doubleClick()
          Simulates a user double-clicking this fixture's JPanel.
protected  void driver(JComponentDriver newDriver)
          Sets the JComponentDriver to be used by this fixture.
 JPanelFixture focus()
          Gives input focus to this fixture's JPanel.
 JPanelFixture pressAndReleaseKey(KeyPressInfo keyPressInfo)
          Simulates a user pressing given key with the given modifiers on this fixture's JPanel.
 JPanelFixture pressAndReleaseKeys(int... keyCodes)
          Simulates a user pressing and releasing the given keys on the JPanel managed by this fixture.
 JPanelFixture pressKey(int keyCode)
          Simulates a user pressing the given key on this fixture's JPanel.
 JPanelFixture releaseKey(int keyCode)
          Simulates a user releasing the given key on this fixture's JPanel.
 JPanelFixture requireDisabled()
          Asserts that this fixture's JPanel is disabled.
 JPanelFixture requireEnabled()
          Asserts that this fixture's JPanel is enabled.
 JPanelFixture requireEnabled(Timeout timeout)
          Asserts that this fixture's JPanel is enabled.
 JPanelFixture requireFocused()
          Asserts that this fixture's JPanel has input focus.
 JPanelFixture requireNotVisible()
          Asserts that this fixture's JPanel is not visible.
 JPanelFixture requireToolTip(Pattern pattern)
          Asserts that the toolTip in this fixture's JPanel matches the given regular expression pattern.
 JPanelFixture requireToolTip(String expected)
          Asserts that the toolTip in this fixture's JPanel matches the given value.
 JPanelFixture requireVisible()
          Asserts that this fixture's JPanel is visible.
 JPanelFixture rightClick()
          Simulates a user right-clicking this fixture's JPanel.
 JPopupMenuFixture showPopupMenu()
          Shows a pop-up menu using this fixture's JPanel 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 JPanel as the invoker of the pop-up menu.
 
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

JPanelFixture

public JPanelFixture(Robot robot,
                     String panelName)
Creates a new JPanelFixture.

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

JPanelFixture

public JPanelFixture(Robot robot,
                     JPanel target)
Creates a new JPanelFixture.

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

driver

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

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

click

public JPanelFixture click()
Simulates a user clicking this fixture's JPanel.

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

click

public JPanelFixture click(MouseButton button)
Simulates a user clicking this fixture's JPanel.

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

click

public JPanelFixture click(MouseClickInfo mouseClickInfo)
Simulates a user clicking this fixture's JPanel.

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.

rightClick

public JPanelFixture rightClick()
Simulates a user right-clicking this fixture's JPanel.

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

doubleClick

public JPanelFixture doubleClick()
Simulates a user double-clicking this fixture's JPanel.

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

focus

public JPanelFixture focus()
Gives input focus to this fixture's JPanel.

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

pressAndReleaseKey

public JPanelFixture pressAndReleaseKey(KeyPressInfo keyPressInfo)
Simulates a user pressing given key with the given modifiers on this fixture's JPanel. 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 JPanelFixture pressAndReleaseKeys(int... keyCodes)
Simulates a user pressing and releasing the given keys on the JPanel managed by this fixture.

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

pressKey

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

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 JPanelFixture releaseKey(int keyCode)
Simulates a user releasing the given key on this fixture's JPanel.

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 JPanelFixture requireFocused()
Asserts that this fixture's JPanel has input focus.

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

requireEnabled

public JPanelFixture requireEnabled()
Asserts that this fixture's JPanel is enabled.

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

requireEnabled

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

requireDisabled

public JPanelFixture requireDisabled()
Asserts that this fixture's JPanel is disabled.

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

requireVisible

public JPanelFixture requireVisible()
Asserts that this fixture's JPanel is visible.

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

requireNotVisible

public JPanelFixture requireNotVisible()
Asserts that this fixture's JPanel is not visible.

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

requireToolTip

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

requireToolTip

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