@Test public void JunitTest() { JFrameOperator mainFrame = new JFrameOperator(); JTextFieldOperator textField = new JTextFieldOperator(mainFrame, "textIn"); int x = 10; assertEquals(x, textField.getLocationOnScreen().x); }
@Test public void testGetAncestorWindow() throws InterruptedException { assertNull(instance.getAncestorWindow()); JFrameOperator frame = showFrameWith(instance); Window window1 = instance.getAncestorWindow(); assertSame(frame.getSource(), window1); frame.dispose(); frame = showFrameWith(instance); // change enclosing frame Window window2 = instance.getAncestorWindow(); assertSame(frame.getSource(), window2); frame.dispose(); assertNotSame(window1, window2); }
@After public void tearDown() throws Exception { frame.dispose(); }
@Test @SuppressWarnings("ResultOfObjectAllocationIgnored") public void testExtraDataUI() { final JComponent ui = new KeyStrengthPanel<AesKeyStrength>(AesKeyStrength.values()); panel.setExtraDataUI(ui); frame.pack(); assertSame(ui, panel.getExtraDataUI()); new JComboBoxOperator(frame); // find combo box } }
@After public void tearDown() { frame.dispose(); }
JFrameOperator mf = new JFrameOperator("Main Frame"); JDialogOperator jd = new JDialogOperator(mf, ""); // dialog that contains JProgressBar has no name JProgressBar pb = JProgressBarOperator.findJProgressBar(jd.getContentPane());
@After public void tearDown() { frame.dispose(); }
@Test public void testSomething() throws Exception { //GIVEN ClassReference cr = new ClassReference("components.TableFilterDemo"); cr.startApplication(); frame = new JFrameOperator("TableFilterDemo"); //WHEN //doing more steps //THEN //do TestNG assertions }
@Test public void testGUI() throws InterruptedException { final JFrameOperator frame = showFrameWith(new FileComboBoxPanel(null)); final JTextComponentOperator tc0 = new JTextComponentOperator(frame, 0); final JTextComponentOperator tc1 = new JTextComponentOperator(frame, 1); // Type a character in tc0, then check that it's appearing in tc1. tc0.typeText("?"); tc0.getQueueTool().waitEmpty(); assertEquals("?", tc1.getText()); // Clear character in tc1, then ensure that its cleared in tc0, too. tc1.clearText(); tc1.getQueueTool().waitEmpty(); assertEquals("", tc0.getText()); // Select first element in list of tc0 (entry in current directory), // if any, and check its appearance in tc1, too. tc0.pressKey(KeyEvent.VK_DOWN); tc0.getQueueTool().waitEmpty(); final String child = tc0.getText(); assertEquals(child, tc1.getText()); frame.dispose(); } }
/** * Displays a new {@link JFrame} with the given {@code component} and * returns an operator for it. * * @param component the component to display in the new frame. * @return An operator for the new frame which shows the given component. */ public static JFrameOperator showFrameWith(final Component component) throws InterruptedException { class Show implements Runnable { JFrame frame; @Override public void run() { frame = new JFrame(); frame.add(component); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } } // Show final Show show = new Show(); runOnEdtNow(show); return new JFrameOperator(show.frame); }
new ClassReference("org.netbeans.jemmy.explorer.GUIBrowser") .startApplication(); JFrameOperator mainFrame = new JFrameOperator("GUI Browser"); new JButtonOperator(mainFrame, "Reload In").push(); new JLabelOperator(mainFrame, "Reloaded"); JTreeOperator tree = new JTreeOperator(mainFrame); //click in the middle of the tree tree.clickMouse(); //collapse node tree.collapsePath(tree.findPath("", "|")); //expand node tree.expandPath(tree.findPath("", "|")); //select node tree.selectPath(tree.findPath("GUI Browser", "|")); JTextFieldOperator testField = new JTextFieldOperator(mainFrame); //type new value in the text field testField.clearText(); testField.typeText("3");
JFrameOperator mainFrame = new JFrameOperator(windowName); JCheckBoxOperator jc = new JCheckBoxOperator(mainFrame, checkBoxName);
throws Exception { JFrameOperator mainFrame = new JFrameOperator(mainWindow); JButtonOperator btn = new JButtonOperator(mainFrame, new TipNameButtonFinder(buttonName));