<AWT Dev> RFR: 8267161 : Write automated test case for JDK-4479161 [v4]
Alexey Ivanov
aivanov at openjdk.java.net
Thu Aug 19 16:42:29 UTC 2021
On Tue, 17 Aug 2021 15:50:56 GMT, lawrence.andrews <github.com+87324768+lawrence-andrew at openjdk.org> wrote:
>> 1) Automated the manual test case.
>> 2) Removed html dependent file
>> 3) Removed javax.swing.JApplet dependent.
>> 4) Test case can be executed independently as well with jtreg framework.
>> 5) Added methods to know that JFrame and Other component is visible before starting the user action via Robot.
>>
>> @shurymury
>
> lawrence.andrews has updated the pull request incrementally with one additional commit since the last revision:
>
> Fixed review comments
Hi Lawrence,
I played a bit with the test and it looks it can be simplified.
First of all, `jTextField.isVisible` is always `true`. So it makes no sense to check its value.
As for the frame, you have `ComponentListener` which decreases the value of `frameVisibleLatch`. Alternatively, you could use `WindowListener` and its `windowOpened`. Once the frame is displayed, the text field is also displayed.
So it looks like the code could be simplified to the following:
SwingUtilities.invokeAndWait( /* create the frame and components */);
robot.waitForIdle();
if (!frameVisibleLatch.await(TIMEOUT, TimeUnit.SECONDS)) {
new RuntimeException("Frame is not visible after " + TIMEOUT + " seconds");
}
robot.waitForIdle();
performMouseAction();
// And so on
What do you think?
I suggest renaming `performMouseAction` to something more specific and descriptive, like `clickTextField` — this way the purpose of the action / method is obvious without opening its code.
-------------
PR: https://git.openjdk.java.net/jdk/pull/5058
More information about the awt-dev
mailing list