author | mrkam |
Wed, 27 Apr 2016 17:47:17 -0700 | |
changeset 37677 | 9774eca96b01 |
parent 36744 | a00905527ec2 |
child 39006 | fd8c3312d043 |
permissions | -rw-r--r-- |
36744 | 1 |
/* |
2 |
* Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
24 |
import org.jtregext.GuiTestListener; |
36744 | 25 |
import com.sun.swingset3.demos.list.ListDemo; |
26 |
import static com.sun.swingset3.demos.list.ListDemo.DEMO_TITLE; |
|
27 |
import static org.testng.AssertJUnit.*; |
|
28 |
import org.testng.annotations.Test; |
|
29 |
import static org.jemmy2ext.JemmyExt.getLabeledContainerOperator; |
|
30 |
import org.netbeans.jemmy.ClassReference; |
|
31 |
import org.netbeans.jemmy.operators.JCheckBoxOperator; |
|
32 |
import org.netbeans.jemmy.operators.JFrameOperator; |
|
33 |
import org.netbeans.jemmy.operators.JListOperator; |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
34 |
import org.testng.annotations.Listeners; |
36744 | 35 |
|
36 |
/* |
|
37 |
* @test |
|
38 |
* @key headful |
|
39 |
* @summary Verifies SwingSet3 ListDemo page by checking and unchecking all |
|
40 |
* the checkboxes on the page and verifying the number of items in the |
|
41 |
* list. |
|
42 |
* |
|
43 |
* @library /sanity/client/lib/jemmy/src |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
44 |
* @library /sanity/client/lib/Extensions/src |
36744 | 45 |
* @library /sanity/client/lib/SwingSet3/src |
46 |
* @build org.jemmy2ext.JemmyExt |
|
47 |
* @build com.sun.swingset3.demos.list.ListDemo |
|
48 |
* @run testng ListDemoTest |
|
49 |
*/ |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
50 |
@Listeners(GuiTestListener.class) |
36744 | 51 |
public class ListDemoTest { |
52 |
||
53 |
private static final int CHECKBOX_COUNT = 50; |
|
54 |
||
55 |
@Test |
|
56 |
public void test() throws Exception { |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
57 |
|
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
58 |
new ClassReference(ListDemo.class.getCanonicalName()).startApplication(); |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
59 |
|
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
60 |
JFrameOperator frame = new JFrameOperator(DEMO_TITLE); |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
61 |
JListOperator listOp = new JListOperator(frame); |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
62 |
|
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
63 |
// Check *NO* Prefix and Suffixes Marked |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
64 |
for (int i = 0; i < CHECKBOX_COUNT; i++) { |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
65 |
JCheckBoxOperator checkBox = getJCheckBoxOperator(frame, i); |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
66 |
checkBox.changeSelection(false); |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
67 |
} |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
68 |
System.out.println("######## Number of Items = " + listOp.getModel().getSize()); |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
69 |
assertEquals("Select None number of items is correct", 0, listOp.getModel().getSize()); |
36744 | 70 |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
71 |
// Check *ALL* Prefix and Suffixes Marked |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
72 |
for (int i = 0; i < CHECKBOX_COUNT; i++) { |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
73 |
JCheckBoxOperator checkBox = getJCheckBoxOperator(frame, i); |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
74 |
checkBox.changeSelection(true); |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
75 |
} |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
76 |
System.out.println("######## Number of Items = " + listOp.getModel().getSize()); |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
77 |
assertEquals("Select All number of items is correct", CHECKBOX_COUNT / 2 * CHECKBOX_COUNT / 2, listOp.getModel().getSize()); |
36744 | 78 |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
79 |
// Check *ALL* Prefix and *NO* Suffixes Marked |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
80 |
for (int i = 0; i < CHECKBOX_COUNT; i++) { |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
81 |
JCheckBoxOperator checkBox = getJCheckBoxOperator(frame, i); |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
82 |
if (i < CHECKBOX_COUNT / 2) { |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
83 |
checkBox.changeSelection(true); |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
84 |
} else { |
36744 | 85 |
checkBox.changeSelection(false); |
86 |
} |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
87 |
} |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
88 |
System.out.println("######## Number of Items = " + listOp.getModel().getSize()); |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
89 |
assertEquals("Select All Prefixes and NO Suffixes number of items is correct", 0, listOp.getModel().getSize()); |
36744 | 90 |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
91 |
// Check *NO* Prefix and *ALL* Suffixes Marked |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
92 |
for (int i = 0; i < CHECKBOX_COUNT; i++) { |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
93 |
JCheckBoxOperator checkBox = getJCheckBoxOperator(frame, i); |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
94 |
if (i < CHECKBOX_COUNT / 2) { |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
95 |
checkBox.changeSelection(false); |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
96 |
} else { |
36744 | 97 |
checkBox.changeSelection(true); |
98 |
} |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
99 |
} |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
100 |
System.out.println("######## Number of Items = " + listOp.getModel().getSize()); |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
101 |
assertEquals("Select NO Prefixes and All Suffixes number of items is correct", 0, listOp.getModel().getSize()); |
36744 | 102 |
} |
103 |
||
104 |
private JCheckBoxOperator getJCheckBoxOperator(JFrameOperator frame, int index) { |
|
105 |
||
106 |
// We map first half of indexes to the Prefixes panel and the second half |
|
107 |
// to the Suffixes panel |
|
108 |
String labelText; |
|
109 |
int subindex; |
|
110 |
if (index < CHECKBOX_COUNT / 2) { |
|
111 |
labelText = "Prefixes"; |
|
112 |
subindex = index; |
|
113 |
} else { |
|
114 |
labelText = "Suffixes"; |
|
115 |
subindex = index - CHECKBOX_COUNT / 2; |
|
116 |
} |
|
117 |
||
118 |
return new JCheckBoxOperator(getLabeledContainerOperator(frame, labelText), subindex); |
|
119 |
} |
|
120 |
||
121 |
} |