|
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.scrollpane.ScrollPaneDemo; |
|
25 import static com.sun.swingset3.demos.scrollpane.ScrollPaneDemo.DEMO_TITLE; |
|
26 import static org.testng.AssertJUnit.*; |
|
27 import org.testng.annotations.Test; |
|
28 import org.netbeans.jemmy.ClassReference; |
|
29 import org.netbeans.jemmy.operators.JFrameOperator; |
|
30 import org.netbeans.jemmy.operators.JScrollPaneOperator; |
|
31 import static org.jemmy2ext.JemmyExt.captureDebugInfoOnFail; |
|
32 |
|
33 /* |
|
34 * @test |
|
35 * @key headful |
|
36 * @summary Verifies SwingSet3 ScrollPaneDemo by scrolling to bottom, to top, |
|
37 * to left and to right and checking scroll bar values. |
|
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.scrollpane.ScrollPaneDemo |
|
44 * @run testng ScrollPaneDemoTest |
|
45 */ |
|
46 public class ScrollPaneDemoTest { |
|
47 |
|
48 @Test |
|
49 public void test() throws Exception { |
|
50 captureDebugInfoOnFail(() -> { |
|
51 new ClassReference(ScrollPaneDemo.class.getName()).startApplication(); |
|
52 |
|
53 JFrameOperator frame = new JFrameOperator(DEMO_TITLE); |
|
54 JScrollPaneOperator jspo = new JScrollPaneOperator(frame); |
|
55 |
|
56 // Set initial scrollbar positions |
|
57 int initialVerticalValue = jspo.getVerticalScrollBar().getValue(); |
|
58 int initialHorizontalValue = jspo.getHorizontalScrollBar().getValue(); |
|
59 |
|
60 System.out.println("Initial Vertical Value = " + jspo.getVerticalScrollBar().getValue()); |
|
61 System.out.println("Initial HoriZontal Value = " + jspo.getHorizontalScrollBar().getValue()); |
|
62 |
|
63 // Check scroll to Bottom |
|
64 { |
|
65 jspo.scrollToBottom(); |
|
66 int currentValue = jspo.getVerticalScrollBar().getValue(); |
|
67 System.out.println("Final Value = " + currentValue); |
|
68 assertTrue("Scroll to Bottom of Pane " |
|
69 + "(initialVerticalValue, actual value: " + initialVerticalValue + " " |
|
70 + "< currentValue, actual value = " + currentValue + ")", |
|
71 initialVerticalValue < currentValue); |
|
72 } |
|
73 |
|
74 // Check scroll to Top |
|
75 { |
|
76 jspo.scrollToTop(); |
|
77 int currentValue = jspo.getVerticalScrollBar().getValue(); |
|
78 System.out.println("Top Scroll Final Value = " + currentValue); |
|
79 assertTrue("Scroll to Top of Pane " |
|
80 + "(initialVerticalValue, actual value: " + initialVerticalValue + " " |
|
81 + "> currentValue, actual value = " + currentValue + ")", |
|
82 initialVerticalValue > currentValue); |
|
83 } |
|
84 |
|
85 // Check scroll to Left |
|
86 { |
|
87 jspo.scrollToLeft(); |
|
88 int currentValue = jspo.getHorizontalScrollBar().getValue(); |
|
89 System.out.println("Scroll to Left Final Value = " + currentValue); |
|
90 assertTrue("Scroll to Left of Pane " |
|
91 + "(initialHorizontalValue, actual value: " + initialHorizontalValue + " " |
|
92 + "> currentValue, actual value = " + currentValue + ")", |
|
93 initialHorizontalValue > currentValue); |
|
94 } |
|
95 |
|
96 // Check scroll to Right |
|
97 { |
|
98 jspo.scrollToRight(); |
|
99 int currentValue = jspo.getHorizontalScrollBar().getValue(); |
|
100 System.out.println("Scroll to Right Final Value = " + currentValue); |
|
101 assertTrue("Scroll to Right of Pane " |
|
102 + "(initialHorizontalValue, actual value: " + initialHorizontalValue + " " |
|
103 + "< currentValue, actual value = " + currentValue + ")", |
|
104 initialHorizontalValue < currentValue); |
|
105 } |
|
106 }); |
|
107 } |
|
108 |
|
109 } |