author | hseigel |
Wed, 01 Mar 2017 08:00:02 -0500 | |
changeset 46194 | 5596e6f63072 |
parent 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 |
||
24 |
import com.sun.swingset3.demos.optionpane.OptionPaneDemo; |
|
25 |
import static com.sun.swingset3.demos.optionpane.OptionPaneDemo.*; |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
26 |
|
36744 | 27 |
import javax.swing.UIManager; |
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
28 |
|
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
29 |
import org.jtregext.GuiTestListener; |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
30 |
|
36744 | 31 |
import org.netbeans.jemmy.ClassReference; |
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
32 |
import org.netbeans.jemmy.operators.Operator.DefaultStringComparator; |
36744 | 33 |
import org.netbeans.jemmy.operators.JButtonOperator; |
34 |
import org.netbeans.jemmy.operators.JComboBoxOperator; |
|
35 |
import org.netbeans.jemmy.operators.JDialogOperator; |
|
36 |
import org.netbeans.jemmy.operators.JFrameOperator; |
|
37 |
import org.netbeans.jemmy.operators.JLabelOperator; |
|
38 |
import org.netbeans.jemmy.operators.JTextFieldOperator; |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
39 |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
40 |
import org.testng.annotations.Listeners; |
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
41 |
import org.testng.annotations.Test; |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
42 |
import static org.testng.AssertJUnit.*; |
36744 | 43 |
|
44 |
||
45 |
/* |
|
46 |
* @test |
|
47 |
* @key headful |
|
48 |
* @summary Verifies SwingSet3 OptionPaneDemo page by opening all the dialogs |
|
49 |
* and choosing different options in them. |
|
50 |
* |
|
51 |
* @library /sanity/client/lib/jemmy/src |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
52 |
* @library /sanity/client/lib/Extensions/src |
36744 | 53 |
* @library /sanity/client/lib/SwingSet3/src |
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
54 |
* @modules java.desktop |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
55 |
* java.logging |
36744 | 56 |
* @build org.jemmy2ext.JemmyExt |
57 |
* @build com.sun.swingset3.demos.optionpane.OptionPaneDemo |
|
58 |
* @run testng OptionPaneDemoTest |
|
59 |
*/ |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
60 |
@Listeners(GuiTestListener.class) |
36744 | 61 |
public class OptionPaneDemoTest { |
62 |
||
63 |
public static final String SOME_TEXT_TO_TYPE = "I am some text"; |
|
64 |
public static final String MESSAGE = UIManager.getString("OptionPane.messageDialogTitle"); |
|
65 |
public static final String OK = "OK"; |
|
66 |
public static final String CANCEL = "Cancel"; |
|
67 |
public static final String INPUT = UIManager.getString("OptionPane.inputDialogTitle"); |
|
68 |
public static final String TEXT_TO_TYPE = "Hooray! I'm a textField"; |
|
69 |
public static final String NO = "No"; |
|
70 |
public static final String YES = "Yes"; |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
71 |
public static final String SELECT_AN_OPTION = UIManager.getString("OptionPane.titleText"); |
36744 | 72 |
|
73 |
@Test |
|
74 |
public void test() throws Exception { |
|
75 |
||
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
76 |
new ClassReference(OptionPaneDemo.class.getCanonicalName()).startApplication(); |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
77 |
|
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
78 |
JFrameOperator frame = new JFrameOperator(DEMO_TITLE); |
36744 | 79 |
|
37677
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
80 |
showInputDialog(frame); |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
81 |
showWarningDialog(frame); |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
82 |
showMessageDialog(frame); |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
83 |
showComponentDialog(frame); |
9774eca96b01
8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents:
36744
diff
changeset
|
84 |
showConfirmationDialog(frame); |
36744 | 85 |
} |
86 |
||
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
87 |
private void checkMessage(String message) { |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
88 |
JDialogOperator jdo = new JDialogOperator(MESSAGE); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
89 |
new JLabelOperator(jdo, message); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
90 |
new JButtonOperator(jdo, OK).push(); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
91 |
jdo.waitClosed(); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
92 |
} |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
93 |
|
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
94 |
private void useInputDialog(JFrameOperator jfo, String textToType, String buttonToPush) { |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
95 |
new JButtonOperator(jfo, INPUT_BUTTON).pushNoBlock(); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
96 |
JDialogOperator jdo = new JDialogOperator(INPUT); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
97 |
if(textToType != null) { |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
98 |
JTextFieldOperator jto = new JTextFieldOperator(jdo); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
99 |
jto.typeText(textToType); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
100 |
jto.waitText(textToType); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
101 |
} |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
102 |
new JButtonOperator(jdo, buttonToPush).push(); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
103 |
jdo.waitClosed(); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
104 |
} |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
105 |
|
36744 | 106 |
public void showInputDialog(JFrameOperator jfo) throws Exception { |
107 |
// Cancel with text case |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
108 |
useInputDialog(jfo, SOME_TEXT_TO_TYPE, CANCEL); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
109 |
//TODO: wait for no dialog displayed |
36744 | 110 |
|
111 |
// Cancel with *NO* text case |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
112 |
useInputDialog(jfo, null, CANCEL); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
113 |
//TODO: wait for no dialog displayed |
36744 | 114 |
|
115 |
// Text field has *NO* input |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
116 |
useInputDialog(jfo, null, OK); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
117 |
//TODO: wait for no dialog displayed |
36744 | 118 |
|
119 |
// Text field has input |
|
120 |
{ |
|
121 |
final String enteredText = "Rambo"; |
|
122 |
||
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
123 |
useInputDialog(jfo, enteredText, OK); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
124 |
checkMessage(enteredText + INPUT_RESPONSE); |
36744 | 125 |
} |
126 |
} |
|
127 |
||
128 |
public void showWarningDialog(JFrameOperator jfo) throws Exception { |
|
129 |
new JButtonOperator(jfo, WARNING_BUTTON).pushNoBlock(); |
|
130 |
||
131 |
JDialogOperator jdo = new JDialogOperator(WARNING_TITLE); |
|
132 |
||
133 |
new JButtonOperator(jdo, OK).push(); |
|
134 |
||
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
135 |
jdo.waitClosed(); |
36744 | 136 |
} |
137 |
||
138 |
public void showMessageDialog(JFrameOperator jfo) throws Exception { |
|
139 |
new JButtonOperator(jfo, MESSAGE_BUTTON).pushNoBlock(); |
|
140 |
||
141 |
JDialogOperator jdo = new JDialogOperator(MESSAGE); |
|
142 |
||
143 |
new JButtonOperator(jdo, OK).push(); |
|
144 |
||
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
145 |
jdo.waitClosed(); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
146 |
} |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
147 |
|
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
148 |
private void callADialogAndClose(JFrameOperator jfo, String buttonToOpenDialog, |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
149 |
String dialogTitle, String buttonToPush) { |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
150 |
new JButtonOperator(jfo, buttonToOpenDialog).pushNoBlock(); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
151 |
JDialogOperator jdo = new JDialogOperator(dialogTitle); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
152 |
new JButtonOperator(jdo, buttonToPush).push(); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
153 |
jdo.waitClosed(); |
36744 | 154 |
} |
155 |
||
156 |
public void showComponentDialog(JFrameOperator jfo) throws Exception { |
|
157 |
// Case: Cancel |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
158 |
callADialogAndClose(jfo, COMPONENT_BUTTON, COMPONENT_TITLE, COMPONENT_OP5); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
159 |
//TODO: wait for no dialog displayed |
36744 | 160 |
|
161 |
// Case: Yes option selected |
|
162 |
{ |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
163 |
callADialogAndClose(jfo, COMPONENT_BUTTON, COMPONENT_TITLE, COMPONENT_OP1); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
164 |
checkMessage(COMPONENT_R1); |
36744 | 165 |
} |
166 |
||
167 |
// Case: No option selected |
|
168 |
{ |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
169 |
callADialogAndClose(jfo, COMPONENT_BUTTON, COMPONENT_TITLE, COMPONENT_OP2); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
170 |
checkMessage(COMPONENT_R2); |
36744 | 171 |
} |
172 |
||
173 |
// Case: Maybe option selected |
|
174 |
{ |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
175 |
callADialogAndClose(jfo, COMPONENT_BUTTON, COMPONENT_TITLE, COMPONENT_OP3); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
176 |
checkMessage(COMPONENT_R3); |
36744 | 177 |
} |
178 |
||
179 |
// Case: Probably option selected |
|
180 |
{ |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
181 |
callADialogAndClose(jfo, COMPONENT_BUTTON, COMPONENT_TITLE, COMPONENT_OP4); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
182 |
checkMessage(COMPONENT_R4); |
36744 | 183 |
} |
184 |
||
185 |
// Case TextField and ComboBox functional |
|
186 |
{ |
|
187 |
new JButtonOperator(jfo, COMPONENT_BUTTON).push(); |
|
188 |
||
189 |
JDialogOperator jdo = new JDialogOperator(COMPONENT_TITLE); |
|
190 |
||
191 |
JTextFieldOperator jto = new JTextFieldOperator(jdo); |
|
192 |
jto.clearText(); |
|
193 |
jto.typeText(TEXT_TO_TYPE); |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
194 |
jto.waitText(TEXT_TO_TYPE); |
36744 | 195 |
|
196 |
JComboBoxOperator jcbo = new JComboBoxOperator(jdo); |
|
197 |
jcbo.selectItem(2); |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
198 |
jcbo.waitItemSelected(2); |
36744 | 199 |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
200 |
new JButtonOperator(jdo, COMPONENT_OP5).push(); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
201 |
jdo.waitClosed(); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
202 |
//TODO: wait for no dialog displayed |
36744 | 203 |
} |
204 |
} |
|
205 |
||
206 |
public void showConfirmationDialog(JFrameOperator jfo) throws Exception { |
|
207 |
// Case: Yes option selected |
|
208 |
{ |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
209 |
callADialogAndClose(jfo, CONFIRM_BUTTON, SELECT_AN_OPTION, YES); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
210 |
checkMessage(CONFIRM_YES); |
36744 | 211 |
} |
212 |
||
213 |
// Case: No option selected |
|
214 |
{ |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
215 |
callADialogAndClose(jfo, CONFIRM_BUTTON, SELECT_AN_OPTION, NO); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
216 |
checkMessage(CONFIRM_NO); |
36744 | 217 |
} |
218 |
||
219 |
// Case: Cancel option selected |
|
220 |
{ |
|
39006
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
221 |
callADialogAndClose(jfo, CONFIRM_BUTTON, SELECT_AN_OPTION, CANCEL); |
fd8c3312d043
8157339: Further stabilization for the SwingSet client sanity tests
prr
parents:
37677
diff
changeset
|
222 |
//TODO: wait for no dialog displayed |
36744 | 223 |
} |
224 |
} |
|
225 |
||
226 |
} |