< prev index next >

test/sanity/client/SwingSet/src/ToggleButtonDemoTest.java

Print this page

        

@@ -54,10 +54,11 @@
  *          selected.
  *
  * @library /sanity/client/lib/jemmy/src
  * @library /sanity/client/lib/Extensions/src
  * @library /sanity/client/lib/SwingSet3/src
+ * @modules java.desktop
  * @build org.jemmy2ext.JemmyExt
  * @build com.sun.swingset3.demos.togglebutton.ToggleButtonDemo
  * @run testng ToggleButtonDemoTest
  */
 @Listeners(GuiTestListener.class)

@@ -123,16 +124,16 @@
                 assertFalse("Radio Button " + i + " is initially not selected", jrbo[i].isSelected());
             }
         }
 
         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);
                 }
             }
         }
     }
 

@@ -144,27 +145,21 @@
      * @param expectedValue
      * @throws Exception
      */
     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);
     }
 
 
     /*
      * testDirectionRadioButtons(JFrameOperator) will toggle each position of
< prev index next >