コード例 #1
0
 public void shouldThrowErrorIfFilesToSelectIsEmpty() {
   try {
     driver.selectFiles(fileChooser, new File[0]);
     failWhenExpectingException();
   } catch (IllegalArgumentException e) {
     assertThat(e.getMessage()).isEqualTo("The array of files to select should not be empty");
   }
 }
コード例 #2
0
 public void shouldThrowErrorIfFilesToSelectIsNull() {
   try {
     driver.selectFiles(fileChooser, null);
     failWhenExpectingException();
   } catch (NullPointerException e) {
     assertThat(e.getMessage()).isEqualTo("The files to select should not be null");
   }
 }
コード例 #3
0
 public void shouldThrowErrorWhenSettingCurrentDirectoryInNotShowingJFileChooser() {
   hideWindow();
   try {
     driver.setCurrentDirectory(fileChooser, userHomeDirectory());
     failWhenExpectingException();
   } catch (IllegalStateException e) {
     assertActionFailureDueToNotShowingComponent(e);
   }
 }
コード例 #4
0
 public void shouldThrowErrorWhenSettingCurrentDirectoryInDisabledJFileChooser() {
   disableFileChooser();
   try {
     driver.setCurrentDirectory(fileChooser, userHomeDirectory());
     failWhenExpectingException();
   } catch (IllegalStateException e) {
     assertActionFailureDueToDisabledComponent(e);
   }
 }
コード例 #5
0
 public void shouldThrowErrorWhenSelectingFilesInNotShowingJFileChooser() {
   hideWindow();
   try {
     driver.selectFiles(fileChooser, array(new File("Fake")));
     failWhenExpectingException();
   } catch (IllegalStateException e) {
     assertActionFailureDueToNotShowingComponent(e);
   }
 }
コード例 #6
0
 public void shouldThrowErrorIfAnyFileToSelectIsNull() {
   try {
     driver.selectFiles(fileChooser, array(new File("Fake"), null));
     failWhenExpectingException();
   } catch (NullPointerException e) {
     assertThat(e.getMessage())
         .isEqualTo("The array of files to select should not contain null elements");
   }
 }
コード例 #7
0
 public void shouldThrowErrorWhenSelectingFilesAndJFileChooserCannotHandleMultipleSelection() {
   disableMultipleSelection();
   try {
     driver.selectFiles(fileChooser, array(new File("Fake1"), new File("Fake2")));
     failWhenExpectingException();
   } catch (IllegalStateException e) {
     assertThat(e.getMessage())
         .contains("Expecting file chooser")
         .contains("to handle multiple selection");
   }
 }
コード例 #8
0
 public void shouldThrowErrorIfJFileChooserCanOnlySelectFilesAndFileToSelectIsFolder() {
   File temporaryFolder = newTemporaryFolder();
   setFileChooserToSelectFilesOny();
   try {
     driver.selectFile(fileChooser, temporaryFolder);
     failWhenExpectingException();
   } catch (IllegalArgumentException e) {
     assertThat(e.getMessage()).contains("the file chooser cannot open directories");
   } finally {
     temporaryFolder.delete();
   }
 }
コード例 #9
0
 public void shouldThrowErrorWhenSelectingFileInDisabledJFileChooser() {
   File temporaryFile = newTemporaryFile();
   disableFileChooser();
   try {
     driver.selectFile(fileChooser, temporaryFile);
     failWhenExpectingException();
   } catch (IllegalStateException e) {
     assertActionFailureDueToDisabledComponent(e);
   } finally {
     temporaryFile.delete();
   }
 }
コード例 #10
0
 public void shouldThrowErrorIfJFileChooserCanOnlySelectFoldersAndOneOfFilesToSelectIsFile() {
   enableMultipleSelection();
   File temporaryFolder = newTemporaryFolder();
   File temporaryFile = newTemporaryFile();
   setFileChooserToSelectDirectoriesOnly();
   try {
     driver.selectFiles(fileChooser, array(temporaryFolder, temporaryFile));
     failWhenExpectingException();
   } catch (IllegalArgumentException e) {
     assertThat(e.getMessage()).contains("the file chooser can only open directories");
   } finally {
     temporaryFile.delete();
     temporaryFile.delete();
   }
 }