8158520: [TEST_BUG] java/awt/PrintJob/PrinterException.java fails on timeout
Reviewed-by: serb
This commit is contained in:
parent
d37fd207e1
commit
db4963b1d3
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -22,7 +22,7 @@
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @bug 7161283
|
||||
* @bug 7161283 8158520
|
||||
* @summary Toolkit.getPrintJob throws NPE if no printer available
|
||||
* @run main PrinterException
|
||||
*/
|
||||
@ -30,9 +30,19 @@ import java.awt.Frame;
|
||||
import java.awt.JobAttributes;
|
||||
import java.awt.PrintJob;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.Robot;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
public class PrinterException {
|
||||
public static void main(String[] args) {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Robot robot = new Robot();
|
||||
Thread t = new Thread (() -> {
|
||||
robot.waitForIdle();
|
||||
robot.delay(2000);
|
||||
robot.keyPress(KeyEvent.VK_ESCAPE);
|
||||
robot.keyRelease(KeyEvent.VK_ESCAPE);
|
||||
});
|
||||
Toolkit tk = Toolkit.getDefaultToolkit();
|
||||
PrintJob pj = null;
|
||||
|
||||
@ -40,12 +50,19 @@ public class PrinterException {
|
||||
JobAttributes ja = new JobAttributes(1,
|
||||
java.awt.JobAttributes.DefaultSelectionType.ALL,
|
||||
JobAttributes.DestinationType.FILE, JobAttributes.DialogType.NATIVE,
|
||||
"", Integer.MAX_VALUE, 1,
|
||||
"filename.ps", Integer.MAX_VALUE, 1,
|
||||
JobAttributes.MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES,
|
||||
pageRange, "", JobAttributes.SidesType.ONE_SIDED);
|
||||
|
||||
Frame testFrame = new Frame("print");
|
||||
if (tk != null) {
|
||||
pj = tk.getPrintJob(testFrame, null, ja, null);
|
||||
try {
|
||||
if (tk != null) {
|
||||
t.start();
|
||||
pj = tk.getPrintJob(testFrame, null, ja, null);
|
||||
}
|
||||
} finally {
|
||||
testFrame.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user