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
JOptionPanes:
- user input simulation
- state verification
- property value query
org.fest.swing.fixture in your tests.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final Stringprivate static final Stringprivate static final StringFields inherited from class org.fest.swing.driver.ComponentDriver
robot -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate StringactualMessageTypeAsText(JOptionPane optionPane) private voidassertEqualMessageType(JOptionPane optionPane, int expected) button(JOptionPane optionPane) Deprecated.in 1.2buttonWithText(JOptionPane optionPane, String text) Finds a button in thecontaining the given text.JOptionPanebuttonWithText(JOptionPane optionPane, Pattern pattern) Finds a button in thewhose text matches the given regular expression pattern.JOptionPaneprivate JButtonbuttonWithTextFromUIManager(JOptionPane optionPane, String key) cancelButton(JOptionPane optionPane) Finds the "Cancel" button in the.JOptionPaneprivate org.fest.assertions.DescriptionmessageProperty(JOptionPane optionPane) noButton(JOptionPane optionPane) Finds the "No" button in the.JOptionPaneokButton(JOptionPane optionPane) Finds the "OK" button in the.JOptionPanevoidrequireErrorMessage(JOptionPane optionPane) Asserts that theis displaying an error message.JOptionPanevoidrequireInformationMessage(JOptionPane optionPane) Asserts that theis displaying an information message.JOptionPanevoidrequireMessage(JOptionPane optionPane, Object message) Asserts that the title of thematches the given value.JOptionPaneprivate voidrequireMessage(JOptionPane optionPane, String expected, String actual) voidrequireMessage(JOptionPane optionPane, Pattern pattern) Asserts that the title of thematches the given regular expression pattern.JOptionPanevoidrequireOptions(JOptionPane optionPane, Object[] options) Asserts that thehas the given options.JOptionPanevoidrequirePlainMessage(JOptionPane optionPane) Asserts that theis displaying a plain message.JOptionPanevoidrequireQuestionMessage(JOptionPane optionPane) Asserts that theis displaying a question.JOptionPanevoidrequireTitle(JOptionPane optionPane, String title) Asserts that the title in the givenmatches the given value.JOptionPanevoidrequireTitle(JOptionPane optionPane, Pattern pattern) Asserts that the title in the givenmatches the given regular expression pattern.JOptionPanevoidrequireWarningMessage(JOptionPane optionPane) Asserts that theis displaying a warning message.JOptionPanetextBox(JOptionPane optionPane) Deprecated.in 1.2title(JOptionPane optionPane) Returns the title of the given.JOptionPaneprivate StringtoStringOf(Object o) yesButton(JOptionPane optionPane) Finds the "Yes" button in the.JOptionPaneMethods inherited from class org.fest.swing.driver.JComponentDriver
clientProperty, invokeAction, isVisible, isVisible, requireToolTip, requireToolTip, scrollToVisibleMethods inherited from class org.fest.swing.driver.ContainerDriver
move, resize, resizeHeight, resizeWidthMethods 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 givenmatches the given value.JOptionPane- Parameters:
optionPane- the targetJOptionPane.title- the title to match. It can be a regular expression.- Throws:
AssertionError- if theJOptionPanedoes not have the given title.
-
requireTitle
Asserts that the title in the givenmatches 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 theJOptionPanedoes 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 thematches the given value. If the given value is a regular expression and the message in theJOptionPaneJOptionPaneis not aString, this method will use thetoStringrepresentation of such message. message in theJOptionPaneis not aString, this method will use thetoStringrepresentation 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 theJOptionPaneis not equal to or does not match the given message.
-
requireMessage
-
requireMessage
Asserts that the title of thematches the given regular expression pattern. If the message in theJOptionPaneJOptionPaneis not aString, this method will use thetoStringrepresentation 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 thehas the given options.JOptionPane- Parameters:
optionPane- the targetJOptionPane.options- the options to verify.- Throws:
AssertionError- if theJOptionPanedoes 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 thecontaining 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 thewhose 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 ain theJButton(assuming it has only one button.)JOptionPane- Parameters:
optionPane- the targetJOptionPane.- Returns:
- the only
JButtoncontained 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 thein 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 theis displaying an error message.JOptionPane- Parameters:
optionPane- the targetJOptionPane.
-
requireInformationMessage
Asserts that theis displaying an information message.JOptionPane- Parameters:
optionPane- the targetJOptionPane.
-
requireWarningMessage
Asserts that theis displaying a warning message.JOptionPane- Parameters:
optionPane- the targetJOptionPane.
-
requireQuestionMessage
Asserts that theis displaying a question.JOptionPane- Parameters:
optionPane- the targetJOptionPane.
-
requirePlainMessage
Asserts that theis displaying a plain message.JOptionPane- Parameters:
optionPane- the targetJOptionPane.
-
assertEqualMessageType
-
actualMessageTypeAsText
-