Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sanity/client/SwingSet/src/ComboBoxDemoTest.java
41153 views
1
/*
2
* Copyright (c) 2010, 2018, 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 org.jtregext.GuiTestListener;
25
import com.sun.swingset3.demos.combobox.ComboBoxDemo;
26
import static org.testng.AssertJUnit.*;
27
import javax.swing.UIManager;
28
import org.testng.annotations.Test;
29
import org.netbeans.jemmy.ClassReference;
30
import org.netbeans.jemmy.operators.JComboBoxOperator;
31
import org.netbeans.jemmy.operators.JFrameOperator;
32
import static com.sun.swingset3.demos.combobox.ComboBoxDemo.*;
33
import org.testng.annotations.Listeners;
34
35
/*
36
* @test
37
* @key headful
38
* @summary Verifies ComboBoxes on SwingSet2 ComboBoxDemo page by selecting
39
* each value of each ComboBox.
40
*
41
* @library /sanity/client/lib/jemmy/src
42
* @library /sanity/client/lib/Extensions/src
43
* @library /sanity/client/lib/SwingSet3/src
44
* @modules java.desktop
45
* java.logging
46
* @build org.jemmy2ext.JemmyExt
47
* @build com.sun.swingset3.demos.combobox.ComboBoxDemo
48
* @run testng/timeout=600 ComboBoxDemoTest
49
*/
50
@Listeners(GuiTestListener.class)
51
public class ComboBoxDemoTest {
52
53
private static enum ComboBoxInfo {
54
55
PRESETS("Presets:"),
56
HAIR("Hair:"),
57
EYES_N_NOSE("Eyes & Nose:"),
58
MOUTH("Mouth:");
59
60
private final String comboBoxName;
61
62
private ComboBoxInfo(String comboBoxName) {
63
this.comboBoxName = comboBoxName;
64
}
65
66
}
67
68
@Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)
69
public void test(String lookAndFeel) throws Exception {
70
UIManager.setLookAndFeel(lookAndFeel);
71
new ClassReference(ComboBoxDemo.class.getCanonicalName()).startApplication();
72
73
JFrameOperator frame = new JFrameOperator(DEMO_TITLE);
74
for (ComboBoxInfo comboBoxInfo : ComboBoxInfo.values()) {
75
comboBoxChecker(frame, comboBoxInfo);
76
}
77
}
78
79
private void comboBoxChecker(JFrameOperator jfo, ComboBoxInfo comboBoxInfo) {
80
JComboBoxOperator jcbo = new JComboBoxOperator(jfo, comboBoxInfo.ordinal());
81
for (int i = 0; i < jcbo.getItemCount(); i++) {
82
jcbo.selectItem(i);
83
jcbo.waitItemSelected(i);
84
}
85
}
86
87
}
88
89