Skip to content

Commit db01fcd

Browse files
author
Damon Nguyen
committedMar 26, 2024
8328827: Convert java/awt/print/PrinterJob/PrinterDialogsModalityTest/PrinterDialogsModalityTest.html applet test to main
Reviewed-by: prr, tr
1 parent 89e0889 commit db01fcd

File tree

3 files changed

+93
-305
lines changed

3 files changed

+93
-305
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
* Copyright (c) 2007, 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.Button;
25+
import java.awt.FlowLayout;
26+
import java.awt.print.PageFormat;
27+
import java.awt.print.PrinterJob;
28+
29+
import javax.swing.JFrame;
30+
31+
/*
32+
* @test
33+
* @bug 4784285 4785920
34+
* @key printer
35+
* @library /java/awt/regtesthelpers
36+
* @build PassFailJFrame
37+
* @summary check whether Print- and Page- dialogs are modal and correct window
38+
* activated after their closing
39+
* @run main/manual PrinterDialogsModalityTest
40+
*/
41+
42+
public class PrinterDialogsModalityTest {
43+
private static final String INSTRUCTIONS =
44+
"""
45+
After the test starts, you will see a frame titled "Test Frame"
46+
with two buttons: "Page Dialog" and "Print Dialog".
47+
1. Make the "Test Frame" active by clicking on title.
48+
2. Press "Page Dialog" button and a page dialog should popup.
49+
3. Make sure page dialog is modal. (Modal in this case means that
50+
it blocks the user from interacting with other windows in the
51+
same application, like this instruction window. You may still be
52+
able to interact with unrelated applications on the desktop.).
53+
4. Close the dialog (either cancel it or press ok).
54+
5. Make sure the frame is still active.
55+
6. Press "Print Dialog" button, print dialog should popup.
56+
7. Repeat steps 3-5.
57+
58+
If you are able to execute all steps successfully then the test
59+
passes, otherwise it fails.
60+
""";
61+
62+
public static void main(String[] args) throws Exception {
63+
PassFailJFrame
64+
.builder()
65+
.title("PrinterDialogsModalityTest Test Instructions")
66+
.instructions(INSTRUCTIONS)
67+
.rows((int) INSTRUCTIONS.lines().count() + 2)
68+
.columns(40)
69+
.testUI(PrinterDialogsModalityTest::createAndShowGUI)
70+
.build()
71+
.awaitAndCheck();
72+
}
73+
74+
public static JFrame createAndShowGUI() {
75+
JFrame frame = new JFrame("Test Frame");
76+
frame.setLayout(new FlowLayout());
77+
78+
Button page = new Button("Page Dialog");
79+
page.addActionListener(e -> {
80+
PrinterJob prnJob = PrinterJob.getPrinterJob();
81+
prnJob.pageDialog(new PageFormat());
82+
});
83+
Button print = new Button("Print Dialog");
84+
print.addActionListener(e -> {
85+
PrinterJob prnJob = PrinterJob.getPrinterJob();
86+
prnJob.printDialog();
87+
});
88+
frame.add(page);
89+
frame.add(print);
90+
frame.pack();
91+
return frame;
92+
}
93+
}

‎test/jdk/java/awt/print/PrinterJob/PrinterDialogsModalityTest/PrinterDialogsModalityTest.html

-43
This file was deleted.

‎test/jdk/java/awt/print/PrinterJob/PrinterDialogsModalityTest/PrinterDialogsModalityTest.java

-262
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.