Package org.fest.swing.driver
Class JFileChooserDriver
java.lang.Object
org.fest.swing.driver.ComponentDriver
org.fest.swing.driver.ContainerDriver
org.fest.swing.driver.JComponentDriver
org.fest.swing.driver.JFileChooserDriver
Understands functional testing of
JFileChoosers:
- 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapproveButton(JFileChooser fileChooser) Finds the "Approve" button in the given.JFileChoosercancelButton(JFileChooser fileChooser) Finds the "Cancel" button in the given.JFileChooserprivate ComponentLookupExceptioncannotFindButton(String name, String text) voidclickApproveButton(JFileChooser fileChooser) Finds and clicks the "Approve" button in the given.JFileChooservoidclickCancelButton(JFileChooser fileChooser) Finds and clicks the "Cancel" button in the given.JFileChooserfileNameTextBox(JFileChooser fileChooser) Returns the text field where the user can enter the name of the file to select.private JButtonfindButton(JFileChooser fileChooser, String logicalName, String text) voidselectFile(JFileChooser fileChooser, File file) Selects the given file in the.JFileChooservoidselectFiles(JFileChooser fileChooser, File[] files) Selects the given file in the.JFileChooservoidsetCurrentDirectory(JFileChooser fileChooser, File dir) Sets the current directory in theto the given one.JFileChooserMethods 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
-
APPROVE_BUTTON
- See Also:
-
CANCEL_BUTTON
- See Also:
-
-
Constructor Details
-
JFileChooserDriver
Creates a newJFileChooserDriver.- Parameters:
robot- the robot to use to simulate user input.
-
-
Method Details
-
selectFile
Selects the given file in the.JFileChooser- Parameters:
fileChooser- the targetJFileChooser.file- the file to select.- Throws:
NullPointerException- if the given file isnull.IllegalStateException- if theJFileChooseris disabled.IllegalStateException- if theJFileChooseris not showing on the screen.IllegalArgumentException- if theJFileChoosercan select directories only and the file to select is not a directory.IllegalArgumentException- if theJFileChoosercannot select directories and the file to select is a directory.
-
selectFiles
Selects the given file in the.JFileChooser- Parameters:
fileChooser- the targetJFileChooser.files- the files to select.- Throws:
NullPointerException- if the given array of files isnull.IllegalArgumentException- if the given array of files is empty.IllegalStateException- if this fixture'sJFileChooseris disabled.IllegalStateException- if this fixture'sJFileChooseris not showing on the screen.IllegalStateException- if this fixture'sJFileChooserdoes not support multiple selection and there is more than one file to select.IllegalArgumentException- if this fixture'sJFileChoosercan select directories only and any of the files to select is not a directory.IllegalArgumentException- if this fixture'sJFileChoosercannot select directories and any of the files to select is a directory.
-
setCurrentDirectory
Sets the current directory in theto the given one.JFileChooser- Parameters:
fileChooser- the targetJFileChooser.dir- the directory to set as current.- Throws:
IllegalStateException- if theJFileChooseris disabled.IllegalStateException- if theJFileChooseris not showing on the screen.
-
fileNameTextBox
Returns the text field where the user can enter the name of the file to select.- Parameters:
fileChooser- the targetJFileChooser.- Returns:
- the found text field.
- Throws:
ComponentLookupException- if a matching text field could not be found.
-
clickCancelButton
Finds and clicks the "Cancel" button in the given.JFileChooser- Parameters:
fileChooser- the targetJFileChooser.- Throws:
ComponentLookupException- if the "Cancel" button cannot be found.IllegalStateException- if the "Cancel" button is disabled.IllegalStateException- if the "Cancel" button is not showing on the screen.
-
cancelButton
Finds the "Cancel" button in the given.JFileChooser- Parameters:
fileChooser- the targetJFileChooser.- Returns:
- the found "Cancel" button.
- Throws:
ComponentLookupException- if the "Cancel" button cannot be found.
-
clickApproveButton
Finds and clicks the "Approve" button in the given.JFileChooser- Parameters:
fileChooser- the targetJFileChooser.- Throws:
ComponentLookupException- if the "Approve" button cannot be found.IllegalStateException- if the "Approve" button is disabled.IllegalStateException- if the "Approve" button is not showing on the screen.
-
approveButton
Finds the "Approve" button in the given.JFileChooser- Parameters:
fileChooser- the targetJFileChooser.- Returns:
- the found "Approve" button.
- Throws:
ComponentLookupException- if the "Approve" button cannot be found.
-
findButton
-
cannotFindButton
-