|
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.combobox.ComboBoxDemo; |
|
25 import static org.testng.AssertJUnit.*; |
|
26 import org.testng.annotations.Test; |
|
27 import org.netbeans.jemmy.ClassReference; |
|
28 import org.netbeans.jemmy.operators.JComboBoxOperator; |
|
29 import org.netbeans.jemmy.operators.JFrameOperator; |
|
30 import static com.sun.swingset3.demos.combobox.ComboBoxDemo.*; |
|
31 import static org.jemmy2ext.JemmyExt.captureDebugInfoOnFail; |
|
32 |
|
33 /* |
|
34 * @test |
|
35 * @key headful |
|
36 * @summary Verifies ComboBoxes on SwingSet2 ComboBoxDemo page by selecting |
|
37 * each value of each ComboBox. |
|
38 * |
|
39 * @library /sanity/client/lib/jemmy/src |
|
40 * @library /sanity/client/lib/Jemmy2Ext/src |
|
41 * @library /sanity/client/lib/SwingSet3/src |
|
42 * @build org.jemmy2ext.JemmyExt |
|
43 * @build com.sun.swingset3.demos.combobox.ComboBoxDemo |
|
44 * @run testng ComboBoxDemoTest |
|
45 */ |
|
46 public class ComboBoxDemoTest { |
|
47 |
|
48 private static enum ComboBoxInfo { |
|
49 PRESETS("Presets:"), |
|
50 HAIR("Hair:"), |
|
51 EYES_N_NOSE("Eyes & Nose:"), |
|
52 MOUTH("Mouth:"); |
|
53 |
|
54 private final String comboBoxName; |
|
55 |
|
56 private ComboBoxInfo(String comboBoxName) { |
|
57 this.comboBoxName = comboBoxName; |
|
58 } |
|
59 |
|
60 } |
|
61 |
|
62 @Test |
|
63 public void test() throws Exception { |
|
64 captureDebugInfoOnFail(() -> { |
|
65 new ClassReference(ComboBoxDemo.class.getCanonicalName()).startApplication(); |
|
66 |
|
67 JFrameOperator frame = new JFrameOperator(DEMO_TITLE); |
|
68 for (ComboBoxInfo comboBoxInfo : ComboBoxInfo.values()) { |
|
69 comboBoxChecker(frame, comboBoxInfo); |
|
70 } |
|
71 }); |
|
72 } |
|
73 |
|
74 private void comboBoxChecker(JFrameOperator jfo, ComboBoxInfo comboBoxInfo) { |
|
75 JComboBoxOperator jcbo = new JComboBoxOperator(jfo, comboBoxInfo.ordinal()); |
|
76 for (int i = 0; i < jcbo.getItemCount(); i++) { |
|
77 jcbo.selectItem(i); |
|
78 assertEquals(comboBoxInfo.comboBoxName + " ComboBox SelectedIndex is correct", i, jcbo.getSelectedIndex()); |
|
79 } |
|
80 } |
|
81 |
|
82 } |