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