|
1 /* |
|
2 * Copyright (c) 2011, 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.window.WindowDemo; |
|
25 import static com.sun.swingset3.demos.window.WindowDemo.*; |
|
26 import static org.jemmy2ext.JemmyExt.*; |
|
27 import static org.testng.AssertJUnit.*; |
|
28 import org.testng.annotations.Test; |
|
29 import org.netbeans.jemmy.ClassReference; |
|
30 import org.netbeans.jemmy.operators.JButtonOperator; |
|
31 import org.netbeans.jemmy.operators.JFrameOperator; |
|
32 import org.netbeans.jemmy.operators.JLabelOperator; |
|
33 import org.netbeans.jemmy.operators.WindowOperator; |
|
34 |
|
35 /* |
|
36 * @test |
|
37 * @key headful |
|
38 * @summary Verifies SwingSet3 WindowDemo by checking that separate JWindow is |
|
39 * shown, it contains predefined label and no new windows are opened |
|
40 * when the "Show JWindow..." button is clicked. |
|
41 * |
|
42 * @library /sanity/client/lib/jemmy/src |
|
43 * @library /sanity/client/lib/Jemmy2Ext/src |
|
44 * @library /sanity/client/lib/SwingSet3/src |
|
45 * @build org.jemmy2ext.JemmyExt |
|
46 * @build com.sun.swingset3.demos.window.WindowDemo |
|
47 * @run testng WindowDemoTest |
|
48 */ |
|
49 public class WindowDemoTest { |
|
50 |
|
51 @Test |
|
52 public void test() throws Exception { |
|
53 captureDebugInfoOnFail(() -> { |
|
54 new ClassReference(WindowDemo.class.getCanonicalName()).startApplication(); |
|
55 |
|
56 JFrameOperator frame = new JFrameOperator(); |
|
57 |
|
58 assertEquals("Only one JWindow is shown", 1, getJWindowCount()); |
|
59 |
|
60 WindowOperator window = new WindowOperator(getJWindow()); |
|
61 |
|
62 assertTrue("JFrame is showing", frame.isShowing()); |
|
63 assertFalse("JFrame is not iconified", isIconified(frame)); |
|
64 assertTrue("JWindow is showing", window.isShowing()); |
|
65 |
|
66 final String labelText = I_HAVE_NO_SYSTEM_BORDER; |
|
67 JLabelOperator jLabelOperator = new JLabelOperator(window, labelText); |
|
68 assertEquals("JWindow contains the label with corresponding text", labelText, jLabelOperator.getText()); |
|
69 |
|
70 new JButtonOperator(frame, SHOW_J_WINDOW).push(); |
|
71 |
|
72 assertEquals("Only one JWindow is shown", 1, getJWindowCount()); |
|
73 }); |
|
74 } |
|
75 |
|
76 } |