Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sanity/client/SwingSet/src/ScrollPaneDemoTest.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.scrollpane.ScrollPaneDemo;
26
import static com.sun.swingset3.demos.scrollpane.ScrollPaneDemo.DEMO_TITLE;
27
import static org.testng.AssertJUnit.*;
28
import javax.swing.UIManager;
29
import org.testng.annotations.Test;
30
import org.netbeans.jemmy.ClassReference;
31
import org.netbeans.jemmy.operators.JFrameOperator;
32
import org.netbeans.jemmy.operators.JScrollPaneOperator;
33
import org.testng.annotations.Listeners;
34
35
/*
36
* @test
37
* @key headful
38
* @summary Verifies SwingSet3 ScrollPaneDemo by scrolling to bottom, to top,
39
* to left and to right and checking scroll bar values.
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.scrollpane.ScrollPaneDemo
48
* @run testng/timeout=600 ScrollPaneDemoTest
49
*/
50
@Listeners(GuiTestListener.class)
51
public class ScrollPaneDemoTest {
52
53
@Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)
54
public void test(String lookAndFeel) throws Exception {
55
UIManager.setLookAndFeel(lookAndFeel);
56
57
new ClassReference(ScrollPaneDemo.class.getName()).startApplication();
58
59
JFrameOperator frame = new JFrameOperator(DEMO_TITLE);
60
JScrollPaneOperator jspo = new JScrollPaneOperator(frame);
61
62
// Set initial scrollbar positions
63
int initialVerticalValue = jspo.getVerticalScrollBar().getValue();
64
int initialHorizontalValue = jspo.getHorizontalScrollBar().getValue();
65
66
System.out.println("Initial Vertical Value = " + jspo.getVerticalScrollBar().getValue());
67
System.out.println("Initial HoriZontal Value = " + jspo.getHorizontalScrollBar().getValue());
68
69
// Check scroll to Bottom
70
{
71
jspo.scrollToBottom();
72
int currentValue = jspo.getVerticalScrollBar().getValue();
73
System.out.println("Final Value = " + currentValue);
74
assertTrue("Scroll to Bottom of Pane "
75
+ "(initialVerticalValue, actual value: " + initialVerticalValue + " "
76
+ "< currentValue, actual value = " + currentValue + ")",
77
initialVerticalValue < currentValue);
78
}
79
80
// Check scroll to Top
81
{
82
jspo.scrollToTop();
83
int currentValue = jspo.getVerticalScrollBar().getValue();
84
System.out.println("Top Scroll Final Value = " + currentValue);
85
assertTrue("Scroll to Top of Pane "
86
+ "(initialVerticalValue, actual value: " + initialVerticalValue + " "
87
+ "> currentValue, actual value = " + currentValue + ")",
88
initialVerticalValue > currentValue);
89
}
90
91
// Check scroll to Left
92
{
93
jspo.scrollToLeft();
94
int currentValue = jspo.getHorizontalScrollBar().getValue();
95
System.out.println("Scroll to Left Final Value = " + currentValue);
96
assertTrue("Scroll to Left of Pane "
97
+ "(initialHorizontalValue, actual value: " + initialHorizontalValue + " "
98
+ "> currentValue, actual value = " + currentValue + ")",
99
initialHorizontalValue > currentValue);
100
}
101
102
// Check scroll to Right
103
{
104
jspo.scrollToRight();
105
int currentValue = jspo.getHorizontalScrollBar().getValue();
106
System.out.println("Scroll to Right Final Value = " + currentValue);
107
assertTrue("Scroll to Right of Pane "
108
+ "(initialHorizontalValue, actual value: " + initialHorizontalValue + " "
109
+ "< currentValue, actual value = " + currentValue + ")",
110
initialHorizontalValue < currentValue);
111
}
112
}
113
114
}
115
116