Skip to content

Commit 42acf50

Browse files
committed
8284524: Create an automated test for JDK-4422362
Backport-of: b9de0a7556f7be2c6afc6bb41bfa0339b639ff88
1 parent 708968e commit 42acf50

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright (c) 2003, 2022, 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+
/*
25+
* @test
26+
* @bug 4422362
27+
* @summary Wrong Max Accessible Value with BoundedRangeModel components
28+
* @run main MaximumAccessibleValueTest
29+
*/
30+
31+
import javax.swing.JProgressBar;
32+
import javax.swing.JScrollBar;
33+
import javax.swing.JSlider;
34+
import javax.swing.SwingUtilities;
35+
36+
public class MaximumAccessibleValueTest {
37+
38+
public static void doTest() {
39+
40+
JScrollBar jScrollBar = new JScrollBar();
41+
JProgressBar jProgressBar = new JProgressBar();
42+
JSlider jSlider = new JSlider();
43+
44+
if (((Integer) jScrollBar.getAccessibleContext().getAccessibleValue()
45+
.getMaximumAccessibleValue()).intValue() != jScrollBar.getMaximum()
46+
- jScrollBar.getVisibleAmount()) {
47+
throw new RuntimeException(
48+
"Wrong MaximumAccessibleValue returned by JScrollBar");
49+
}
50+
51+
if (((Integer) jProgressBar.getAccessibleContext().getAccessibleValue()
52+
.getMaximumAccessibleValue().intValue()) != (jProgressBar
53+
.getMaximum() - jProgressBar.getModel().getExtent())) {
54+
throw new RuntimeException(
55+
"Wrong MaximumAccessibleValue returned by JProgressBar");
56+
}
57+
58+
if (((Integer) jSlider.getAccessibleContext().getAccessibleValue()
59+
.getMaximumAccessibleValue()).intValue() != jSlider.getMaximum()
60+
- jSlider.getModel().getExtent()) {
61+
throw new RuntimeException(
62+
"Wrong MaximumAccessibleValue returned by JSlider");
63+
}
64+
}
65+
66+
public static void main(String[] args) throws Exception {
67+
SwingUtilities.invokeAndWait(() -> doTest());
68+
System.out.println("Test Passed");
69+
}
70+
}
71+

0 commit comments

Comments
 (0)