Package org.fest.swing.driver
Class JTabbedPaneDriver
java.lang.Object
org.fest.swing.driver.ComponentDriver
org.fest.swing.driver.ContainerDriver
org.fest.swing.driver.JComponentDriver
org.fest.swing.driver.JTabbedPaneDriver
Understands functional testing of
JTabbedPane
s:
- user input simulation
- state verification
- property value query
org.fest.swing.fixture
in your tests.-
Field Summary
FieldsFields inherited from class org.fest.swing.driver.ComponentDriver
robot
-
Constructor Summary
ConstructorsConstructorDescriptionJTabbedPaneDriver
(Robot robot) Creates a newJTabbedPaneDriver
.JTabbedPaneDriver
(Robot robot, JTabbedPaneLocation location) Creates a newJTabbedPaneDriver
. -
Method Summary
Modifier and TypeMethodDescriptionprivate static String[]
allTabTitlesIn
(JTabbedPane tabbedPane) private void
moveMouseToTab
(JTabbedPane tabbedPane, int index) private static Point
pointAtTab
(JTabbedPaneLocation location, JTabbedPane tabbedPane, int index) void
requireTabTitle
(JTabbedPane tabbedPane, String title, Index index) Asserts that the title of the tab at the given index matches the given value.void
requireTabTitle
(JTabbedPane tabbedPane, Pattern pattern, Index index) Asserts that the title of the tab at the given index matches the given regular expression pattern.void
requireTabTitles
(JTabbedPane tabbedPane, String[] titles) Asserts that the tabs of the given
have the given titles.JTabbedPane
private static Component
selectedComponent
(JTabbedPane tabbedPane) selectedComponentOf
(JTabbedPane tabbedPane) Returns the currently selected component for the given
.JTabbedPane
void
selectTab
(JTabbedPane tabbedPane, int index) Simulates a user selecting the tab located at the given index.void
selectTab
(JTabbedPane tabbedPane, String title) Simulates a user selecting the tab containing the given title.void
selectTab
(JTabbedPane tabbedPane, Pattern pattern) Simulates a user selecting the tab whose title matches the given regular expression pattern.private void
selectTab
(JTabbedPane tabbedPane, TextMatcher matcher) (package private) void
setTabDirectly
(JTabbedPane tabbedPane, int index) String[]
tabTitles
(JTabbedPane tabbedPane) Returns the titles of all the tabs.tabToSelectInfo
(JTabbedPaneLocation location, JTabbedPane tabbedPane, TextMatcher matcher) private static String
titleAt
(JTabbedPane tabbedPane, Index index) private org.fest.assertions.Description
titleAtProperty
(JTabbedPane tabbedPane) private static Point
validateAndGetPoint
(JTabbedPaneLocation location, JTabbedPane tabbedPane, int index) 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
-
Field Details
-
location
-
-
Constructor Details
-
JTabbedPaneDriver
Creates a newJTabbedPaneDriver
.- Parameters:
robot
- the robot to use to simulate user input.
-
JTabbedPaneDriver
JTabbedPaneDriver(Robot robot, JTabbedPaneLocation location) Creates a newJTabbedPaneDriver
.- Parameters:
robot
- the robot to use to simulate user input.location
- knows how to find the location of a tab.
-
-
Method Details
-
tabTitles
Returns the titles of all the tabs.- Parameters:
tabbedPane
- the targetJTabbedPane
.- Returns:
- the titles of all the tabs.
-
selectTab
Simulates a user selecting the tab containing the given title.- Parameters:
tabbedPane
- the targetJTabbedPane
.title
- the given text to match. It can be a regular expression.- Throws:
IllegalStateException
- if theJTabbedPane
is disabled.IllegalStateException
- if theJTabbedPane
is not showing on the screen.LocationUnavailableException
- if a tab matching the given title could not be found.
-
selectTab
Simulates a user selecting the tab whose title matches the given regular expression pattern.- Parameters:
tabbedPane
- the targetJTabbedPane
.pattern
- the regular expression pattern to match.- Throws:
IllegalStateException
- if theJTabbedPane
is disabled.IllegalStateException
- if theJTabbedPane
is not showing on the screen.NullPointerException
- if the given regular expression pattern isnull
.LocationUnavailableException
- if a tab matching the given regular expression pattern could not be found.- Since:
- 1.2
-
selectTab
-
tabToSelectInfo
@RunsInEDT private static Pair<Integer,Point> tabToSelectInfo(JTabbedPaneLocation location, JTabbedPane tabbedPane, TextMatcher matcher) -
selectTab
Simulates a user selecting the tab located at the given index.- Parameters:
tabbedPane
- the targetJTabbedPane
.index
- the index of the tab to select.- Throws:
IllegalStateException
- if theJTabbedPane
is disabled.IllegalStateException
- if theJTabbedPane
is not showing on the screen.IndexOutOfBoundsException
- if the given index is not within theJTabbedPane
bounds.
-
validateAndGetPoint
@RunsInEDT private static Point validateAndGetPoint(JTabbedPaneLocation location, JTabbedPane tabbedPane, int index) -
setTabDirectly
-
moveMouseToTab
-
pointAtTab
@RunsInEDT private static Point pointAtTab(JTabbedPaneLocation location, JTabbedPane tabbedPane, int index) -
selectedComponentOf
Returns the currently selected component for the given
.JTabbedPane
- Parameters:
tabbedPane
- the targetJTabbedPane
.- Returns:
- the currently selected component for the given
JTabbedPane
.
-
selectedComponent
-
requireTabTitle
Asserts that the title of the tab at the given index matches the given value.- Parameters:
tabbedPane
- the targetJTabbedPane
.title
- the expected title. It can be a regular expression.index
- the index of the tab.- Throws:
IndexOutOfBoundsException
- if the given index is not within theJTabbedPane
bounds.AssertionError
- if the title of the tab at the given index does not match the given one.
-
requireTabTitle
Asserts that the title of the tab at the given index matches the given regular expression pattern.- Parameters:
tabbedPane
- the targetJTabbedPane
.pattern
- the regular expression pattern to match.index
- the index of the tab.- Throws:
NullPointerException
- if the given regular expression pattern isnull
.IndexOutOfBoundsException
- if the given index is not within theJTabbedPane
bounds.AssertionError
- if the title of the tab at the given index does not match the given one.- Since:
- 1.2
-
titleAtProperty
-
titleAt
-
requireTabTitles
Asserts that the tabs of the given
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.JTabbedPane
- Parameters:
tabbedPane
- the targetJTabbedPane
.titles
- the expected titles.- Throws:
AssertionError
- if the title of any of the tabs is not equal to the expected titles.
-
allTabTitlesIn
-