On Mon, 18 Sep 2023 12:16:23 GMT, Alexey Ivanov <[email protected]> wrote:
>> Damon Nguyen has updated the pull request incrementally with one additional
>> commit since the last revision:
>>
>> Add focus to EDT
>
> test/jdk/javax/swing/JTabbedPane/bug4703690.java line 54:
>
>> 52: static volatile boolean focusButtonTwo = false;
>> 53: static volatile boolean switchToTabTwo = false;
>> 54: static volatile boolean focusButtonOne = false;
>
> Assigning the default value is redundant.
>
> Use CountDownLatch instead of boolean values:
>
>
> public void execute() {
> // Create robot
>
> two.requestFocus();
>
> if (!focusButtonTwo.await(1, TimeUnit.SECONDS)) {
> throw new RuntimeException("Button two didn't receive focus");
> }
>
> // Switch to tab two
> // do the click
> if (!switchToTabTwo.await(1, TimeUnit.SECONDS)) {
> throw new RuntimeException("Switching to tab two failed");
> }
>
> // Switch to tab one
> // do the click
> if (!focusButtonOne.await(1, TimeUnit.SECONDS)) {
> throw new RuntimeException("The 'Button 1' button doesn't have
> focus");
> }
> }
>
>
> The test completes much faster because there are no unneeded delays.
The test runs much faster with your changes. Appreciate the advice
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15747#discussion_r1329167895