RFR: 8270609: [TESTBUG] java/awt/print/Dialog/DialogCopies.java does not show instruction [v2]
lawrence.andrews
github.com+87324768+lawrence-andrew at openjdk.java.net
Thu Sep 16 21:35:24 UTC 2021
On Thu, 16 Sep 2021 19:44:48 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
>> 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
>
> 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.
Done
> 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.
If user click the Cancel button the test is passed.
> 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.
Done throwing RunTimeException if number of copies is less than <= 1
> 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.
I will handle the timeout separately.
-------------
PR: https://git.openjdk.java.net/jdk/pull/4850
More information about the client-libs-dev
mailing list