--- old/test/ProblemList.txt 2016-05-24 10:48:05.000000000 -0700 +++ new/test/ProblemList.txt 2016-05-24 10:48:05.000000000 -0700 @@ -306,6 +306,8 @@ # jdk_swing +sanity/client/SwingSet/src/ButtonDemoScreenshotTest.java 8157338 generic-all + ############################################################################ # jdk_text --- old/test/sanity/client/SwingSet/src/ButtonDemoScreenshotTest.java 2016-05-24 10:48:06.000000000 -0700 +++ new/test/sanity/client/SwingSet/src/ButtonDemoScreenshotTest.java 2016-05-24 10:48:06.000000000 -0700 @@ -38,7 +38,7 @@ /* * @test - * @key headful screenshots + * @key headful screenshots intermittent * @summary Verifies buttons on SwingSet3 ButtonDemo page by clicking each * button, taking its screenshots and checking that pressed button * image is different from initial button image. @@ -46,6 +46,8 @@ * @library /sanity/client/lib/jemmy/src * @library /sanity/client/lib/Extensions/src * @library /sanity/client/lib/SwingSet3/src + * @modules java.desktop + * java.logging * @build org.jemmy2ext.JemmyExt * @build com.sun.swingset3.demos.button.ButtonDemo * @run testng ButtonDemoScreenshotTest --- old/test/sanity/client/SwingSet/src/ButtonDemoTest.java 2016-05-24 10:48:07.000000000 -0700 +++ new/test/sanity/client/SwingSet/src/ButtonDemoTest.java 2016-05-24 10:48:07.000000000 -0700 @@ -51,6 +51,8 @@ * @library /sanity/client/lib/jemmy/src * @library /sanity/client/lib/Extensions/src * @library /sanity/client/lib/SwingSet3/src + * @modules java.desktop + * java.logging * @build org.jemmy2ext.JemmyExt * @build com.sun.swingset3.demos.button.ButtonDemo * @run testng ButtonDemoTest --- old/test/sanity/client/SwingSet/src/ComboBoxDemoTest.java 2016-05-24 10:48:08.000000000 -0700 +++ new/test/sanity/client/SwingSet/src/ComboBoxDemoTest.java 2016-05-24 10:48:07.000000000 -0700 @@ -40,6 +40,8 @@ * @library /sanity/client/lib/jemmy/src * @library /sanity/client/lib/Extensions/src * @library /sanity/client/lib/SwingSet3/src + * @modules java.desktop + * java.logging * @build org.jemmy2ext.JemmyExt * @build com.sun.swingset3.demos.combobox.ComboBoxDemo * @run testng ComboBoxDemoTest @@ -76,7 +78,7 @@ JComboBoxOperator jcbo = new JComboBoxOperator(jfo, comboBoxInfo.ordinal()); for (int i = 0; i < jcbo.getItemCount(); i++) { jcbo.selectItem(i); - assertEquals(comboBoxInfo.comboBoxName + " ComboBox SelectedIndex is correct", i, jcbo.getSelectedIndex()); + jcbo.waitItemSelected(i); } } --- old/test/sanity/client/SwingSet/src/ListDemoTest.java 2016-05-24 10:48:08.000000000 -0700 +++ new/test/sanity/client/SwingSet/src/ListDemoTest.java 2016-05-24 10:48:08.000000000 -0700 @@ -21,17 +21,25 @@ * questions. */ -import org.jtregext.GuiTestListener; import com.sun.swingset3.demos.list.ListDemo; import static com.sun.swingset3.demos.list.ListDemo.DEMO_TITLE; -import static org.testng.AssertJUnit.*; -import org.testng.annotations.Test; -import static org.jemmy2ext.JemmyExt.getLabeledContainerOperator; + +import java.awt.Component; +import javax.swing.JList; + import org.netbeans.jemmy.ClassReference; +import org.netbeans.jemmy.ComponentChooser; import org.netbeans.jemmy.operators.JCheckBoxOperator; import org.netbeans.jemmy.operators.JFrameOperator; import org.netbeans.jemmy.operators.JListOperator; + +import static org.jemmy2ext.JemmyExt.*; + +import org.jtregext.GuiTestListener; + import org.testng.annotations.Listeners; +import org.testng.annotations.Test; +import static org.testng.AssertJUnit.*; /* * @test @@ -43,6 +51,8 @@ * @library /sanity/client/lib/jemmy/src * @library /sanity/client/lib/Extensions/src * @library /sanity/client/lib/SwingSet3/src + * @modules java.desktop + * java.logging * @build org.jemmy2ext.JemmyExt * @build com.sun.swingset3.demos.list.ListDemo * @run testng ListDemoTest @@ -52,6 +62,17 @@ private static final int CHECKBOX_COUNT = 50; + private void waitModelSize(JListOperator listOp, int size) { + listOp.waitState(new ComponentChooser() { + public boolean checkComponent(Component comp) { + return getUIValue(listOp, (JList list) -> list.getModel().getSize()) == size; + } + public String getDescription() { + return "Model size to be equal to " + size; + } + }); + } + @Test public void test() throws Exception { @@ -65,16 +86,14 @@ JCheckBoxOperator checkBox = getJCheckBoxOperator(frame, i); checkBox.changeSelection(false); } - System.out.println("######## Number of Items = " + listOp.getModel().getSize()); - assertEquals("Select None number of items is correct", 0, listOp.getModel().getSize()); + waitModelSize(listOp, 0); // Check *ALL* Prefix and Suffixes Marked for (int i = 0; i < CHECKBOX_COUNT; i++) { JCheckBoxOperator checkBox = getJCheckBoxOperator(frame, i); checkBox.changeSelection(true); } - System.out.println("######## Number of Items = " + listOp.getModel().getSize()); - assertEquals("Select All number of items is correct", CHECKBOX_COUNT / 2 * CHECKBOX_COUNT / 2, listOp.getModel().getSize()); + waitModelSize(listOp, CHECKBOX_COUNT * CHECKBOX_COUNT / 4); // Check *ALL* Prefix and *NO* Suffixes Marked for (int i = 0; i < CHECKBOX_COUNT; i++) { @@ -85,8 +104,7 @@ checkBox.changeSelection(false); } } - System.out.println("######## Number of Items = " + listOp.getModel().getSize()); - assertEquals("Select All Prefixes and NO Suffixes number of items is correct", 0, listOp.getModel().getSize()); + waitModelSize(listOp, 0); // Check *NO* Prefix and *ALL* Suffixes Marked for (int i = 0; i < CHECKBOX_COUNT; i++) { @@ -97,8 +115,7 @@ checkBox.changeSelection(true); } } - System.out.println("######## Number of Items = " + listOp.getModel().getSize()); - assertEquals("Select NO Prefixes and All Suffixes number of items is correct", 0, listOp.getModel().getSize()); + waitModelSize(listOp, 0); } private JCheckBoxOperator getJCheckBoxOperator(JFrameOperator frame, int index) { @@ -115,7 +132,9 @@ subindex = index - CHECKBOX_COUNT / 2; } - return new JCheckBoxOperator(getLabeledContainerOperator(frame, labelText), subindex); + JCheckBoxOperator result = new JCheckBoxOperator(getLabeledContainerOperator(frame, labelText), subindex); + result.setVerification(true); + return result; } } --- old/test/sanity/client/SwingSet/src/OptionPaneDemoTest.java 2016-05-24 10:48:09.000000000 -0700 +++ new/test/sanity/client/SwingSet/src/OptionPaneDemoTest.java 2016-05-24 10:48:09.000000000 -0700 @@ -21,20 +21,25 @@ * questions. */ -import org.jtregext.GuiTestListener; import com.sun.swingset3.demos.optionpane.OptionPaneDemo; import static com.sun.swingset3.demos.optionpane.OptionPaneDemo.*; + import javax.swing.UIManager; -import static org.testng.AssertJUnit.*; -import org.testng.annotations.Test; + +import org.jtregext.GuiTestListener; + import org.netbeans.jemmy.ClassReference; +import org.netbeans.jemmy.operators.Operator.DefaultStringComparator; import org.netbeans.jemmy.operators.JButtonOperator; import org.netbeans.jemmy.operators.JComboBoxOperator; import org.netbeans.jemmy.operators.JDialogOperator; import org.netbeans.jemmy.operators.JFrameOperator; import org.netbeans.jemmy.operators.JLabelOperator; import org.netbeans.jemmy.operators.JTextFieldOperator; + import org.testng.annotations.Listeners; +import org.testng.annotations.Test; +import static org.testng.AssertJUnit.*; /* @@ -46,6 +51,8 @@ * @library /sanity/client/lib/jemmy/src * @library /sanity/client/lib/Extensions/src * @library /sanity/client/lib/SwingSet3/src + * @modules java.desktop + * java.logging * @build org.jemmy2ext.JemmyExt * @build com.sun.swingset3.demos.optionpane.OptionPaneDemo * @run testng OptionPaneDemoTest @@ -77,70 +84,44 @@ showConfirmationDialog(frame); } - public void showInputDialog(JFrameOperator jfo) throws Exception { - // Cancel with text case - { - new JButtonOperator(jfo, INPUT_BUTTON).pushNoBlock(); + private void checkMessage(String message) { + JDialogOperator jdo = new JDialogOperator(MESSAGE); + new JLabelOperator(jdo, message); + new JButtonOperator(jdo, OK).push(); + jdo.waitClosed(); + } - JDialogOperator jdo = new JDialogOperator(INPUT); + private void useInputDialog(JFrameOperator jfo, String textToType, String buttonToPush) { + new JButtonOperator(jfo, INPUT_BUTTON).pushNoBlock(); + JDialogOperator jdo = new JDialogOperator(INPUT); + if(textToType != null) { JTextFieldOperator jto = new JTextFieldOperator(jdo); - jto.setText(SOME_TEXT_TO_TYPE); - - assertTrue("Show Input Dialog cancel w/ Text", jdo.isShowing()); - - new JButtonOperator(jdo, CANCEL).push(); - - assertFalse("Show Input Dialog cancel w/ Text", jdo.isShowing()); + jto.typeText(textToType); + jto.waitText(textToType); } + new JButtonOperator(jdo, buttonToPush).push(); + jdo.waitClosed(); + } - // Cancel with *NO* text case - { - new JButtonOperator(jfo, INPUT_BUTTON).pushNoBlock(); - - JDialogOperator jdo = new JDialogOperator(INPUT); - - assertTrue("Show Input Dialog cancel w/o Text", jdo.isShowing()); - - new JButtonOperator(jdo, CANCEL).push(); + public void showInputDialog(JFrameOperator jfo) throws Exception { + // Cancel with text case + useInputDialog(jfo, SOME_TEXT_TO_TYPE, CANCEL); + //TODO: wait for no dialog displayed - assertFalse("Show Input Dialog cancel w/o Text", jdo.isShowing()); - } + // Cancel with *NO* text case + useInputDialog(jfo, null, CANCEL); + //TODO: wait for no dialog displayed // Text field has *NO* input - { - new JButtonOperator(jfo, INPUT_BUTTON).pushNoBlock(); - - JDialogOperator jdo = new JDialogOperator(INPUT); - - assertTrue("Show Input Dialog w/o Input", jdo.isShowing()); - - new JButtonOperator(jdo, OK).push(); - - assertFalse("Show Input Dialog w/o Input", jdo.isShowing()); - } + useInputDialog(jfo, null, OK); + //TODO: wait for no dialog displayed // Text field has input { final String enteredText = "Rambo"; - new JButtonOperator(jfo, INPUT_BUTTON).pushNoBlock(); - - JDialogOperator jdo = new JDialogOperator(INPUT); - JTextFieldOperator jto = new JTextFieldOperator(jdo); - jto.setText(enteredText); - new JButtonOperator(jdo, OK).pushNoBlock(); - - JDialogOperator jdo1 = new JDialogOperator(MESSAGE); - - assertTrue("Show Input Dialog w/ Input", jdo1.isShowing()); - - final String labelText = enteredText + INPUT_RESPONSE; - JLabelOperator jLabelOperator = new JLabelOperator(jdo1, labelText); - assertEquals("Text from the field made it into the dialog", labelText, jLabelOperator.getText()); - - new JButtonOperator(jdo1, OK).push(); - - assertFalse("Show Input Dialog w/ Input", jdo1.isShowing()); + useInputDialog(jfo, enteredText, OK); + checkMessage(enteredText + INPUT_RESPONSE); } } @@ -149,11 +130,9 @@ JDialogOperator jdo = new JDialogOperator(WARNING_TITLE); - assertTrue("Show Warning Dialog", jdo.isShowing()); - new JButtonOperator(jdo, OK).push(); - assertFalse("Show Warning Dialog", jdo.isShowing()); + jdo.waitClosed(); } public void showMessageDialog(JFrameOperator jfo) throws Exception { @@ -161,105 +140,46 @@ JDialogOperator jdo = new JDialogOperator(MESSAGE); - assertTrue("Show Message Dialog", jdo.isShowing()); - new JButtonOperator(jdo, OK).push(); - assertFalse("Show Message Dialog", jdo.isShowing()); + jdo.waitClosed(); + } + + private void callADialogAndClose(JFrameOperator jfo, String buttonToOpenDialog, + String dialogTitle, String buttonToPush) { + new JButtonOperator(jfo, buttonToOpenDialog).pushNoBlock(); + JDialogOperator jdo = new JDialogOperator(dialogTitle); + new JButtonOperator(jdo, buttonToPush).push(); + jdo.waitClosed(); } public void showComponentDialog(JFrameOperator jfo) throws Exception { // Case: Cancel - { - new JButtonOperator(jfo, COMPONENT_BUTTON).pushNoBlock(); - - JDialogOperator jdo = new JDialogOperator(COMPONENT_TITLE); - - assertTrue("Show Component Dialog Cancel Option", jdo.isShowing()); - - new JButtonOperator(jdo, COMPONENT_OP5).push(); - - assertFalse("Show Component Dialog Cancel Option", jdo.isShowing()); - } + callADialogAndClose(jfo, COMPONENT_BUTTON, COMPONENT_TITLE, COMPONENT_OP5); + //TODO: wait for no dialog displayed // Case: Yes option selected { - new JButtonOperator(jfo, COMPONENT_BUTTON).pushNoBlock(); - - JDialogOperator jdo = new JDialogOperator(COMPONENT_TITLE); - new JButtonOperator(jdo, COMPONENT_OP1).pushNoBlock(); - - JDialogOperator jdo1 = new JDialogOperator(MESSAGE); - - assertTrue("Component Dialog Example Yes Option", jdo1.isShowing()); - - final String labelText = COMPONENT_R1; - JLabelOperator jLabelOperator = new JLabelOperator(jdo1, labelText); - assertEquals("Dialog contains appropriate text", labelText, jLabelOperator.getText()); - - new JButtonOperator(jdo1, OK).push(); - - assertFalse("Component Dialog Example Yes Option", jdo1.isShowing()); + callADialogAndClose(jfo, COMPONENT_BUTTON, COMPONENT_TITLE, COMPONENT_OP1); + checkMessage(COMPONENT_R1); } // Case: No option selected { - new JButtonOperator(jfo, COMPONENT_BUTTON).pushNoBlock(); - - JDialogOperator jdo = new JDialogOperator(COMPONENT_TITLE); - new JButtonOperator(jdo, COMPONENT_OP2).pushNoBlock(); - - JDialogOperator jdo1 = new JDialogOperator(MESSAGE); - - assertTrue("Component Dialog Example No Option", jdo1.isShowing()); - - final String labelText = COMPONENT_R2; - JLabelOperator jLabelOperator = new JLabelOperator(jdo1, labelText); - assertEquals("Dialog contains appropriate text", labelText, jLabelOperator.getText()); - - new JButtonOperator(jdo1, OK).push(); - - assertFalse("Component Dialog Example No Option", jdo1.isShowing()); + callADialogAndClose(jfo, COMPONENT_BUTTON, COMPONENT_TITLE, COMPONENT_OP2); + checkMessage(COMPONENT_R2); } // Case: Maybe option selected { - new JButtonOperator(jfo, COMPONENT_BUTTON).pushNoBlock(); - - JDialogOperator jdo = new JDialogOperator(COMPONENT_TITLE); - new JButtonOperator(jdo, COMPONENT_OP3).pushNoBlock(); - - JDialogOperator jdo1 = new JDialogOperator(MESSAGE); - - assertTrue("Component Dialog Maybe Yes Option", jdo1.isShowing()); - - final String labelText = COMPONENT_R3; - JLabelOperator jLabelOperator = new JLabelOperator(jdo1, labelText); - assertEquals("Dialog contains appropriate text", labelText, jLabelOperator.getText()); - - new JButtonOperator(jdo1, OK).push(); - - assertFalse("Component Dialog Maybe Yes Option", jdo1.isShowing()); + callADialogAndClose(jfo, COMPONENT_BUTTON, COMPONENT_TITLE, COMPONENT_OP3); + checkMessage(COMPONENT_R3); } // Case: Probably option selected { - new JButtonOperator(jfo, COMPONENT_BUTTON).pushNoBlock(); - - JDialogOperator jdo = new JDialogOperator(COMPONENT_TITLE); - new JButtonOperator(jdo, COMPONENT_OP4).pushNoBlock(); - - JDialogOperator jdo1 = new JDialogOperator(MESSAGE); - - assertTrue("Component Dialog Example Probably Option", jdo1.isShowing()); - - final String labelText = COMPONENT_R4; - JLabelOperator jLabelOperator = new JLabelOperator(jdo1, labelText); - assertEquals("Dialog contains appropriate text", labelText, jLabelOperator.getText()); - - new JButtonOperator(jdo1, OK).push(); - - assertFalse("Component Dialog Example Probably Option", jdo1.isShowing()); + callADialogAndClose(jfo, COMPONENT_BUTTON, COMPONENT_TITLE, COMPONENT_OP4); + checkMessage(COMPONENT_R4); } // Case TextField and ComboBox functional @@ -271,69 +191,35 @@ JTextFieldOperator jto = new JTextFieldOperator(jdo); jto.clearText(); jto.typeText(TEXT_TO_TYPE); + jto.waitText(TEXT_TO_TYPE); JComboBoxOperator jcbo = new JComboBoxOperator(jdo); jcbo.selectItem(2); + jcbo.waitItemSelected(2); - assertEquals("Show Component Dialog TextField", TEXT_TO_TYPE, jto.getText()); - assertEquals("Show Component Dialog ComboBox", 2, jcbo.getSelectedIndex()); - - new JButtonOperator(jdo, "cancel").push(); + new JButtonOperator(jdo, COMPONENT_OP5).push(); + jdo.waitClosed(); + //TODO: wait for no dialog displayed } } public void showConfirmationDialog(JFrameOperator jfo) throws Exception { // Case: Yes option selected { - new JButtonOperator(jfo, CONFIRM_BUTTON).pushNoBlock(); - - JDialogOperator jdo = new JDialogOperator(SELECT_AN_OPTION); - new JButtonOperator(jdo, YES).pushNoBlock(); - - JDialogOperator jdo1 = new JDialogOperator(MESSAGE); - - assertTrue("Show Confirmation Dialog Yes Option", jdo1.isShowing()); - - final String labelText = CONFIRM_YES; - JLabelOperator jLabelOperator = new JLabelOperator(jdo1, labelText); - assertEquals("Dialog contains appropriate text", labelText, jLabelOperator.getText()); - - new JButtonOperator(jdo1, OK).push(); - - assertFalse("Show Confirmation Dialog Yes Option", jdo1.isShowing()); + callADialogAndClose(jfo, CONFIRM_BUTTON, SELECT_AN_OPTION, YES); + checkMessage(CONFIRM_YES); } // Case: No option selected { - new JButtonOperator(jfo, CONFIRM_BUTTON).pushNoBlock(); - - JDialogOperator jdo = new JDialogOperator(SELECT_AN_OPTION); - new JButtonOperator(jdo, NO).pushNoBlock(); - - JDialogOperator jdo1 = new JDialogOperator(MESSAGE); - - assertTrue("Show Confirmation Dialog No Option", jdo1.isShowing()); - - final String labelText = CONFIRM_NO; - JLabelOperator jLabelOperator = new JLabelOperator(jdo1, labelText); - assertEquals("Dialog contains appropriate text", labelText, jLabelOperator.getText()); - - new JButtonOperator(jdo1, OK).push(); - - assertFalse("Show Confirmation Dialog No Option", jdo1.isShowing()); + callADialogAndClose(jfo, CONFIRM_BUTTON, SELECT_AN_OPTION, NO); + checkMessage(CONFIRM_NO); } // Case: Cancel option selected { - new JButtonOperator(jfo, CONFIRM_BUTTON).pushNoBlock(); - - JDialogOperator jdo = new JDialogOperator(SELECT_AN_OPTION); - - assertTrue("Show Confirmation Dialog Cancel Option", jdo.isShowing()); - - new JButtonOperator(jdo, CANCEL).push(); - - assertFalse("Show Confirmation Dialog Cancel Option", jdo.isShowing()); + callADialogAndClose(jfo, CONFIRM_BUTTON, SELECT_AN_OPTION, CANCEL); + //TODO: wait for no dialog displayed } } --- old/test/sanity/client/SwingSet/src/ProgressBarDemoTest.java 2016-05-24 10:48:10.000000000 -0700 +++ new/test/sanity/client/SwingSet/src/ProgressBarDemoTest.java 2016-05-24 10:48:09.000000000 -0700 @@ -43,6 +43,8 @@ * @library /sanity/client/lib/jemmy/src * @library /sanity/client/lib/Extensions/src * @library /sanity/client/lib/SwingSet3/src + * @modules java.desktop + * java.logging * @build org.jemmy2ext.JemmyExt * @build com.sun.swingset3.demos.progressbar.ProgressBarDemo * @run testng ProgressBarDemoTest @@ -81,7 +83,6 @@ @Override public boolean checkComponent(Component comp) { int value = progressBar.getValue(); - System.out.println("checkComponent1 value = " + value); return value < maximum; } @@ -98,7 +99,6 @@ @Override public boolean checkComponent(Component comp) { int value = progressBar.getValue(); - System.out.println("checkComponent2 value = " + value); return value > 0; } --- old/test/sanity/client/SwingSet/src/ScrollPaneDemoTest.java 2016-05-24 10:48:10.000000000 -0700 +++ new/test/sanity/client/SwingSet/src/ScrollPaneDemoTest.java 2016-05-24 10:48:10.000000000 -0700 @@ -40,6 +40,8 @@ * @library /sanity/client/lib/jemmy/src * @library /sanity/client/lib/Extensions/src * @library /sanity/client/lib/SwingSet3/src + * @modules java.desktop + * java.logging * @build org.jemmy2ext.JemmyExt * @build com.sun.swingset3.demos.scrollpane.ScrollPaneDemo * @run testng ScrollPaneDemoTest --- old/test/sanity/client/SwingSet/src/SpinnerDemoTest.java 2016-05-24 10:48:11.000000000 -0700 +++ new/test/sanity/client/SwingSet/src/SpinnerDemoTest.java 2016-05-24 10:48:11.000000000 -0700 @@ -42,6 +42,8 @@ * @library /sanity/client/lib/jemmy/src * @library /sanity/client/lib/Extensions/src * @library /sanity/client/lib/SwingSet3/src + * @modules java.desktop + * java.logging * @build org.jemmy2ext.JemmyExt * @build com.sun.swingset3.demos.spinner.SpinnerDemo * @run testng SpinnerDemoTest --- old/test/sanity/client/SwingSet/src/SplitPaneDemoTest.java 2016-05-24 10:48:12.000000000 -0700 +++ new/test/sanity/client/SwingSet/src/SplitPaneDemoTest.java 2016-05-24 10:48:12.000000000 -0700 @@ -21,22 +21,29 @@ * questions. */ -import org.jtregext.GuiTestListener; import com.sun.swingset3.demos.splitpane.SplitPaneDemo; import static com.sun.swingset3.demos.splitpane.SplitPaneDemo.*; + +import java.awt.Component; import java.awt.event.KeyEvent; import javax.swing.JSplitPane; -import static org.testng.AssertJUnit.*; -import org.testng.annotations.Test; + +import static org.jemmy2ext.JemmyExt.*; + +import org.jtregext.GuiTestListener; + import org.netbeans.jemmy.ClassReference; +import org.netbeans.jemmy.ComponentChooser; import org.netbeans.jemmy.operators.JButtonOperator; import org.netbeans.jemmy.operators.JCheckBoxOperator; import org.netbeans.jemmy.operators.JFrameOperator; import org.netbeans.jemmy.operators.JRadioButtonOperator; import org.netbeans.jemmy.operators.JSplitPaneOperator; import org.netbeans.jemmy.operators.JTextFieldOperator; -import static org.jemmy2ext.JemmyExt.*; + import org.testng.annotations.Listeners; +import org.testng.annotations.Test; +import static org.testng.AssertJUnit.*; /* * @test @@ -48,6 +55,8 @@ * @library /sanity/client/lib/jemmy/src * @library /sanity/client/lib/Extensions/src * @library /sanity/client/lib/SwingSet3/src + * @modules java.desktop + * java.logging * @build org.jemmy2ext.JemmyExt * @build com.sun.swingset3.demos.splitpane.SplitPaneDemo * @run testng SplitPaneDemoTest @@ -115,14 +124,33 @@ (splitPane.getMaximumDividerLocation() + splitPane.getMinimumDividerLocation()) / 2, splitPane.getDividerLocation()); } + private void waitDividerSize(JSplitPaneOperator splitPane, int size) { + splitPane.waitState(new ComponentChooser() { + public boolean checkComponent(Component c) { + return splitPane.getDividerSize() == size; + } + public String getDescription() { + return "Divider size to be " + size; + } + }); + } + // Check changing the size of the divider public void changeDividerSize(JFrameOperator frame, JSplitPaneOperator splitPane, int amount) throws Exception { JTextFieldOperator size = new JTextFieldOperator(getLabeledContainerOperator(frame, DIVIDER_SIZE)); - size.clearText(); - size.typeText(Integer.toString(amount)); - size.pressKey(KeyEvent.VK_ENTER); + size.enterText(Integer.toString(amount)); + waitDividerSize(splitPane, amount); + } - assertEquals("Change Divider Size", amount, splitPane.getDividerSize()); + private void waitDividerLocation(JSplitPaneOperator splitPane, int location) { + splitPane.waitState(new ComponentChooser() { + public boolean checkComponent(Component c) { + return splitPane.getDividerLocation() == location; + } + public String getDescription() { + return "Divider location to be " + location; + } + }); } public void checkOneTouch(JFrameOperator frame, JSplitPaneOperator splitPane, boolean oneTouch) throws Exception { @@ -144,23 +172,19 @@ // expand full left buttonLeft.push(); - assertEquals("Expandable Left", left, splitPane.getDividerLocation()); + waitDividerLocation(splitPane, left); // expand back from full left buttonRight.push(); - assertEquals("Expandable Back to Original from Left", - initDividerLocation, splitPane.getDividerLocation()); + waitDividerLocation(splitPane, initDividerLocation); // expand all the way right buttonRight.push(); - assertEquals("Expandable Right", - splitPane.getWidth() - splitPane.getDividerSize() - right, - splitPane.getDividerLocation()); + waitDividerLocation(splitPane, splitPane.getWidth() - splitPane.getDividerSize() - right); // Click to move back from right expansion buttonLeft.push(); - assertEquals("Expandable Back to Original from Right", - initDividerLocation, splitPane.getDividerLocation()); + waitDividerLocation(splitPane, initDividerLocation); } // Test for case where one touch expandable is disabled @@ -169,7 +193,14 @@ // uncheck checkBox.doClick(); } - assertFalse("One Touch Expandable Off", splitPane.isOneTouchExpandable()); + splitPane.waitState(new ComponentChooser() { + public boolean checkComponent(Component c) { + return !splitPane.isOneTouchExpandable(); + } + public String getDescription() { + return "Split pane not to be one touch expandable"; + } + }); } } --- old/test/sanity/client/SwingSet/src/TabbedPaneDemoTest.java 2016-05-24 10:48:12.000000000 -0700 +++ new/test/sanity/client/SwingSet/src/TabbedPaneDemoTest.java 2016-05-24 10:48:12.000000000 -0700 @@ -43,6 +43,8 @@ * @library /sanity/client/lib/jemmy/src * @library /sanity/client/lib/Extensions/src * @library /sanity/client/lib/SwingSet3/src + * @modules java.desktop + * java.logging * @build org.jemmy2ext.JemmyExt * @build com.sun.swingset3.demos.tabbedpane.TabbedPaneDemo * @run testng TabbedPaneDemoTest @@ -69,9 +71,8 @@ for (int i = 0; i < tabTitles.length; i++) { String pageTitle = tabTitles[i]; JTabbedPaneOperator tabOperator = new JTabbedPaneOperator(mainFrame); + tabOperator.setVerification(true); tabOperator.selectPage(pageTitle); - - assertEquals("Selected tab is selected", i, tabOperator.getSelectedIndex()); } } --- old/test/sanity/client/SwingSet/src/TextFieldDemoTest.java 2016-05-24 10:48:13.000000000 -0700 +++ new/test/sanity/client/SwingSet/src/TextFieldDemoTest.java 2016-05-24 10:48:13.000000000 -0700 @@ -21,20 +21,22 @@ * questions. */ -import org.jtregext.GuiTestListener; import com.sun.swingset3.demos.textfield.JHistoryTextField; import com.sun.swingset3.demos.textfield.TextFieldDemo; import static com.sun.swingset3.demos.textfield.TextFieldDemo.*; + import java.awt.Color; +import java.awt.Component; import java.awt.event.KeyEvent; import java.util.Calendar; import java.util.Date; import java.util.Locale; import javax.swing.JFormattedTextField; + import static org.jemmy2ext.JemmyExt.*; -import static org.testng.AssertJUnit.*; -import org.testng.annotations.Test; + import org.netbeans.jemmy.ClassReference; +import org.netbeans.jemmy.ComponentChooser; import org.netbeans.jemmy.QueueTool; import org.netbeans.jemmy.operators.ContainerOperator; import org.netbeans.jemmy.operators.JButtonOperator; @@ -42,7 +44,12 @@ import org.netbeans.jemmy.operators.JLabelOperator; import org.netbeans.jemmy.operators.JPasswordFieldOperator; import org.netbeans.jemmy.operators.JTextFieldOperator; + +import org.jtregext.GuiTestListener; + import org.testng.annotations.Listeners; +import org.testng.annotations.Test; +import static org.testng.AssertJUnit.*; /* * @test @@ -53,6 +60,8 @@ * @library /sanity/client/lib/jemmy/src * @library /sanity/client/lib/Extensions/src * @library /sanity/client/lib/SwingSet3/src + * @modules java.desktop + * java.logging * @build org.jemmy2ext.JemmyExt * @build com.sun.swingset3.demos.textfield.TextFieldDemo * @run testng TextFieldDemoTest @@ -95,9 +104,7 @@ // Check default date Day of the Week jbo.push(); - assertEquals("Default DOW", - calendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.ENGLISH), - dowLabel.getText()); + dowLabel.waitText(calendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.ENGLISH)); // Check Custom Day of the Week calendar.set(2012, 9, 11); // Represents "Oct 11, 2012" @@ -114,7 +121,7 @@ jtfo.enterText(dateString); jbo.push(); - assertEquals("Custom DOW", "Thursday", dowLabel.getText()); + dowLabel.waitText("Thursday"); } public void passwordField(JFrameOperator jfo) throws Exception { @@ -125,13 +132,27 @@ password2.typeText("password"); // Check Matching Passwords - assertEquals("Matching Passwords", Color.green, password1.getBackground()); - assertEquals("Matching Passwords", Color.green, password2.getBackground()); + password1.waitState(new ComponentChooser() { + public boolean checkComponent(Component comp) { + return password1.getBackground().equals(Color.green) && + password2.getBackground().equals(Color.green); + } + public String getDescription() { + return "Passwords to match"; + } + }); // Check non-matching passwords password2.typeText("passwereertegrs"); - assertEquals("Non-Matching Passwords", Color.white, password1.getBackground()); - assertEquals("Non-Matching Passwords", Color.white, password2.getBackground()); + password1.waitState(new ComponentChooser() { + public boolean checkComponent(Component comp) { + return password1.getBackground().equals(Color.white) && + password2.getBackground().equals(Color.white); + } + public String getDescription() { + return "Passwords not to match"; + } + }); } } --- old/test/sanity/client/SwingSet/src/ToggleButtonDemoTest.java 2016-05-24 10:48:14.000000000 -0700 +++ new/test/sanity/client/SwingSet/src/ToggleButtonDemoTest.java 2016-05-24 10:48:14.000000000 -0700 @@ -56,6 +56,8 @@ * @library /sanity/client/lib/jemmy/src * @library /sanity/client/lib/Extensions/src * @library /sanity/client/lib/SwingSet3/src + * @modules java.desktop + * java.logging * @build org.jemmy2ext.JemmyExt * @build com.sun.swingset3.demos.togglebutton.ToggleButtonDemo * @run testng ToggleButtonDemoTest @@ -125,12 +127,12 @@ } for (int i = 0; i < radioButtonCount; i++) { - jrbo[i].doClick(); - assertTrue("Radio Button " + i + " is selected", jrbo[i].isSelected()); + jrbo[i].push(); + jrbo[i].waitSelected(true); for (int j = 0; j < radioButtonCount; j++) { if (i != j) { - assertFalse("Radio Button " + j + " is not selected", jrbo[j].isSelected()); + jrbo[j].waitSelected(false); } } } @@ -146,23 +148,17 @@ */ private void testCheckBox(ContainerOperator parent, String text, boolean expectedValue) { + System.out.println("Testing " + text); parent.setComparator(EXACT_STRING_COMPARATOR); JCheckBoxOperator jcbo = new JCheckBoxOperator(parent, text); - assertEquals("Initial selection state of the checkbox '" + text + "'", expectedValue, jcbo.isSelected()); + jcbo.waitSelected(expectedValue); // click check box (toggle the state) - jcbo.doClick(); - assertEquals("Selection state of the checkbox '" + text + "' after click", !expectedValue, jcbo.isSelected()); - if (jcbo.isSelected()) { - // toggle back to not-selected state - jcbo.doClick(); - assertFalse("Check Box '" + text + "' is not selected", jcbo.isSelected()); - } else { - // toggle back to selected state - jcbo.doClick(); + jcbo.push(); + jcbo.waitSelected(!expectedValue); - assertTrue("Check Box '" + text + "' is selected", jcbo.isSelected()); - } + jcbo.push(); + jcbo.waitSelected(expectedValue); } --- old/test/sanity/client/SwingSet/src/TreeDemoTest.java 2016-05-24 10:48:15.000000000 -0700 +++ new/test/sanity/client/SwingSet/src/TreeDemoTest.java 2016-05-24 10:48:14.000000000 -0700 @@ -21,16 +21,22 @@ * questions. */ -import org.jtregext.GuiTestListener; import com.sun.swingset3.demos.tree.TreeDemo; import static com.sun.swingset3.demos.tree.TreeDemo.DEMO_TITLE; + +import java.awt.Component; import javax.swing.tree.TreePath; -import static org.testng.AssertJUnit.*; -import org.testng.annotations.Test; + +import org.jtregext.GuiTestListener; + import org.netbeans.jemmy.ClassReference; +import org.netbeans.jemmy.ComponentChooser; import org.netbeans.jemmy.operators.JFrameOperator; import org.netbeans.jemmy.operators.JTreeOperator; + import org.testng.annotations.Listeners; +import org.testng.annotations.Test; +import static org.testng.AssertJUnit.*; /* * @test @@ -45,6 +51,8 @@ * @library /sanity/client/lib/jemmy/src * @library /sanity/client/lib/Extensions/src * @library /sanity/client/lib/SwingSet3/src + * @modules java.desktop + * java.logging * @build org.jemmy2ext.JemmyExt * @build com.sun.swingset3.demos.tree.TreeDemo * @run testng TreeDemoTest @@ -52,6 +60,20 @@ @Listeners(GuiTestListener.class) public class TreeDemoTest { + private static final int NODES_TO_EXPAND = 75; + private static final int NODES_TOTAL = 616; + + private void waitRowCount(JTreeOperator tree, int count) { + tree.waitState(new ComponentChooser() { + public boolean checkComponent(Component comp) { + return tree.getRowCount() == count; + } + public String getDescription() { + return "A tree to have " + count + " rows"; + } + }); + } + @Test public void test() throws Exception { @@ -75,9 +97,8 @@ } } - assertEquals("Number of rows expanded", 75, expandsCount); - assertEquals("Number of rows in the tree after expanding all of them", - 616, tree.getRowCount()); + assertEquals("Number of rows expanded", NODES_TO_EXPAND, expandsCount); + waitRowCount(tree, NODES_TOTAL); int expandedTreeHeight = tree.getHeight(); assertTrue("Expanded tree height has increased, current " @@ -94,9 +115,8 @@ } } - assertEquals("Number of rows collapsed", 76, collapsesCount); - assertEquals("Number of rows in the tree after collapsing all of them", - 1, tree.getRowCount()); + assertEquals("Number of rows collapsed", NODES_TO_EXPAND + 1, collapsesCount); + waitRowCount(tree, 1); int collapsedTreeHeight = tree.getHeight(); assertTrue("Collpased tree height is not longer than initial, " --- old/test/sanity/client/SwingSet/src/WindowDemoTest.java 2016-05-24 10:48:15.000000000 -0700 +++ new/test/sanity/client/SwingSet/src/WindowDemoTest.java 2016-05-24 10:48:15.000000000 -0700 @@ -44,6 +44,8 @@ * @library /sanity/client/lib/jemmy/src * @library /sanity/client/lib/Extensions/src * @library /sanity/client/lib/SwingSet3/src + * @modules java.desktop + * java.logging * @build org.jemmy2ext.JemmyExt * @build com.sun.swingset3.demos.window.WindowDemo * @run testng WindowDemoTest