org.fest.swing.fixture
Class JTabbedPaneFixture

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

public class JTabbedPaneFixture
extends ComponentFixture<JTabbedPane>
implements CommonComponentFixture, JComponentFixture, JPopupMenuInvokerFixture

Understands functional testing of JTabbedPanes:

Author:
Alex Ruiz, Yvonne Wang

Field Summary
 
Fields inherited from class org.fest.swing.fixture.ComponentFixture
BACKGROUND_PROPERTY, FONT_PROPERTY, FOREGROUND_PROPERTY, robot, target
 
Constructor Summary
JTabbedPaneFixture(Robot robot, JTabbedPane target)
          Creates a new JTabbedPaneFixture.
JTabbedPaneFixture(Robot robot, String tabbedPaneName)
          Creates a new JTabbedPaneFixture.
 
Method Summary
 JTabbedPaneFixture click()
          Simulates a user clicking this fixture's JTabbedPane.
 JTabbedPaneFixture click(MouseButton button)
          Simulates a user clicking this fixture's JTabbedPane.
 JTabbedPaneFixture click(MouseClickInfo mouseClickInfo)
          Simulates a user clicking this fixture's JTabbedPane.
 Object clientProperty(Object key)
          Returns the client property stored in this fixture's JTabbedPane, under the given key.
 JTabbedPaneFixture doubleClick()
          Simulates a user double-clicking this fixture's JTabbedPane.
protected  void driver(JTabbedPaneDriver newDriver)
          Sets the JTabbedPaneDriver to be used by this fixture.
 JTabbedPaneFixture focus()
          Gives input focus to this fixture's JTabbedPane.
 JTabbedPaneFixture pressAndReleaseKey(KeyPressInfo keyPressInfo)
          Simulates a user pressing given key with the given modifiers on this fixture's JTabbedPane.
 JTabbedPaneFixture pressAndReleaseKeys(int... keyCodes)
          Simulates a user pressing and releasing the given keys on this fixture's JTabbedPane.
 JTabbedPaneFixture pressKey(int keyCode)
          Simulates a user pressing the given key on this fixture's JTabbedPane.
 JTabbedPaneFixture releaseKey(int keyCode)
          Simulates a user releasing the given key on this fixture's JTabbedPane.
 JTabbedPaneFixture requireDisabled()
          Asserts that this fixture's JTabbedPane is disabled.
 JTabbedPaneFixture requireEnabled()
          Asserts that this fixture's JTabbedPane is enabled.
 JTabbedPaneFixture requireEnabled(Timeout timeout)
          Asserts that this fixture's JTabbedPane is enabled.
 JTabbedPaneFixture requireFocused()
          Asserts that this fixture's JTabbedPane has input focus.
 JTabbedPaneFixture requireNotVisible()
          Asserts that this fixture's JTabbedPane is not visible.
 JTabbedPaneFixture requireTabTitles(String... titles)
          Asserts that the tabs of this fixture's JTabbedPane have the given titles.
 JTabbedPaneFixture requireTitle(Pattern pattern, Index index)
          Asserts that the title of the tab at the given index matches the given regular expression pattern.
 JTabbedPaneFixture requireTitle(String title, Index index)
          Asserts that the title of the tab at the given index matches the given value.
 JTabbedPaneFixture requireToolTip(Pattern pattern)
          Asserts that the toolTip in this fixture's JTabbedPane matches the given regular expression pattern.
 JTabbedPaneFixture requireToolTip(String expected)
          Asserts that the toolTip in this fixture's JTabbedPane matches the given value.
 JTabbedPaneFixture requireVisible()
          Asserts that this fixture's JTabbedPane is visible.
 JTabbedPaneFixture rightClick()
          Simulates a user right-clicking this fixture's JTabbedPane.
 Component selectedComponent()
          Returns the currently selected component for this fixture's JTabbedPane.
 JTabbedPaneFixture selectTab(int index)
          Simulates a user selecting the tab located at the given index.
 JTabbedPaneFixture selectTab(Pattern pattern)
          Simulates a user selecting the tab whose title matches the given regular expression pattern.
 JTabbedPaneFixture selectTab(String title)
          Simulates a user selecting the tab whose title matches the given value.
 JPopupMenuFixture showPopupMenu()
          Shows a pop-up menu using this fixture's JTabbedPane 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 JTabbedPane as the invoker of the pop-up menu.
 String[] tabTitles()
          Returns the titles of all the tabs in this fixture's JTabbedPane.
 
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

JTabbedPaneFixture

public JTabbedPaneFixture(Robot robot,
                          JTabbedPane target)
Creates a new JTabbedPaneFixture.

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

JTabbedPaneFixture

public JTabbedPaneFixture(Robot robot,
                          String tabbedPaneName)
Creates a new JTabbedPaneFixture.

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

driver

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

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

tabTitles

public String[] tabTitles()
Returns the titles of all the tabs in this fixture's JTabbedPane.

Returns:
the titles of all the tabs.

selectTab

public JTabbedPaneFixture selectTab(int index)
Simulates a user selecting the tab located at the given index.

Parameters:
index - the index of the tab to select.
Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JTabbedPane is disabled.
IllegalStateException - if this fixture's JTabbedPane is not showing on the screen.
IndexOutOfBoundsException - if the given index is not within the JTabbedPane bounds.

selectTab

public JTabbedPaneFixture selectTab(String title)
Simulates a user selecting the tab whose title matches the given value.

Parameters:
title - the title to match. It can be a regular expression.
Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JTabbedPane is disabled.
IllegalStateException - if this fixture's JTabbedPane is not showing on the screen.
LocationUnavailableException - if a tab matching the given title could not be found.

selectTab

public JTabbedPaneFixture selectTab(Pattern pattern)
Simulates a user selecting the tab whose title matches the given regular expression pattern.

Parameters:
pattern - the regular expression pattern to match.
Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JTabbedPane is disabled.
IllegalStateException - if this fixture's JTabbedPane is not showing on the screen.
NullPointerException - if the given regular expression pattern is null.
LocationUnavailableException - if a tab matching the given regular expression pattern could not be found.
Since:
1.2

selectedComponent

public Component selectedComponent()
Returns the currently selected component for this fixture's JTabbedPane.

Returns:
the currently selected component for this fixture's JTabbedPane.

click

public JTabbedPaneFixture click()
Simulates a user clicking this fixture's JTabbedPane.

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

click

public JTabbedPaneFixture click(MouseButton button)
Simulates a user clicking this fixture's JTabbedPane.

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

click

public JTabbedPaneFixture click(MouseClickInfo mouseClickInfo)
Simulates a user clicking this fixture's JTabbedPane.

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

doubleClick

public JTabbedPaneFixture doubleClick()
Simulates a user double-clicking this fixture's JTabbedPane.

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

rightClick

public JTabbedPaneFixture rightClick()
Simulates a user right-clicking this fixture's JTabbedPane.

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

focus

public JTabbedPaneFixture focus()
Gives input focus to this fixture's JTabbedPane.

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

pressAndReleaseKey

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

pressAndReleaseKeys

public JTabbedPaneFixture pressAndReleaseKeys(int... keyCodes)
Simulates a user pressing and releasing the given keys on this fixture's JTabbedPane. 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 JTabbedPane is disabled.
IllegalStateException - if this fixture's JTabbedPane is not showing on the screen.
See Also:
KeyEvent

pressKey

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

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

releaseKey

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

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

requireFocused

public JTabbedPaneFixture requireFocused()
Asserts that this fixture's JTabbedPane has input focus.

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

requireEnabled

public JTabbedPaneFixture requireEnabled()
Asserts that this fixture's JTabbedPane is enabled.

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

requireEnabled

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

requireDisabled

public JTabbedPaneFixture requireDisabled()
Asserts that this fixture's JTabbedPane is disabled.

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

requireVisible

public JTabbedPaneFixture requireVisible()
Asserts that this fixture's JTabbedPane is visible.

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

requireNotVisible

public JTabbedPaneFixture requireNotVisible()
Asserts that this fixture's JTabbedPane is not visible.

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

requireTitle

public JTabbedPaneFixture requireTitle(String title,
                                       Index index)
Asserts that the title of the tab at the given index matches the given value.

Parameters:
title - the expected title. It can be a regular expression.
index - the index of the tab.
Returns:
this fixture.
Throws:
IndexOutOfBoundsException - if the given index is not within the JTabbedPane bounds.
AssertionError - if the title of the tab at the given index does not match the given one.

requireTitle

public JTabbedPaneFixture requireTitle(Pattern pattern,
                                       Index index)
Asserts that the title of the tab at the given index matches the given regular expression pattern.

Parameters:
pattern - the regular expression pattern to match.
index - the index of the tab.
Returns:
this fixture.
Throws:
NullPointerException - if the given regular expression pattern is null.
AssertionError - if the title of the tab at the given index does not match the given regular expression pattern.

requireTabTitles

public JTabbedPaneFixture requireTabTitles(String... titles)
Asserts that the tabs of this fixture's JTabbedPane have the given titles. The tab titles are evaluated by index order, for example, the first tab is expected to have the first title in the given array, and so on.

Parameters:
titles - the expected titles.
Returns:
this fixture.
Throws:
AssertionError - if the title of any of the tabs is not equal to the expected titles.

requireToolTip

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

requireToolTip

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