On Wed, 18 Jun 2025 07:04:25 GMT, Lukasz Kostyra <lkost...@openjdk.org> wrote:

>> tests/system/src/test/java/test/robot/javafx/stage/StageFocusTest.java line 
>> 110:
>> 
>>> 108:     public void testStageHasFocusAfterShow() {
>>> 109:         Util.sleep(250);
>>> 110:         Util.runAndWait(() -> {
>> 
>> If the stage isn't focused after the sleep the robot's key press might go to 
>> some other app entirely. You might want to add an assert after the sleep 
>> checking that stage.isFocused() returns true.
>
> I checked this and it actually is a bug, `isFocused()` returns true in this 
> case (when the Stage is not focused). We don't capture the failure of 
> `SetForegroundWindow()`, so JFX assumes we are in focus. It doesn't 
> necessarily change the outcome of the test, the key press check will then 
> fail, but it would be good for the flag to also reflect that.
> 
> I'll add the assertion and file a separate issue for that.

I wonder if we could paint the window in some unusual color and check the 
screen pixels to make sure the window is on top, in addition to being focused?

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1804#discussion_r2172400511

Reply via email to