|
21 | 21 | * questions. |
22 | 22 | */ |
23 | 23 |
|
24 | | -/** |
| 24 | +/* |
25 | 25 | * @test |
26 | | - * @bug 6575331 8320677 |
| 26 | + * @bug 6575331 |
27 | 27 | * @key printer |
28 | 28 | * @summary The specified pages should be printed. |
29 | 29 | * @library /java/awt/regtesthelpers |
| 30 | + * @library /test/lib |
30 | 31 | * @build PassFailJFrame |
| 32 | + * @build jtreg.SkippedException |
31 | 33 | * @run main/manual PageRanges |
32 | 34 | */ |
33 | 35 |
|
|
36 | 38 | import java.awt.print.Printable; |
37 | 39 | import java.awt.print.PrinterException; |
38 | 40 | import java.awt.print.PrinterJob; |
| 41 | +import jtreg.SkippedException; |
39 | 42 |
|
40 | 43 | public class PageRanges implements Printable { |
41 | 44 | 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 | + """; |
48 | 51 |
|
49 | 52 | public static void main(String args[]) throws Exception { |
50 | | - PassFailJFrame passFailJFrame = new PassFailJFrame(INSTRUCTIONS); |
51 | | - passFailJFrame.positionTestWindow(null, PassFailJFrame.Position.HORIZONTAL); |
52 | | - |
53 | 53 | 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 | + |
54 | 64 | if (job.getPrintService() == null) { |
55 | 65 | System.out.println("No printer available"); |
56 | 66 | PassFailJFrame.forcePass(); |
|
0 commit comments