org.fest.swing.driver
Class JOptionPaneDriver

java.lang.Object
  extended by org.fest.swing.driver.ComponentDriver
      extended by org.fest.swing.driver.ContainerDriver
          extended by org.fest.swing.driver.JComponentDriver
              extended by org.fest.swing.driver.JOptionPaneDriver

public class JOptionPaneDriver
extends JComponentDriver

Understands functional testing of JOptionPanes:

This class is intended for internal use only. Please use the classes in the package org.fest.swing.fixture in your tests.

Author:
Alex Ruiz

Field Summary
 
Fields inherited from class org.fest.swing.driver.ComponentDriver
robot
 
Constructor Summary
JOptionPaneDriver(Robot robot)
          Creates a new JOptionPaneDriver.
 
Method Summary
 JButton button(JOptionPane optionPane)
          Deprecated. in 1.2
 JButton buttonWithText(JOptionPane optionPane, Pattern pattern)
          Finds a button in the JOptionPane whose text matches the given regular expression pattern.
 JButton buttonWithText(JOptionPane optionPane, String text)
          Finds a button in the JOptionPane containing the given text.
 JButton cancelButton(JOptionPane optionPane)
          Finds the "Cancel" button in the JOptionPane.
 JButton noButton(JOptionPane optionPane)
          Finds the "No" button in the JOptionPane.
 JButton okButton(JOptionPane optionPane)
          Finds the "OK" button in the JOptionPane.
 void requireErrorMessage(JOptionPane optionPane)
          Asserts that the JOptionPane is displaying an error message.
 void requireInformationMessage(JOptionPane optionPane)
          Asserts that the JOptionPane is displaying an information message.
 void requireMessage(JOptionPane optionPane, Object message)
          Asserts that the title of the JOptionPane matches the given value.
 void requireMessage(JOptionPane optionPane, Pattern pattern)
          Asserts that the title of the JOptionPane matches the given regular expression pattern.
 void requireOptions(JOptionPane optionPane, Object[] options)
          Asserts that the JOptionPane has the given options.
 void requirePlainMessage(JOptionPane optionPane)
          Asserts that the JOptionPane is displaying a plain message.
 void requireQuestionMessage(JOptionPane optionPane)
          Asserts that the JOptionPane is displaying a question.
 void requireTitle(JOptionPane optionPane, Pattern pattern)
          Asserts that the title in the given JOptionPane matches the given regular expression pattern.
 void requireTitle(JOptionPane optionPane, String title)
          Asserts that the title in the given JOptionPane matches the given value.
 void requireWarningMessage(JOptionPane optionPane)
          Asserts that the JOptionPane is displaying a warning message.
 JTextComponent textBox(JOptionPane optionPane)
          Deprecated. in 1.2
 String title(JOptionPane optionPane)
          Returns the title of the given JOptionPane.
 JButton 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JOptionPaneDriver

public JOptionPaneDriver(Robot robot)
Creates a new JOptionPaneDriver.

Parameters:
robot - the robot to use to simulate user input.
Method Detail

requireTitle

@RunsInEDT
public void requireTitle(JOptionPane optionPane,
                                   String title)
Asserts that the title in the given JOptionPane matches the given value.

Parameters:
optionPane - the target JOptionPane.
title - the title to match. It can be a regular expression.
Throws:
AssertionError - if the JOptionPane does not have the given title.

requireTitle

@RunsInEDT
public void requireTitle(JOptionPane optionPane,
                                   Pattern pattern)
Asserts that the title in the given JOptionPane matches the given regular expression pattern.

Parameters:
optionPane - the target JOptionPane.
pattern - the regular expression pattern to match.
Throws:
NullPointerException - if the given regular expression pattern is null.
AssertionError - if the JOptionPane does not have the given title.
Since:
1.2

title

@RunsInEDT
public String title(JOptionPane optionPane)
Returns the title of the given JOptionPane.

Parameters:
optionPane - the target JOptionPane.
Returns:
the title of the given JOptionPane.
Since:
1.2

requireMessage

@RunsInEDT
public void requireMessage(JOptionPane optionPane,
                                     Object message)
Asserts that the title of the JOptionPane matches the given value. If the given value is a regular expression and the message in the JOptionPane is not a String, this method will use the toString representation of such message. message in the JOptionPane is not a String, this method will use the toString representation of such message.

Parameters:
optionPane - the target JOptionPane.
message - the message to verify. If it is a String, it can be specified as a regular expression.
Throws:
AssertionError - if the message in the JOptionPane is not equal to or does not match the given message.

requireMessage

@RunsInEDT
public void requireMessage(JOptionPane optionPane,
                                     Pattern pattern)
Asserts that the title of the JOptionPane matches the given regular expression pattern. If the message in the JOptionPane is not a String, this method will use the toString representation of such message.

Parameters:
optionPane - the target JOptionPane.
pattern - the regular expression to match.
Throws:
NullPointerException - if the given regular expression pattern is null.
AssertionError - if the message in the JOptionPaneFixture does not match the given regular expression pattern.
Since:
1.2

requireOptions

@RunsInEDT
public void requireOptions(JOptionPane optionPane,
                                     Object[] options)
Asserts that the JOptionPane has the given options.

Parameters:
optionPane - the target JOptionPane.
options - the options to verify.
Throws:
AssertionError - if the JOptionPane does not have the given options.

okButton

@RunsInEDT
public JButton okButton(JOptionPane optionPane)
Finds the "OK" button in the JOptionPane. This method is independent of locale and platform.

Parameters:
optionPane - the target JOptionPane.
Returns:
the "OK" button.
Throws:
ComponentLookupException - if the a "OK" button cannot be found.

cancelButton

@RunsInEDT
public JButton cancelButton(JOptionPane optionPane)
Finds the "Cancel" button in the JOptionPane. This method is independent of locale and platform.

Parameters:
optionPane - the target JOptionPane.
Returns:
the "Cancel" button.
Throws:
ComponentLookupException - if the a "Cancel" button cannot be found.

yesButton

@RunsInEDT
public JButton yesButton(JOptionPane optionPane)
Finds the "Yes" button in the JOptionPane. This method is independent of locale and platform.

Parameters:
optionPane - the target JOptionPane.
Returns:
the "Yes" button.
Throws:
ComponentLookupException - if the a "Yes" button cannot be found.

noButton

@RunsInEDT
public JButton noButton(JOptionPane optionPane)
Finds the "No" button in the JOptionPane. This method is independent of locale and platform.

Parameters:
optionPane - the target JOptionPane.
Returns:
the "No" button.
Throws:
ComponentLookupException - if the a "No" button cannot be found.

buttonWithText

@RunsInEDT
public JButton buttonWithText(JOptionPane optionPane,
                                        String text)
Finds a button in the JOptionPane containing the given text.

Parameters:
optionPane - the target JOptionPane.
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

@RunsInEDT
public JButton buttonWithText(JOptionPane optionPane,
                                        Pattern pattern)
Finds a button in the JOptionPane whose text matches the given regular expression pattern.

Parameters:
optionPane - the target JOptionPane.
pattern - the regular expression pattern to match.
Returns:
a button containing the given text.
Throws:
NullPointerException - if the given regular expression pattern is null.
ComponentLookupException - if the a button with the given text cannot be found.
Since:
1.2

button

@RunsInEDT
@Deprecated
public JButton button(JOptionPane optionPane)
Deprecated. in 1.2

Finds a JButton in the JOptionPane (assuming it has only one button.)

Parameters:
optionPane - the target JOptionPane.
Returns:
the only JButton contained in the JOptionPane.
Throws:
ComponentLookupException - if a matching component could not be found.
ComponentLookupException - if more than one matching component is found.

textBox

@RunsInEDT
@Deprecated
public JTextComponent textBox(JOptionPane optionPane)
Deprecated. in 1.2

Returns the JTextComponent in the given message only if the message is of type input.

Parameters:
optionPane - the target JOptionPane.
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

@RunsInEDT
public void requireErrorMessage(JOptionPane optionPane)
Asserts that the JOptionPane is displaying an error message.

Parameters:
optionPane - the target JOptionPane.

requireInformationMessage

@RunsInEDT
public void requireInformationMessage(JOptionPane optionPane)
Asserts that the JOptionPane is displaying an information message.

Parameters:
optionPane - the target JOptionPane.

requireWarningMessage

@RunsInEDT
public void requireWarningMessage(JOptionPane optionPane)
Asserts that the JOptionPane is displaying a warning message.

Parameters:
optionPane - the target JOptionPane.

requireQuestionMessage

@RunsInEDT
public void requireQuestionMessage(JOptionPane optionPane)
Asserts that the JOptionPane is displaying a question.

Parameters:
optionPane - the target JOptionPane.

requirePlainMessage

@RunsInEDT
public void requirePlainMessage(JOptionPane optionPane)
Asserts that the JOptionPane is displaying a plain message.

Parameters:
optionPane - the target JOptionPane.


Copyright © 2007-2011 FEST (Fixtures for Easy Software Testing). All Rights Reserved.