On Wed, 15 Sep 2021 20:23:24 GMT, lawrence.andrews 
<[email protected]> wrote:

>> 1) When the test is executed via jtreg user can see only print dialog with 
>> no instruction to the user. User has to see the test case to see the 
>> instruction and perform the test . 
>> 2) With this fix User is instructed what he/she has to do with the print 
>> dialog.
>> 3) I have added both success instruction as well as failure instruction.
>> 
>> @shurymury
>
> lawrence.andrews has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Close instruction frame if OK/Cancel button is pressed

Changes requested by aivanov (Reviewer).

test/jdk/java/awt/print/Dialog/DialogCopies.java line 58:

> 56:         instructionTextArea.setEditable(false);
> 57:         mainControlPanel.add(instructionTextArea, BorderLayout.CENTER);
> 58:         instructionFrame.add(mainControlPanel);

The panel is not needed here, there's only one component in the panel, so

instructionFrame.add(instructionTextArea, BorderLayout.CENTER);

will do just fine.

You can set the text to `TextArea` in its constructor.

test/jdk/java/awt/print/Dialog/DialogCopies.java line 80:

> 78:         } else {
> 79:             System.out.println("User has selected Cancel button on the 
> PrintDialog");
> 80:         }

I suggest treating *Cancel* button as a pass. It will handle the case where the 
user does not have a real printer but has virtual printers such as *Microsoft 
Print to PDF* or *Microsoft XPS Document Writer*. Neither allows setting 
*Copies* to anything but 1. If you increase the number of copies and click OK, 
an error message is displayed. Yet clicking OK with number of copies set 1 will 
fail the test.

To avoid such a situation, clicking *Cancel* should be treated a passed test or 
rather a skipped one.

test/jdk/java/awt/print/Dialog/DialogCopies.java line 84:

> 82:         if (copies <= 1) {
> 83:             testResult = false;
> 84:             System.out.println("Expected the number of copies to be more 
> than 1 but got " + copies);

At this time, your code is synchronous and is executed on main thread only, 
therefore you can `throw new RuntimeException` with an error message here 
without using the `testResult` flag.

test/jdk/java/awt/print/Dialog/DialogCopies.java line 99:

> 97:         if (!countDownLatch.await(5, TimeUnit.MINUTES)) {
> 98:             throw new RuntimeException("Timeout : No action was performed 
> on the test UI.");
> 99:         }

`job.printDialog()`  is a blocking call. This line will be reached only after 
the Print dialog is dismissed, thus the test will never time out by the latch.

The original version of the test didn't support timing out, so the updated 
version may skip this too. You may submit a new bug to implement timeout 
support.

-------------

PR: https://git.openjdk.java.net/jdk/pull/4850

Reply via email to