Skip to content

Commit dd495ab

Browse files
author
Satyen Subramaniam
committed
8354285: Open source Swing tests Batch 3
Backport-of: 4c99489420bd73159eca6bae22442f7b29156c1d
1 parent 7e92579 commit dd495ab

File tree

3 files changed

+253
-0
lines changed

3 files changed

+253
-0
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
* Copyright (c) 1999, 2025, 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 4210461
27+
* @summary Tests that Motif Look & Feel's MenuItem Accelerator Delimiter is
28+
* shown properly
29+
* @library /java/awt/regtesthelpers
30+
* @build PassFailJFrame
31+
* @run main/manual MotifLAFMenuAcceleratorDelimiter
32+
*/
33+
34+
import java.awt.BorderLayout;
35+
import java.awt.event.ActionEvent;
36+
import java.awt.event.KeyEvent;
37+
import javax.swing.JFrame;
38+
import javax.swing.JMenu;
39+
import javax.swing.JMenuBar;
40+
import javax.swing.JMenuItem;
41+
import javax.swing.JPanel;
42+
import javax.swing.KeyStroke;
43+
import javax.swing.UIManager;
44+
45+
public class MotifLAFMenuAcceleratorDelimiter {
46+
public static void main(String[] args) throws Exception {
47+
try {
48+
UIManager.setLookAndFeel(
49+
"com.sun.java.swing.plaf.motif.MotifLookAndFeel");
50+
} catch (Exception e) {
51+
throw new RuntimeException("The Motif LAF failed to instantiate");
52+
}
53+
54+
String INSTRUCTIONS = """
55+
The visual design specification for the Motif LAF asks for
56+
a "+" to delimit the other two entities in a menu item's
57+
accelerator.
58+
59+
As a point of reference, the visual design specifications for the
60+
L&Fs are as follows: JLF/Metal = "-", Mac = "-", Motif = "+",
61+
Windows = "+".
62+
63+
Click on "Menu" of "MotifLAFMenuAcceleratorDelimiter" window,
64+
make sure it shows MenuItem with label "Hi There! ^+H" or
65+
"Hi There! Ctrl+H".
66+
67+
If it shows same label test passed otherwise failed.
68+
""";
69+
PassFailJFrame.builder()
70+
.instructions(INSTRUCTIONS)
71+
.columns(50)
72+
.testUI(MotifLAFMenuAcceleratorDelimiter::initialize)
73+
.build()
74+
.awaitAndCheck();
75+
}
76+
77+
private static JFrame initialize() {
78+
JFrame fr = new JFrame("MotifLAFMenuAcceleratorDelimiter");
79+
JPanel menuPanel = new JPanel();
80+
JMenuBar menuBar = new JMenuBar();
81+
menuBar.setOpaque(true);
82+
JMenu exampleMenu = new JMenu("Menu");
83+
JMenuItem hiMenuItem = new JMenuItem("Hi There!");
84+
hiMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_H,
85+
ActionEvent.CTRL_MASK));
86+
exampleMenu.add(hiMenuItem);
87+
menuBar.add(exampleMenu);
88+
menuPanel.add(menuBar);
89+
90+
fr.setLayout(new BorderLayout());
91+
fr.add(menuPanel, BorderLayout.CENTER);
92+
fr.setSize(250,100);
93+
return fr;
94+
}
95+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright (c) 1999, 2025, 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 4141400
27+
* @summary Tests that the divider of JSplitPane can be moved only by
28+
* dragging its thumb under Motif LAF
29+
* @library /java/awt/regtesthelpers
30+
* @build PassFailJFrame
31+
* @run main/manual bug4141400
32+
*/
33+
34+
import javax.swing.JButton;
35+
import javax.swing.JFrame;
36+
import javax.swing.JSplitPane;
37+
import javax.swing.UIManager;
38+
39+
public class bug4141400 {
40+
public static void main(String[] args) throws Exception {
41+
try {
42+
UIManager.setLookAndFeel(
43+
"com.sun.java.swing.plaf.motif.MotifLookAndFeel");
44+
} catch (Exception e) {
45+
throw new RuntimeException("Failed to set Motif LAF");
46+
}
47+
48+
String INSTRUCTIONS = """
49+
Place mouse cursor somewhere on the split pane divider, but outside
50+
its thumb. Then try to move the divider. It should not move. If it
51+
does not move, the test passes, otherwise it fails.
52+
""";
53+
PassFailJFrame.builder()
54+
.instructions(INSTRUCTIONS)
55+
.columns(70)
56+
.testUI(bug4141400::initialize)
57+
.build()
58+
.awaitAndCheck();
59+
}
60+
61+
private static JFrame initialize() {
62+
JFrame fr = new JFrame("bug4141400");
63+
JSplitPane pane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
64+
true,
65+
new JButton("Button 1"),
66+
new JButton("Button 2"));
67+
fr.add(pane);
68+
fr.setSize(250, 300);
69+
return fr;
70+
}
71+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* Copyright (c) 2003, 2025, 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 4685843
27+
* @requires (os.family == "windows")
28+
* @summary Tests that disabled JCheckBoxMenuItem's are drawn properly in
29+
* Windows LAF
30+
* @library /java/awt/regtesthelpers
31+
* @build PassFailJFrame
32+
* @run main/manual bug4685843
33+
*/
34+
35+
import javax.swing.JCheckBoxMenuItem;
36+
import javax.swing.JFrame;
37+
import javax.swing.JMenu;
38+
import javax.swing.JMenuBar;
39+
import javax.swing.JMenuItem;
40+
import javax.swing.JRadioButtonMenuItem;
41+
import javax.swing.UIManager;
42+
43+
public class bug4685843 {
44+
public static void main(String[] args) throws Exception {
45+
try {
46+
UIManager.setLookAndFeel (
47+
"com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
48+
} catch (Exception e) {
49+
throw new RuntimeException("Failed to set Windows LAF");
50+
}
51+
52+
String INSTRUCTIONS = """
53+
In the window named "bug4685843" open File menu.
54+
If all three disabled items are drawn properly press "Pass".
55+
Otherwise press "Fail".
56+
""";
57+
PassFailJFrame.builder()
58+
.instructions(INSTRUCTIONS)
59+
.columns(35)
60+
.testUI(bug4685843::initialize)
61+
.build()
62+
.awaitAndCheck();
63+
}
64+
65+
private static JFrame initialize() {
66+
JMenuBar jMenuBar = new JMenuBar();
67+
JMenu jMenu = new JMenu("File");
68+
JMenuItem jMenuItem = new JMenuItem("JMenuItem");
69+
JCheckBoxMenuItem jCheckBoxMenuItem =
70+
new JCheckBoxMenuItem("JCheckBoxMenuItem");
71+
JRadioButtonMenuItem jRadioButtonMenuItem =
72+
new JRadioButtonMenuItem("JRadioButtonMenuItem");
73+
74+
jMenuItem.setEnabled(false);
75+
jMenu.add(jMenuItem);
76+
jCheckBoxMenuItem.setEnabled(false);
77+
jMenu.add(jCheckBoxMenuItem);
78+
jRadioButtonMenuItem.setEnabled(false);
79+
jMenu.add(jRadioButtonMenuItem);
80+
jMenuBar.add(jMenu);
81+
82+
JFrame mainFrame = new JFrame("bug4685843");
83+
mainFrame.setJMenuBar(jMenuBar);
84+
mainFrame.setSize(200, 200);
85+
return mainFrame;
86+
}
87+
}

0 commit comments

Comments
 (0)