Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/swing/JEditorPane/6917744/bug6917744.java
38918 views
1
/*
2
* Copyright (c) 2010, 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
/* @test
25
* @bug 6917744
26
* @summary JScrollPane Page Up/Down keys do not handle correctly html tables with different cells contents
27
* @author Pavel Porvatov
28
* @run main bug6917744
29
*/
30
31
import java.awt.*;
32
import java.awt.event.KeyEvent;
33
import java.io.IOException;
34
import javax.swing.*;
35
36
public class bug6917744 {
37
private static JFrame frame;
38
39
private static JEditorPane editorPane;
40
41
private static JScrollPane scrollPane;
42
43
private static Robot robot;
44
45
public static void main(String[] args) throws Exception {
46
47
robot = new Robot();
48
robot.setAutoDelay(100);
49
50
SwingUtilities.invokeAndWait(new Runnable() {
51
public void run() {
52
frame = new JFrame();
53
54
editorPane = new JEditorPane();
55
56
try {
57
editorPane.setPage(bug6917744.class.getResource("/test.html"));
58
} catch (IOException e) {
59
throw new RuntimeException("HTML resource not found", e);
60
}
61
62
scrollPane = new JScrollPane(editorPane);
63
64
frame.getContentPane().add(scrollPane);
65
frame.setSize(400, 300);
66
frame.setVisible(true);
67
}
68
});
69
70
robot.waitForIdle();
71
72
for (int i = 0; i < 50; i++) {
73
robot.keyPress(KeyEvent.VK_PAGE_DOWN);
74
robot.keyRelease(KeyEvent.VK_PAGE_DOWN);
75
}
76
77
robot.waitForIdle();
78
79
// Check that we at the end of document
80
SwingUtilities.invokeAndWait(new Runnable() {
81
public void run() {
82
BoundedRangeModel model = scrollPane.getVerticalScrollBar().getModel();
83
84
if (model.getValue() + model.getExtent() != model.getMaximum()) {
85
throw new RuntimeException("Invalid HTML position");
86
}
87
}
88
});
89
90
robot.waitForIdle();
91
92
for (int i = 0; i < 50; i++) {
93
robot.keyPress(KeyEvent.VK_PAGE_UP);
94
robot.keyRelease(KeyEvent.VK_PAGE_UP);
95
}
96
97
robot.waitForIdle();
98
99
// Check that we at the begin of document
100
SwingUtilities.invokeAndWait(new Runnable() {
101
public void run() {
102
BoundedRangeModel model = scrollPane.getVerticalScrollBar().getModel();
103
104
if (model.getValue() != model.getMinimum()) {
105
throw new RuntimeException("Invalid HTML position");
106
}
107
108
frame.dispose();
109
}
110
});
111
}
112
}
113
114