< prev index next >
test/sanity/client/SwingSet/src/ListDemoTest.java
Print this page
*** 19,39 ****
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* 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 org.netbeans.jemmy.ClassReference;
import org.netbeans.jemmy.operators.JCheckBoxOperator;
import org.netbeans.jemmy.operators.JFrameOperator;
import org.netbeans.jemmy.operators.JListOperator;
import org.testng.annotations.Listeners;
/*
* @test
* @key headful
* @summary Verifies SwingSet3 ListDemo page by checking and unchecking all
--- 19,47 ----
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import com.sun.swingset3.demos.list.ListDemo;
import static com.sun.swingset3.demos.list.ListDemo.DEMO_TITLE;
!
! 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
* @key headful
* @summary Verifies SwingSet3 ListDemo page by checking and unchecking all
*** 41,59 ****
--- 49,79 ----
* list.
*
* @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.list.ListDemo
* @run testng ListDemoTest
*/
@Listeners(GuiTestListener.class)
public class ListDemoTest {
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 {
new ClassReference(ListDemo.class.getCanonicalName()).startApplication();
*** 63,106 ****
// Check *NO* Prefix and Suffixes Marked
for (int i = 0; i < CHECKBOX_COUNT; i++) {
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());
// 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());
// Check *ALL* Prefix and *NO* Suffixes Marked
for (int i = 0; i < CHECKBOX_COUNT; i++) {
JCheckBoxOperator checkBox = getJCheckBoxOperator(frame, i);
if (i < CHECKBOX_COUNT / 2) {
checkBox.changeSelection(true);
} else {
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());
// Check *NO* Prefix and *ALL* Suffixes Marked
for (int i = 0; i < CHECKBOX_COUNT; i++) {
JCheckBoxOperator checkBox = getJCheckBoxOperator(frame, i);
if (i < CHECKBOX_COUNT / 2) {
checkBox.changeSelection(false);
} else {
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());
}
private JCheckBoxOperator getJCheckBoxOperator(JFrameOperator frame, int index) {
// We map first half of indexes to the Prefixes panel and the second half
--- 83,122 ----
// Check *NO* Prefix and Suffixes Marked
for (int i = 0; i < CHECKBOX_COUNT; i++) {
JCheckBoxOperator checkBox = getJCheckBoxOperator(frame, i);
checkBox.changeSelection(false);
}
! 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);
}
! waitModelSize(listOp, CHECKBOX_COUNT * CHECKBOX_COUNT / 4);
// Check *ALL* Prefix and *NO* Suffixes Marked
for (int i = 0; i < CHECKBOX_COUNT; i++) {
JCheckBoxOperator checkBox = getJCheckBoxOperator(frame, i);
if (i < CHECKBOX_COUNT / 2) {
checkBox.changeSelection(true);
} else {
checkBox.changeSelection(false);
}
}
! waitModelSize(listOp, 0);
// Check *NO* Prefix and *ALL* Suffixes Marked
for (int i = 0; i < CHECKBOX_COUNT; i++) {
JCheckBoxOperator checkBox = getJCheckBoxOperator(frame, i);
if (i < CHECKBOX_COUNT / 2) {
checkBox.changeSelection(false);
} else {
checkBox.changeSelection(true);
}
}
! waitModelSize(listOp, 0);
}
private JCheckBoxOperator getJCheckBoxOperator(JFrameOperator frame, int index) {
// We map first half of indexes to the Prefixes panel and the second half
*** 113,121 ****
} else {
labelText = "Suffixes";
subindex = index - CHECKBOX_COUNT / 2;
}
! return new JCheckBoxOperator(getLabeledContainerOperator(frame, labelText), subindex);
}
}
--- 129,139 ----
} else {
labelText = "Suffixes";
subindex = index - CHECKBOX_COUNT / 2;
}
! JCheckBoxOperator result = new JCheckBoxOperator(getLabeledContainerOperator(frame, labelText), subindex);
! result.setVerification(true);
! return result;
}
}
< prev index next >