On Mon, 5 Dec 2022 21:03:09 GMT, Thiago Milczarek Sayao <tsa...@openjdk.org> 
wrote:

>> Simple fix to not requestFocus() on scene change.
>> 
>> The attached bug sample shows that the TextField focused on the scene 
>> remains focused when the scene comes back.
>
> Thiago Milczarek Sayao has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Add new line

Suggesting minor changes in the test.

tests/system/src/test/java/test/robot/javafx/scene/SceneChangeShouldNotFocusStageTest.java
 line 61:

> 59:     public static void initFX() throws Exception {
> 60:         new Thread(() -> Application.launch(TestApp.class, (String[]) 
> null)).start();
> 61:         waitForLatch(startupLatch, 10, "FX runtime failed to start.");

With the changes made in #950, we have a new pattern for launch and exit.
These two lines would be now:  `Util.launch(startupLatch, TestApp.class);`
and similarly exit method would be : `Util.shutdown(stage);`
and `waitForLatch` method can be removed.

tests/system/src/test/java/test/robot/javafx/scene/SceneChangeShouldNotFocusStageTest.java
 line 80:

> 78:             tl.setCycleCount(Animation.INDEFINITE);
> 79:             tl.getKeyFrames().addAll(new KeyFrame(Duration.millis(0), e 
> -> stage.setScene(scene1)),
> 80:                     new KeyFrame(Duration.millis(200), e -> 
> stage.setScene(scene2)));

With `Duration.millis(0)`, JavaFX gets no time to switch to `scene2`. We should 
allow some time for `stage.setScene(scene2)` to be processed.
We can observe the behavior by commenting two lines 55 and 88, and adding a 
delay `Util.sleep(10000)` in `exit()` method : The `scene2` will never be seen 
on Window.
I would recommend to change `Duration.millis(0)` to `Duration.millis(100)` OR 
any other duration with sufficient gap between the two Frames.

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

Changes requested by arapte (Reviewer).

PR: https://git.openjdk.org/jfx/pull/940

Reply via email to