author | jboes |
Fri, 08 Nov 2019 11:15:16 +0000 | |
changeset 59029 | 3786a0962570 |
parent 52128 | 1e0cdaf980f3 |
permissions | -rw-r--r-- |
44131 | 1 |
|
2 |
/* |
|
52085
26c3104c936d
8210055: Enable different look and feel tests in SwingSet3 demo tests
akolarkunnu
parents:
47216
diff
changeset
|
3 |
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
44131 | 4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5 |
* |
|
6 |
* This code is free software; you can redistribute it and/or modify it |
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
|
8 |
* published by the Free Software Foundation. |
|
9 |
* |
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
14 |
* accompanied this code). |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License version |
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
19 |
* |
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
21 |
* or visit www.oracle.com if you need additional information or have any |
|
22 |
* questions. |
|
23 |
*/ |
|
24 |
import org.jtregext.GuiTestListener; |
|
25 |
import com.sun.swingset3.demos.dialog.DialogDemo; |
|
26 |
import static com.sun.swingset3.demos.dialog.DialogDemo.*; |
|
27 |
import java.awt.Dimension; |
|
28 |
import java.awt.Point; |
|
29 |
import javax.swing.JDialog; |
|
52085
26c3104c936d
8210055: Enable different look and feel tests in SwingSet3 demo tests
akolarkunnu
parents:
47216
diff
changeset
|
30 |
import javax.swing.UIManager; |
44131 | 31 |
import static org.testng.AssertJUnit.*; |
32 |
import org.testng.annotations.Test; |
|
33 |
import static org.jemmy2ext.JemmyExt.isIconified; |
|
34 |
import static org.jemmy2ext.JemmyExt.ByClassChooser; |
|
35 |
import org.netbeans.jemmy.ClassReference; |
|
36 |
import org.netbeans.jemmy.ComponentChooser; |
|
37 |
import static org.netbeans.jemmy.WindowWaiter.countWindows; |
|
38 |
import org.netbeans.jemmy.operators.JFrameOperator; |
|
39 |
import org.netbeans.jemmy.operators.JDialogOperator; |
|
40 |
import org.netbeans.jemmy.operators.JLabelOperator; |
|
41 |
import org.netbeans.jemmy.operators.JButtonOperator; |
|
42 |
import org.testng.annotations.Listeners; |
|
43 |
||
44 |
/* |
|
45 |
* @test |
|
46 |
* @key headful |
|
47 |
* @summary Verifies SwingSet3 DialogDemo by checking that separate JDialog is |
|
48 |
* shown, it contains predefined label and no new dialogs are opened |
|
49 |
* when the "Show JDialog..." button is clicked. |
|
50 |
* |
|
51 |
* @library /sanity/client/lib/jemmy/src |
|
52 |
* @library /sanity/client/lib/Extensions/src |
|
53 |
* @library /sanity/client/lib/SwingSet3/src |
|
54 |
* @modules java.desktop |
|
55 |
* java.logging |
|
56 |
* @build org.jemmy2ext.JemmyExt |
|
57 |
* @build com.sun.swingset3.demos.dialog.DialogDemo |
|
52128
1e0cdaf980f3
8211139: Increase timeout value in all tests under jdk/sanity/client/SwingSet/src
akolarkunnu
parents:
52085
diff
changeset
|
58 |
* @run testng/timeout=600 DialogDemoTest |
44131 | 59 |
*/ |
60 |
@Listeners(GuiTestListener.class) |
|
61 |
public class DialogDemoTest { |
|
62 |
||
63 |
private final ComponentChooser jDialogClassChooser = new ByClassChooser(JDialog.class); |
|
64 |
||
52085
26c3104c936d
8210055: Enable different look and feel tests in SwingSet3 demo tests
akolarkunnu
parents:
47216
diff
changeset
|
65 |
@Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class) |
26c3104c936d
8210055: Enable different look and feel tests in SwingSet3 demo tests
akolarkunnu
parents:
47216
diff
changeset
|
66 |
public void test(String lookAndFeel) throws Exception { |
26c3104c936d
8210055: Enable different look and feel tests in SwingSet3 demo tests
akolarkunnu
parents:
47216
diff
changeset
|
67 |
UIManager.setLookAndFeel(lookAndFeel); |
44131 | 68 |
new ClassReference(DialogDemo.class.getCanonicalName()).startApplication(); |
69 |
JFrameOperator mainFrame = new JFrameOperator(DIALOG_DEMO_TITLE); |
|
70 |
JDialogOperator dialog = new JDialogOperator(DIALOG_TITLE); |
|
71 |
JButtonOperator showJDialogButton = new JButtonOperator(mainFrame, SHOW_BUTTON_TITLE); |
|
72 |
initialCheckWithLabel(mainFrame, dialog); |
|
73 |
checkShowDialogButton(dialog, showJDialogButton); |
|
74 |
TestHelpers.checkChangeSize(dialog, new Dimension(dialog.getSize().width * 2, |
|
75 |
dialog.getSize().height * 2)); |
|
76 |
TestHelpers.checkChangeLocation(dialog, new Point(dialog.getLocation().x + 100, |
|
77 |
dialog.getLocation().y + 100)); |
|
78 |
} |
|
79 |
||
80 |
private void initialCheckWithLabel(JFrameOperator frame, JDialogOperator jdo) { |
|
81 |
JLabelOperator label = new JLabelOperator(jdo); |
|
82 |
assertFalse("JFrame is not iconified", isIconified(frame)); |
|
83 |
assertEquals("Only one JDialog is present", 1, |
|
84 |
countWindows(jDialogClassChooser)); |
|
85 |
assertEquals(LABEL_CONTENT, label.getText()); |
|
86 |
} |
|
87 |
||
88 |
private void checkShowDialogButton(JDialogOperator jdo, JButtonOperator jbo) |
|
89 |
throws InterruptedException { |
|
90 |
//Check that the button does not change the number of JDialog |
|
91 |
jbo.push(); |
|
92 |
Thread.sleep(500); |
|
93 |
assertEquals("Only one JDialog is present", 1, |
|
94 |
countWindows(jDialogClassChooser)); |
|
95 |
assertTrue("Check JDialog is visible", jdo.isVisible()); |
|
96 |
jdo.requestClose(); |
|
97 |
jdo.waitClosed(); |
|
98 |
//Check that the button makes the JDialog visible |
|
99 |
//and that 1 jDialog is present. |
|
100 |
jbo.push(); |
|
101 |
jdo.waitComponentVisible(true); |
|
102 |
Thread.sleep(500); |
|
103 |
assertEquals("Only one JDialog is present", 1, |
|
104 |
countWindows(jDialogClassChooser)); |
|
105 |
} |
|
106 |
} |