org.fest.swing.driver
Class JFileChooserDriver

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.JFileChooserDriver

public class JFileChooserDriver
extends JComponentDriver

Understands functional testing of JFileChoosers:

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

Author:
Yvonne Wang, Alex Ruiz

Field Summary
 
Fields inherited from class org.fest.swing.driver.ComponentDriver
robot
 
Constructor Summary
JFileChooserDriver(Robot robot)
          Creates a new JFileChooserDriver.
 
Method Summary
 JButton approveButton(JFileChooser fileChooser)
          Finds the "Approve" button in the given JFileChooser.
 JButton cancelButton(JFileChooser fileChooser)
          Finds the "Cancel" button in the given JFileChooser.
 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.
 JTextField fileNameTextBox(JFileChooser fileChooser)
          Returns the text field where the user can enter the name of the file to select.
 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 JFileChooser to the given one.
 
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

JFileChooserDriver

public JFileChooserDriver(Robot robot)
Creates a new JFileChooserDriver.

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

selectFile

@RunsInEDT
public void selectFile(JFileChooser fileChooser,
                                 File file)
Selects the given file in the JFileChooser.

Parameters:
fileChooser - the target JFileChooser.
file - the file to select.
Throws:
NullPointerException - if the given file is null.
IllegalStateException - if the JFileChooser is disabled.
IllegalStateException - if the JFileChooser is not showing on the screen.
IllegalArgumentException - if the JFileChooser can select directories only and the file to select is not a directory.
IllegalArgumentException - if the JFileChooser cannot select directories and the file to select is a directory.

selectFiles

public void selectFiles(JFileChooser fileChooser,
                        File[] files)
Selects the given file in the JFileChooser.

Parameters:
fileChooser - the target JFileChooser.
files - the files to select.
Throws:
NullPointerException - if the given array of files is null.
IllegalArgumentException - if the given array of files is empty.
IllegalStateException - if this fixture's JFileChooser is disabled.
IllegalStateException - if this fixture's JFileChooser is not showing on the screen.
IllegalStateException - if this fixture's JFileChooser does not support multiple selection and there is more than one file to select.
IllegalArgumentException - if this fixture's JFileChooser can select directories only and any of the files to select is not a directory.
IllegalArgumentException - if this fixture's JFileChooser cannot select directories and any of the files to select is a directory.

setCurrentDirectory

@RunsInEDT
public void setCurrentDirectory(JFileChooser fileChooser,
                                          File dir)
Sets the current directory in the JFileChooser to the given one.

Parameters:
fileChooser - the target JFileChooser.
dir - the directory to set as current.
Throws:
IllegalStateException - if the JFileChooser is disabled.
IllegalStateException - if the JFileChooser is not showing on the screen.

fileNameTextBox

@RunsInEDT
public JTextField fileNameTextBox(JFileChooser fileChooser)
Returns the text field where the user can enter the name of the file to select.

Parameters:
fileChooser - the target JFileChooser.
Returns:
the found text field.
Throws:
ComponentLookupException - if a matching text field could not be found.

clickCancelButton

@RunsInEDT
public void clickCancelButton(JFileChooser fileChooser)
Finds and clicks the "Cancel" button in the given JFileChooser.

Parameters:
fileChooser - the target JFileChooser.
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

@RunsInEDT
public JButton cancelButton(JFileChooser fileChooser)
Finds the "Cancel" button in the given JFileChooser.

Parameters:
fileChooser - the target JFileChooser.
Returns:
the found "Cancel" button.
Throws:
ComponentLookupException - if the "Cancel" button cannot be found.

clickApproveButton

@RunsInEDT
public void clickApproveButton(JFileChooser fileChooser)
Finds and clicks the "Approve" button in the given JFileChooser.

Parameters:
fileChooser - the target JFileChooser.
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

@RunsInEDT
public JButton approveButton(JFileChooser fileChooser)
Finds the "Approve" button in the given JFileChooser.

Parameters:
fileChooser - the target JFileChooser.
Returns:
the found "Approve" button.
Throws:
ComponentLookupException - if the "Approve" button cannot be found.


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