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
JFileChooser
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapproveButton
(JFileChooser fileChooser) Finds the "Approve" button in the given
.JFileChooser
cancelButton
(JFileChooser fileChooser) Finds the "Cancel" button in the given
.JFileChooser
private ComponentLookupException
cannotFindButton
(String name, String text) void
clickApproveButton
(JFileChooser fileChooser) Finds and clicks the "Approve" button in the given
.JFileChooser
void
clickCancelButton
(JFileChooser fileChooser) Finds and clicks the "Cancel" button in the given
.JFileChooser
fileNameTextBox
(JFileChooser fileChooser) Returns the text field where the user can enter the name of the file to select.private JButton
findButton
(JFileChooser fileChooser, String logicalName, String text) void
selectFile
(JFileChooser fileChooser, File file) Selects the given file in the
.JFileChooser
void
selectFiles
(JFileChooser fileChooser, File[] files) Selects the given file in the
.JFileChooser
void
setCurrentDirectory
(JFileChooser fileChooser, File dir) Sets the current directory in the
to the given one.JFileChooser
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
-
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 theJFileChooser
is disabled.IllegalStateException
- if theJFileChooser
is not showing on the screen.IllegalArgumentException
- if theJFileChooser
can select directories only and the file to select is not a directory.IllegalArgumentException
- if theJFileChooser
cannot 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'sJFileChooser
is disabled.IllegalStateException
- if this fixture'sJFileChooser
is not showing on the screen.IllegalStateException
- if this fixture'sJFileChooser
does not support multiple selection and there is more than one file to select.IllegalArgumentException
- if this fixture'sJFileChooser
can select directories only and any of the files to select is not a directory.IllegalArgumentException
- if this fixture'sJFileChooser
cannot select directories and any of the files to select is a directory.
-
setCurrentDirectory
Sets the current directory in the
to the given one.JFileChooser
- Parameters:
fileChooser
- the targetJFileChooser
.dir
- the directory to set as current.- Throws:
IllegalStateException
- if theJFileChooser
is disabled.IllegalStateException
- if theJFileChooser
is 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
-