Skip to content

Commit b3ce6cf

Browse files
committed
Using the PolylinePrintingTest builder
1 parent c247b77 commit b3ce6cf

File tree

2 files changed

+33
-20
lines changed

2 files changed

+33
-20
lines changed

test/jdk/java/awt/print/PrinterJob/PageRanges.java

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@
2121
* questions.
2222
*/
2323

24-
/**
24+
/*
2525
* @test
26-
* @bug 6575331 8320677
26+
* @bug 6575331
2727
* @key printer
2828
* @summary The specified pages should be printed.
2929
* @library /java/awt/regtesthelpers
30+
* @library /test/lib
3031
* @build PassFailJFrame
32+
* @build jtreg.SkippedException
3133
* @run main/manual PageRanges
3234
*/
3335

@@ -36,21 +38,29 @@
3638
import java.awt.print.Printable;
3739
import java.awt.print.PrinterException;
3840
import java.awt.print.PrinterJob;
41+
import jtreg.SkippedException;
3942

4043
public class PageRanges implements Printable {
4144
private static final String INSTRUCTIONS = """
42-
"This test prints two jobs, and tests that the specified range",
43-
"of pages is printed. You must have a printer installed for this test.",
44-
"In the first dialog, select a page range of 2 to 3, and press OK",
45-
"In the second dialog, select ALL, to print all pages (in total 5 pages).",
46-
"Collect the two print outs and confirm the jobs printed correctly",
47-
""";
45+
This test prints two jobs, and tests that the specified range.
46+
of pages is printed. You must have a printer installed for this test.
47+
In the first dialog, select a page range of 2 to 3, and press OK
48+
In the second dialog, select ALL, to print all pages (in total 5 pages).
49+
Collect the two print outs and confirm the jobs printed correctly.
50+
""";
4851

4952
public static void main(String args[]) throws Exception {
50-
PassFailJFrame passFailJFrame = new PassFailJFrame(INSTRUCTIONS);
51-
passFailJFrame.positionTestWindow(null, PassFailJFrame.Position.HORIZONTAL);
52-
5353
PrinterJob job = PrinterJob.getPrinterJob();
54+
if(job == null) {
55+
throw new SkippedException("Printer not configured or available.");
56+
}
57+
58+
PassFailJFrame passFailJFrame = PassFailJFrame.builder()
59+
.instructions(INSTRUCTIONS)
60+
.rows((int) INSTRUCTIONS.lines().count() + 2)
61+
.columns(45)
62+
.build();
63+
5464
if (job.getPrintService() == null) {
5565
System.out.println("No printer available");
5666
PassFailJFrame.forcePass();

test/jdk/java/awt/print/PrinterJob/PolylinePrintingTest.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
* questions.
2222
*/
2323

24-
/**
24+
/*
2525
* @test
26-
* @bug 8041902 8320677
26+
* @bug 8041902
2727
* @key printer
2828
* @summary Test printing of wide poly lines.
2929
* @library /java/awt/regtesthelpers
@@ -43,15 +43,18 @@
4343

4444
public class PolylinePrintingTest implements Printable {
4545
private static final String INSTRUCTIONS = """
46-
"You must have a printer available to perform this test.",
47-
"OK the print dialog, and collect the printed page.",
48-
"Passing test : Output should show two identical chevrons.",
49-
"Failing test : The line joins will appear different."
50-
""";
46+
You must have a printer available to perform this test.
47+
OK the print dialog, and collect the printed page.
48+
Passing test : Output should show two identical chevrons.
49+
Failing test : The line joins will appear different.
50+
""";
5151

5252
public static void main(String[] args) throws Exception {
53-
PassFailJFrame passFailJFrame = new PassFailJFrame(INSTRUCTIONS);
54-
passFailJFrame.positionTestWindow(null, PassFailJFrame.Position.HORIZONTAL);
53+
PassFailJFrame passFailJFrame = PassFailJFrame.builder()
54+
.instructions(INSTRUCTIONS)
55+
.rows((int) INSTRUCTIONS.lines().count() + 2)
56+
.columns(45)
57+
.build();
5558

5659
new PolylinePrintingTest();
5760

0 commit comments

Comments
 (0)