Skip to content

Commit 7b77ad3

Browse files
author
Satyen Subramaniam
committed
8353213: Open source several swing tests batch3
Backport-of: e639cd6a775fabb057b684c70f85b94f84fa5d04
1 parent 6db60fd commit 7b77ad3

File tree

4 files changed

+296
-0
lines changed

4 files changed

+296
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* Copyright (c) 2000, 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 4331515
27+
* @requires (os.family == "windows")
28+
* @summary System menu of an internal frame shouldn't have duplicated items in Win L&F
29+
* @library /java/awt/regtesthelpers
30+
* @build PassFailJFrame
31+
* @run main/manual bug4331515
32+
*/
33+
34+
import javax.swing.JDesktopPane;
35+
import javax.swing.JFrame;
36+
import javax.swing.JInternalFrame;
37+
import javax.swing.UIManager;
38+
39+
public class bug4331515 {
40+
static final String INSTRUCTIONS = """
41+
Open the system menu of internal frame "JIF" placed in the frame "Test".
42+
If this menu contains duplicates of some items then test FAILS, else
43+
test PASSES.
44+
""";
45+
46+
public static void main(String[] args) throws Exception {
47+
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
48+
PassFailJFrame.builder()
49+
.title("bug4331515 Test Instructions")
50+
.instructions(INSTRUCTIONS)
51+
.columns(40)
52+
.testUI(bug4331515::createUI)
53+
.build()
54+
.awaitAndCheck();
55+
}
56+
57+
static JFrame createUI() {
58+
JFrame fr = new JFrame("System Menu in JIF Test");
59+
JDesktopPane dp = new JDesktopPane();
60+
fr.setContentPane(dp);
61+
JInternalFrame jif = new JInternalFrame("JIF", true, true, true, true);
62+
dp.add(jif);
63+
jif.setBounds(20, 20, 120, 100);
64+
jif.setVisible(true);
65+
fr.setSize(200, 200);
66+
return fr;
67+
}
68+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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 4165874
27+
* @summary Adds a MouseListener to the splitpane divider.
28+
* @library /java/awt/regtesthelpers
29+
* @build PassFailJFrame
30+
* @run main/manual AddMouseListenerTest
31+
*/
32+
33+
import java.awt.Component;
34+
import java.awt.event.MouseAdapter;
35+
36+
import javax.swing.JFrame;
37+
import javax.swing.JSplitPane;
38+
39+
public class AddMouseListenerTest {
40+
static final String INSTRUCTIONS = """
41+
Try dragging the split pane divider, if you can, click PASS,
42+
else click FAIL.
43+
""";
44+
45+
public static void main(String[] args) throws Exception {
46+
PassFailJFrame.builder()
47+
.title("AddMouseListenerTest Test Instructions")
48+
.instructions(INSTRUCTIONS)
49+
.columns(40)
50+
.testUI(AddMouseListenerTest::createUI)
51+
.build()
52+
.awaitAndCheck();
53+
}
54+
55+
static JFrame createUI() {
56+
JFrame f = new JFrame("JSplitPane With ActionListener Test");
57+
JSplitPane sp = new JSplitPane();
58+
59+
sp.setContinuousLayout(true);
60+
Component[] children = sp.getComponents();
61+
for (int counter = children.length - 1; counter >= 0; counter--) {
62+
children[counter].addMouseListener(new MouseAdapter() {});
63+
}
64+
f.getContentPane().add(sp);
65+
f.setSize(400, 400);
66+
return f;
67+
}
68+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* Copyright (c) 2001, 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 4305622
27+
* @summary MetalToolBarUI.installUI invokeLater causes flickering
28+
* @library /java/awt/regtesthelpers
29+
* @build PassFailJFrame
30+
* @run main/manual bug4305622
31+
*/
32+
33+
import java.awt.BorderLayout;
34+
import java.awt.Color;
35+
36+
import javax.swing.JButton;
37+
import javax.swing.JFrame;
38+
import javax.swing.JToolBar;
39+
import javax.swing.UIManager;
40+
import javax.swing.border.LineBorder;
41+
42+
43+
public class bug4305622 {
44+
private static JFrame fr;
45+
static final String INSTRUCTIONS = """
46+
Press button "Create ToolBar" at frame "Create ToolBar Test".
47+
If you see any flickering during creating of toolbar
48+
then the test FAILS, otherwise the test PASSES.
49+
""";
50+
51+
public static void main(String[] args) throws Exception {
52+
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
53+
PassFailJFrame.builder()
54+
.title("bug4305622 Test Instructions")
55+
.instructions(INSTRUCTIONS)
56+
.columns(40)
57+
.testUI(bug4305622::createUI)
58+
.build()
59+
.awaitAndCheck();
60+
}
61+
62+
static JFrame createUI() {
63+
fr = new JFrame("Create ToolBar Test");
64+
JButton button = new JButton("Create ToolBar");
65+
button.addActionListener(ae -> addToolBar());
66+
fr.add(button, BorderLayout.SOUTH);
67+
fr.setSize(400, 400);
68+
return fr;
69+
}
70+
71+
static void addToolBar() {
72+
fr.repaint();
73+
fr.revalidate();
74+
JToolBar toolbar = new JToolBar();
75+
76+
JButton btn = new JButton("Button 1");
77+
btn.setBorder(new LineBorder(Color.red, 30));
78+
toolbar.add(btn);
79+
80+
btn = new JButton("Button 2");
81+
btn.setBorder(new LineBorder(Color.red, 30));
82+
toolbar.add(btn);
83+
84+
toolbar.updateUI();
85+
fr.add(toolbar, BorderLayout.NORTH);
86+
}
87+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright (c) 2000, 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 4331392
27+
* @summary Tests if BasicToolBarUI has bogus logic that prevents vertical
28+
* toolbars from docking
29+
* @library /java/awt/regtesthelpers
30+
* @build PassFailJFrame
31+
* @run main/manual bug4331392
32+
*/
33+
34+
import java.awt.BorderLayout;
35+
import java.awt.Container;
36+
37+
import javax.swing.JButton;
38+
import javax.swing.JFrame;
39+
import javax.swing.JToolBar;
40+
41+
public class bug4331392 {
42+
static final String INSTRUCTIONS = """
43+
Try to dock the toolbar across all the edges of frame. If you succeed,
44+
then the test PASSES. Otherwise, it FAILS.
45+
""";
46+
47+
public static void main(String[] args) throws Exception {
48+
PassFailJFrame.builder()
49+
.title("bug4331392 Test Instructions")
50+
.instructions(INSTRUCTIONS)
51+
.columns(40)
52+
.testUI(bug4331392::createUI)
53+
.build()
54+
.awaitAndCheck();
55+
}
56+
57+
static JFrame createUI() {
58+
JFrame frame = new JFrame("JToolBar Docking Test");
59+
Container c = frame.getContentPane();
60+
61+
JToolBar tbar = new JToolBar(JToolBar.VERTICAL);
62+
63+
tbar.add(new JButton("A"));
64+
tbar.add(new JButton("B"));
65+
tbar.add(new JButton("C"));
66+
67+
JButton b = new JButton("Hello");
68+
c.add(b, BorderLayout.CENTER);
69+
c.add(tbar, BorderLayout.EAST);
70+
frame.setSize(300, 300);
71+
return frame;
72+
}
73+
}

0 commit comments

Comments
 (0)