/** * Return a reference to a JTabbedPaneOperator within the given father * component * * @param mainFrame * - The Father of the tab * @param tabName * - The tab title * @return a reference to a JTabbedPaneOperator * @throws Exception */ public JTabbedPaneOperator getJTableFromTab(JDialogOperator mainFrame, String tabName) throws Exception { JTabbedPaneOperator tabbedPaneOperator = new JTabbedPaneOperator( mainFrame, 0); tabbedPaneOperator.selectPage(tabName); return tabbedPaneOperator; }
private Component selectTabPage(String tabIdentifier) { return createTabPane().selectPage(indexOfTab(tabIdentifier)); }
@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 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 }
@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())); }