On Thu, 6 Nov 2025 13:26:35 GMT, Alexey Ivanov <[email protected]> wrote:

>> test/jdk/javax/swing/JFileChooser/bug4759934.java line 74:
>> 
>>> 72:             robot.mouseMove(dlgBtnLoc.x , dlgBtnLoc.y);
>>> 73:             robot.mousePress(MouseEvent.BUTTON1_DOWN_MASK);
>>> 74:             robot.mouseRelease(MouseEvent.BUTTON1_DOWN_MASK);
>> 
>> https://github.com/openjdk/jdk/pull/27944#discussion_r2490547507
>> 
>>> All the clicks above are to click a button… Should we replace these clicks 
>>> with programmatic clicks?
>> 
>> This is more reliable and quicker than robot.
>> 
>> The only possible issue is to to ensure the updated test still reproduces 
>> the original bug.
>
> I just noticed your comment: 
> https://github.com/openjdk/jdk/pull/27944#discussion_r2496343433
> 
>> I'm for keeping the other clicks as-is (via Robot) since we have reference 
>> to these buttons unlike the cancel button of JFileChooser and this way keep 
>> much of the original test case intact without overly modifying it.
> 
> “…Since we have reference to these buttons,” it's even easier to call 
> `frameBtn.doClick()` and `dlgBtnLoc.doClick()`.
> 
> Once you get the reference to the Cancel button in the file chooser you can 
> also use robot to click the button.
> 
> Using consistently the same method to click the buttons makes the test easier 
> to comprehend.

I referred to the original JBS issue for which this test was created - 
[JDK-4759934](https://bugs.openjdk.org/browse/JDK-4759934). Looks like we can 
use doClick() instead of using Robot for the clicks.

But the problem is that when we use doClick() for frameBtn and dialogBtn, JFC's 
click on Cancel button doesn't happen and the test fails due to timeout. This 
happens on macOS26, I have to test on other platforms.



            SwingUtilities.invokeAndWait(() -> frameBtn.doClick());
            robot.waitForIdle();
            robot.delay(500);

            SwingUtilities.invokeAndWait(() -> dialogBtn.doClick());
            robot.waitForIdle();
            robot.delay(500);

            SwingUtilities.invokeAndWait(() -> {
                JButton cancelBtn = findCancelButton(jfc);
                cancelBtn.doClick();
            });
            robot.delay(500);

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28169#discussion_r2505072844

Reply via email to