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"); } }
public void shouldThrowErrorIfFilesToSelectIsNull() { try { driver.selectFiles(fileChooser, null); failWhenExpectingException(); } catch (NullPointerException e) { assertThat(e.getMessage()).isEqualTo("The files to select should not be null"); } }
public void shouldThrowErrorWhenSelectingFilesInNotShowingJFileChooser() { hideWindow(); try { driver.selectFiles(fileChooser, array(new File("Fake"))); failWhenExpectingException(); } catch (IllegalStateException e) { assertActionFailureDueToNotShowingComponent(e); } }
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"); } }
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"); } }
public void shouldNotThrowErrorIfJFileChooserCannotHandleMultipleSelectionAndArrayOfFilesToSelectHasOneElementOnly() { disableMultipleSelection(); File temporaryFile = newTemporaryFile(); try { driver.selectFiles(fileChooser, array(temporaryFile)); File[] selectedFiles = selectedFilesIn(fileChooser); assertThat(selectedFiles).containsOnly(temporaryFile); } finally { temporaryFile.delete(); } }
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(); } }
public void shouldThrowErrorIfJFileChooserCanOnlySelectFilesAndOneOfFilesToSelectIsFolder() { enableMultipleSelection(); File temporaryFolder = newTemporaryFolder(); File temporaryFile = newTemporaryFile(); setFileChooserToSelectFilesOny(); try { driver.selectFiles(fileChooser, array(temporaryFolder, temporaryFile)); failWhenExpectingException(); } catch (IllegalArgumentException e) { assertThat(e.getMessage()).contains("the file chooser cannot open directories"); } finally { temporaryFolder.delete(); temporaryFile.delete(); } }