@RobotKeyword("Chooses from a filechooser by pushing the approve button.\n" + "An optional file name can be provided, which is inserted to the file name textfield.\n" + "Expects the file chooser to be open.\n\n" + "Example:\n" + "| `Push Button` | Open File |\n" + "| `Choose From File Chooser` | /tmp/elements.xml |\n") @ArgumentNames({"fileName="}) public void chooseFromFileChooser(String fileName) { if (!"".equals(fileName)) { fileChooserOperator().chooseFile(fileName); } else { fileChooserOperator().approve(); } }
public JFileChooserOperator createFileChooserOperator() { return new JFileChooserOperator(); } }
@RobotKeyword("Cancels and closes file chooser.\n" + "Expects the file chooser to be open.\n\n" + "Example:\n" + "| `Push Button` | Open File |\n" + "| `Cancel File Chooser` | |\n") public void cancelFileChooser() { fileChooserOperator().cancelSelection(); }
@Test public void testKeyFile() throws InterruptedException { final SafePbeParameters<?, ?> param = newPbeParameters(); new JTabbedPaneOperator(frame).selectPage(AuthenticationPanel.AUTH_KEY_FILE); // select tab for key files new JButtonOperator(frame, KEY_FILE_CHOOSER).push(); // open file chooser JFileChooserOperator fc = new TFileChooserOperator(frame); fc.chooseFile(NON_EXISTING_FILE); fc.getQueueTool().waitEmpty(WAIT_EMPTY); assertTrue(isBlank(error.getText())); assertFalse(updateParam(param)); assertFalse(isBlank(error.getText())); new JButtonOperator(frame, KEY_FILE_CHOOSER).push(); // open file chooser fc = new TFileChooserOperator(frame); final List<File> files = Arrays.asList(fc.getFiles()); Collections.shuffle(files); for (final File file : files) { if (!file.isFile()) continue; fc.setSelectedFile(file); fc.approve(); // close file chooser if (updateParam(param)) { assertNotNull(param.getPassword()); assertTrue(isBlank(error.getText())); } else { assertFalse(isBlank(error.getText())); } return; } fc.cancel(); // close file chooser }
@SuppressWarnings("ResultOfObjectAllocationIgnored") @Test public void testTabbedPane() { final ComponentChooser keyFileChooser = new NameComponentChooser("keyFileChooser"); new JTabbedPaneOperator(frame).selectPage(AuthenticationPanel.AUTH_KEY_FILE); // select tab for key files new JButtonOperator(frame, keyFileChooser).push(); // open file chooser JFileChooserOperator fc = new TFileChooserOperator(frame); fc.cancel(); new JTabbedPaneOperator(frame).selectPage(AuthenticationPanel.AUTH_PASSWD); // select tab for passwords new JLabelOperator(frame, LABEL_TEXT); fc = null; new JTabbedPaneOperator(frame).selectPage(AuthenticationPanel.AUTH_KEY_FILE); // select tab for key files new JButtonOperator(frame, keyFileChooser).push(); // open file chooser fc = new TFileChooserOperator(frame); final File file = new File("test"); fc.setSelectedFile(file); fc.approve(); fc.getQueueTool().waitEmpty(WAIT_EMPTY); JTextFieldOperator tf = new JTextFieldOperator(frame); assertEquals(file.getPath(), tf.getText()); fc = null; new JTabbedPaneOperator(frame).selectPage(AuthenticationPanel.AUTH_PASSWD); // select tab for passwords new JLabelOperator(frame, LABEL_TEXT); } }
@Test public void testUpdateErrorLabel() { panel.setError("This is a test error message!"); assertFalse(isBlank(error.getText())); final JTextFieldOperator tf = new JTextFieldOperator(frame); tf.setText("secret"); //tf.getQueueTool().waitEmpty(WAIT_EMPTY); assertTrue(isBlank(error.getText())); panel.setError("This is a test error message!"); assertFalse(isBlank(error.getText())); new JTabbedPaneOperator(frame).selectPage(AuthenticationPanel.AUTH_KEY_FILE); // select tab for key files new JButtonOperator(frame, KEY_FILE_CHOOSER).push(); // open file chooser final JFileChooserOperator fc = new TFileChooserOperator(frame); fc.chooseFile(NON_EXISTING_FILE); fc.getQueueTool().waitEmpty(WAIT_EMPTY); assertTrue(isBlank(error.getText())); }
TFileChooserOperator(final WindowOperator parent) { super((JFileChooser) waitComponent( waitJFileChooserDialog(parent), new JFileChooserFinder(), 0, parent.getTimeouts(), parent.getOutput())); super.copyEnvironment(parent); }