Skip to content

Commit 6071346

Browse files
author
Alisen Chung
committed
8339879: Open some dialog awt tests
Reviewed-by: honkar, prr
1 parent a8a8b2d commit 6071346

File tree

4 files changed

+571
-0
lines changed

4 files changed

+571
-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, 2024, 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 java.awt.Dialog;
25+
import java.awt.Frame;
26+
27+
/*
28+
* @test
29+
* @bug 4964237
30+
* @requires (os.family == "windows")
31+
* @summary Win: Changing theme changes java dialogs title icon
32+
* @library /java/awt/regtesthelpers
33+
* @build PassFailJFrame
34+
* @run main/manual DefaultIconTest
35+
*/
36+
37+
public class DefaultIconTest {
38+
static String instructions = """
39+
This test shows frame and two dialogs
40+
Change windows theme. Resizable dialog should retain default icon
41+
Non-resizable dialog should retain no icon
42+
Press PASS if icons look correct, FAIL otherwise
43+
""";
44+
45+
public static void main(String[] args) throws Exception {
46+
PassFailJFrame.builder()
47+
.title("ShownModalDialogSerializationTest Instructions")
48+
.instructions(instructions)
49+
.testTimeOut(5)
50+
.rows(10)
51+
.columns(35)
52+
.testUI(DefaultIconTest::createGUIs)
53+
.build()
54+
.awaitAndCheck();
55+
}
56+
57+
public static Frame createGUIs() {
58+
Frame f = new Frame("DefaultIconTest");
59+
f.setSize(200, 100);
60+
Dialog d1 = new Dialog(f, "Resizable Dialog, should show default icon");
61+
d1.setSize(200, 100);
62+
d1.setVisible(true);
63+
d1.setLocation(0, 150);
64+
Dialog d2 = new Dialog(f, "Non-resizable dialog, should have no icon");
65+
d2.setSize(200, 100);
66+
d2.setVisible(true);
67+
d2.setResizable(false);
68+
d2.setLocation(0, 300);
69+
return f;
70+
}
71+
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*
2+
* Copyright (c) 2003, 2024, 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 java.awt.Dialog;
25+
import java.awt.Dimension;
26+
import java.awt.Frame;
27+
import java.awt.event.ComponentEvent;
28+
import java.awt.event.ComponentListener;
29+
30+
/*
31+
* @test
32+
* @bug 4912551
33+
* @summary Checks that with resizable set to false before show()
34+
* dialog can not be resized.
35+
* @library /java/awt/regtesthelpers
36+
* @build PassFailJFrame
37+
* @run main/manual DialogInitialResizability
38+
*/
39+
40+
public class DialogInitialResizability {
41+
static String instructions = """
42+
When this test is run a dialog will display (setResizable Test).
43+
This dialog should not be resizable.
44+
45+
Additionally ensure that there are NO componentResized events in the log section.
46+
If the above conditions are true, then Press PASS else FAIL.
47+
""";
48+
49+
private static final Dimension INITIAL_SIZE = new Dimension(400, 150);
50+
public static void main(String[] args) throws Exception {
51+
PassFailJFrame.builder()
52+
.title("DialogInitialResizability")
53+
.instructions(instructions)
54+
.testTimeOut(5)
55+
.rows((int) instructions.lines().count() + 2)
56+
.columns(40)
57+
.testUI(DialogInitialResizability::createGUI)
58+
.logArea()
59+
.build()
60+
.awaitAndCheck();
61+
}
62+
63+
public static MyDialog createGUI() {
64+
Frame f = new Frame("invisible dialog owner");
65+
66+
MyDialog ld = new MyDialog(f);
67+
ld.setBounds(100, 100, INITIAL_SIZE.width, INITIAL_SIZE.height);
68+
ld.setResizable(false);
69+
70+
PassFailJFrame.log("Dialog isResizable is set to: " + ld.isResizable());
71+
PassFailJFrame.log("Dialog Initial Size " + ld.getSize());
72+
return ld;
73+
}
74+
75+
private static class MyDialog extends Dialog implements ComponentListener {
76+
public MyDialog(Frame f) {
77+
super(f, "setResizable test", false);
78+
this.addComponentListener(this);
79+
}
80+
81+
public void componentResized(ComponentEvent e) {
82+
if (!e.getComponent().getSize().equals(INITIAL_SIZE)) {
83+
PassFailJFrame.log("Component Resized. Test Failed!!");
84+
}
85+
}
86+
87+
public void componentMoved(ComponentEvent e) {
88+
}
89+
90+
public void componentShown(ComponentEvent e) {
91+
}
92+
93+
public void componentHidden(ComponentEvent e) {
94+
}
95+
}
96+
}

0 commit comments

Comments
 (0)