Package org.fest.swing.driver
Class JOptionPaneDriver
java.lang.Object
org.fest.swing.driver.ComponentDriver
org.fest.swing.driver.ContainerDriver
org.fest.swing.driver.JComponentDriver
org.fest.swing.driver.JOptionPaneDriver
Understands functional testing of
JOptionPane
s:
- user input simulation
- state verification
- property value query
org.fest.swing.fixture
in your tests.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private static final String
private static final String
private static final String
Fields inherited from class org.fest.swing.driver.ComponentDriver
robot
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate String
actualMessageTypeAsText
(JOptionPane optionPane) private void
assertEqualMessageType
(JOptionPane optionPane, int expected) button
(JOptionPane optionPane) Deprecated.in 1.2buttonWithText
(JOptionPane optionPane, String text) Finds a button in the
containing the given text.JOptionPane
buttonWithText
(JOptionPane optionPane, Pattern pattern) Finds a button in the
whose text matches the given regular expression pattern.JOptionPane
private JButton
buttonWithTextFromUIManager
(JOptionPane optionPane, String key) cancelButton
(JOptionPane optionPane) Finds the "Cancel" button in the
.JOptionPane
private org.fest.assertions.Description
messageProperty
(JOptionPane optionPane) noButton
(JOptionPane optionPane) Finds the "No" button in the
.JOptionPane
okButton
(JOptionPane optionPane) Finds the "OK" button in the
.JOptionPane
void
requireErrorMessage
(JOptionPane optionPane) Asserts that the
is displaying an error message.JOptionPane
void
requireInformationMessage
(JOptionPane optionPane) Asserts that the
is displaying an information message.JOptionPane
void
requireMessage
(JOptionPane optionPane, Object message) Asserts that the title of the
matches the given value.JOptionPane
private void
requireMessage
(JOptionPane optionPane, String expected, String actual) void
requireMessage
(JOptionPane optionPane, Pattern pattern) Asserts that the title of the
matches the given regular expression pattern.JOptionPane
void
requireOptions
(JOptionPane optionPane, Object[] options) Asserts that the
has the given options.JOptionPane
void
requirePlainMessage
(JOptionPane optionPane) Asserts that the
is displaying a plain message.JOptionPane
void
requireQuestionMessage
(JOptionPane optionPane) Asserts that the
is displaying a question.JOptionPane
void
requireTitle
(JOptionPane optionPane, String title) Asserts that the title in the given
matches the given value.JOptionPane
void
requireTitle
(JOptionPane optionPane, Pattern pattern) Asserts that the title in the given
matches the given regular expression pattern.JOptionPane
void
requireWarningMessage
(JOptionPane optionPane) Asserts that the
is displaying a warning message.JOptionPane
textBox
(JOptionPane optionPane) Deprecated.in 1.2title
(JOptionPane optionPane) Returns the title of the given
.JOptionPane
private String
toStringOf
(Object o) yesButton
(JOptionPane optionPane) Finds the "Yes" button in the
.JOptionPane
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
-
MESSAGE_PROPERTY
- See Also:
-
MESSAGE_TYPE_PROPERTY
- See Also:
-
OPTIONS_PROPERTY
- See Also:
-
TITLE_PROPERTY
- See Also:
-
-
Constructor Details
-
JOptionPaneDriver
Creates a newJOptionPaneDriver
.- Parameters:
robot
- the robot to use to simulate user input.
-
-
Method Details
-
requireTitle
Asserts that the title in the given
matches the given value.JOptionPane
- Parameters:
optionPane
- the targetJOptionPane
.title
- the title to match. It can be a regular expression.- Throws:
AssertionError
- if theJOptionPane
does not have the given title.
-
requireTitle
Asserts that the title in the given
matches the given regular expression pattern.JOptionPane
- Parameters:
optionPane
- the targetJOptionPane
.pattern
- the regular expression pattern to match.- Throws:
NullPointerException
- if the given regular expression pattern isnull
.AssertionError
- if theJOptionPane
does not have the given title.- Since:
- 1.2
-
title
Returns the title of the given
.JOptionPane
- Parameters:
optionPane
- the targetJOptionPane
.- Returns:
- the title of the given
JOptionPane
. - Since:
- 1.2
-
requireMessage
Asserts that the title of the
matches the given value. If the given value is a regular expression and the message in theJOptionPane
JOptionPane
is not aString
, this method will use thetoString
representation of such message. message in theJOptionPane
is not aString
, this method will use thetoString
representation of such message.- Parameters:
optionPane
- the targetJOptionPane
.message
- the message to verify. If it is aString
, it can be specified as a regular expression.- Throws:
AssertionError
- if the message in theJOptionPane
is not equal to or does not match the given message.
-
requireMessage
-
requireMessage
Asserts that the title of the
matches the given regular expression pattern. If the message in theJOptionPane
JOptionPane
is not aString
, this method will use thetoString
representation of such message.- Parameters:
optionPane
- the targetJOptionPane
.pattern
- the regular expression to match.- Throws:
NullPointerException
- if the given regular expression pattern isnull
.AssertionError
- if the message in the JOptionPaneFixture does not match the given regular expression pattern.- Since:
- 1.2
-
toStringOf
-
messageProperty
-
requireOptions
Asserts that the
has the given options.JOptionPane
- Parameters:
optionPane
- the targetJOptionPane
.options
- the options to verify.- Throws:
AssertionError
- if theJOptionPane
does not have the given options.
-
okButton
Finds the "OK" button in the
. This method is independent of locale and platform.JOptionPane
- Parameters:
optionPane
- the targetJOptionPane
.- Returns:
- the "OK" button.
- Throws:
ComponentLookupException
- if the a "OK" button cannot be found.
-
cancelButton
Finds the "Cancel" button in the
. This method is independent of locale and platform.JOptionPane
- Parameters:
optionPane
- the targetJOptionPane
.- Returns:
- the "Cancel" button.
- Throws:
ComponentLookupException
- if the a "Cancel" button cannot be found.
-
yesButton
Finds the "Yes" button in the
. This method is independent of locale and platform.JOptionPane
- Parameters:
optionPane
- the targetJOptionPane
.- Returns:
- the "Yes" button.
- Throws:
ComponentLookupException
- if the a "Yes" button cannot be found.
-
noButton
Finds the "No" button in the
. This method is independent of locale and platform.JOptionPane
- Parameters:
optionPane
- the targetJOptionPane
.- Returns:
- the "No" button.
- Throws:
ComponentLookupException
- if the a "No" button cannot be found.
-
buttonWithTextFromUIManager
-
buttonWithText
Finds a button in the
containing the given text.JOptionPane
- Parameters:
optionPane
- the targetJOptionPane
.text
- the text of the button to find and return. It can be a regular expression.- Returns:
- a button containing the given text.
- Throws:
ComponentLookupException
- if the a button with the given text cannot be found.
-
buttonWithText
Finds a button in the
whose text matches the given regular expression pattern.JOptionPane
- Parameters:
optionPane
- the targetJOptionPane
.pattern
- the regular expression pattern to match.- Returns:
- a button containing the given text.
- Throws:
NullPointerException
- if the given regular expression pattern isnull
.ComponentLookupException
- if the a button with the given text cannot be found.- Since:
- 1.2
-
button
Deprecated.in 1.2Finds a
in theJButton
(assuming it has only one button.)JOptionPane
- Parameters:
optionPane
- the targetJOptionPane
.- Returns:
- the only
JButton
contained in theJOptionPane
. - Throws:
ComponentLookupException
- if a matching component could not be found.ComponentLookupException
- if more than one matching component is found.
-
textBox
Deprecated.in 1.2Returns the
in the given message only if the message is of type input.JTextComponent
- Parameters:
optionPane
- the targetJOptionPane
.- Returns:
- the text component in the given message.
- Throws:
ComponentLookupException
- if the message type is not input and therefore it does not contain a text component.
-
requireErrorMessage
Asserts that the
is displaying an error message.JOptionPane
- Parameters:
optionPane
- the targetJOptionPane
.
-
requireInformationMessage
Asserts that the
is displaying an information message.JOptionPane
- Parameters:
optionPane
- the targetJOptionPane
.
-
requireWarningMessage
Asserts that the
is displaying a warning message.JOptionPane
- Parameters:
optionPane
- the targetJOptionPane
.
-
requireQuestionMessage
Asserts that the
is displaying a question.JOptionPane
- Parameters:
optionPane
- the targetJOptionPane
.
-
requirePlainMessage
Asserts that the
is displaying a plain message.JOptionPane
- Parameters:
optionPane
- the targetJOptionPane
.
-
assertEqualMessageType
-
actualMessageTypeAsText
-