コード例 #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 shouldThrowErrorWhenSelectingFilesInNotShowingJFileChooser() {
   hideWindow();
   try {
     driver.selectFiles(fileChooser, array(new File("Fake")));
     failWhenExpectingException();
   } catch (IllegalStateException e) {
     assertActionFailureDueToNotShowingComponent(e);
   }
 }
コード例 #5
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");
   }
 }
コード例 #6
0
 public void shouldThrowErrorWhenSettingCurrentDirectoryInDisabledJFileChooser() {
   disableFileChooser();
   try {
     driver.setCurrentDirectory(fileChooser, userHomeDirectory());
     failWhenExpectingException();
   } catch (IllegalStateException e) {
     assertActionFailureDueToDisabledComponent(e);
   }
 }
コード例 #7
0
 public void shouldSelectFile() {
   File temporaryFile = newTemporaryFile();
   try {
     driver.selectFile(fileChooser, temporaryFile);
     File selectedFile = selectedFileIn(fileChooser);
     assertThat(selectedFile).isSameAs(temporaryFile);
   } finally {
     temporaryFile.delete();
   }
 }
コード例 #8
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");
   }
 }
コード例 #9
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();
   }
 }
コード例 #10
0
 public void
     shouldNotThrowErrorIfJFileChooserCannotHandleMultipleSelectionAndArrayOfFilesToSelectHasOneElementOnly() {
   disableMultipleSelection();
   File temporaryFile = newTemporaryFile();
   try {
     driver.selectFiles(fileChooser, array(temporaryFile));
     File[] selectedFiles = selectedFilesIn(fileChooser);
     assertThat(selectedFiles).containsOnly(temporaryFile);
   } finally {
     temporaryFile.delete();
   }
 }
コード例 #11
0
 public void shouldThrowErrorWhenSelectingFileInDisabledJFileChooser() {
   File temporaryFile = newTemporaryFile();
   disableFileChooser();
   try {
     driver.selectFile(fileChooser, temporaryFile);
     failWhenExpectingException();
   } catch (IllegalStateException e) {
     assertActionFailureDueToDisabledComponent(e);
   } finally {
     temporaryFile.delete();
   }
 }
コード例 #12
0
 public void shouldSelectFiles() {
   enableMultipleSelection();
   setFileChooserToSelectFilesAndDirectories();
   File temporaryFolder = newTemporaryFolder();
   File temporaryFile = newTemporaryFile();
   try {
     driver.selectFiles(fileChooser, array(temporaryFolder, temporaryFile));
     File[] selectedFiles = selectedFilesIn(fileChooser);
     assertThat(selectedFiles).containsOnly(temporaryFolder, temporaryFile);
   } finally {
     temporaryFolder.delete();
     temporaryFile.delete();
   }
 }
コード例 #13
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();
   }
 }
コード例 #14
0
 public void shouldFindCancelButton() {
   JButton cancelButton = driver.cancelButton(fileChooser);
   assertThat(cancelButton).isNotNull();
   assertThat(textOf(cancelButton)).isEqualTo(cancelButtonText());
 }
コード例 #15
0
 public void shouldSetCurrentDirectory() {
   File userHome = userHomeDirectory();
   driver.setCurrentDirectory(fileChooser, userHome);
   assertThat(currentDirectoryAbsolutePath(fileChooser)).isEqualTo(userHome.getAbsolutePath());
 }
コード例 #16
0
 public void shouldFindFileNameTextBox() {
   JTextField fileNameTextBox = driver.fileNameTextBox(fileChooser);
   assertThat(fileNameTextBox).isNotNull();
 }
コード例 #17
0
 public void shouldFindApproveButton() {
   JButton approveButton = driver.approveButton(fileChooser);
   assertThat(approveButton).isNotNull();
   assertThat(textOf(approveButton)).isEqualTo(approveButtonText(fileChooser));
 }