On Tue, 14 Apr 2020 10:47:55 GMT, Florian Kirmaier <fkirma...@openjdk.org> wrote:
>> tests/system/src/test/java/test/javafx/stage/FocusedWindowTest.java line 77: >> >>> 76: Platform.runLater(() -> stage.close()); >>> 77: } >>> 78: >> >> Looks like the primary `stage` is not required for actual test, and this >> block is only used to initialize JavaFX >> runtime. Please check if it can be replaced by below block >> ``` >> @BeforeClass >> public static void initFX() throws Exception { >> startupLatch = new CountDownLatch(1); >> Platform.startup(startupLatch::countDown); >> Assert.assertTrue("Timeout waiting for FX runtime to start", >> startupLatch.await(15, TimeUnit.MILLISECONDS)); >> } > > This version doesn't work for me. > With this change, I get the following error: > test.javafx.stage.FocusedWindowTest > testLeak FAILED > junit.framework.AssertionFailedError: Exceeded timeout limit of 10000 msec > at test.util.Util.runAndWait(Util.java:163) > at test.util.Util.runAndWait(Util.java:134) > at > test.javafx.stage.FocusedWindowTest.testLeak(FocusedWindowTest.java:82) This is happening because after the last stage is closed JavaFX runtime shuts down implicitly unless specified otherwise using `Platform.setImplicitExit(false);`. So `initFX()` should look as, ``` @BeforeClass public static void initFX() throws Exception { startupLatch = new CountDownLatch(1); Platform.startup(startupLatch::countDown); Platform.setImplicitExit(false); Assert.assertTrue("Timeout waiting for FX runtime to start", startupLatch.await(15, TimeUnit.MILLISECONDS)); } >> tests/system/src/test/java/test/javafx/stage/FocusedWindowTest.java line 53: >> >>> 52: System.setProperty("monocle.platform","Headless"); >>> 53: } >>> 54: >> >> The test will always run with Monocle. I see that if this static block is >> removed then the test fails on Windows 10. >> Can you please verify all the platforms and change the test such that it >> runs on all platforms/ combinations. > > I wasn't able to reproduce the Problem on Window10 with VirtualBox. > > How should I do it? Add a second test class without the static code? Do you > have a good recommendation on how to add it? The previous version of test failed on my Windows 10 machine with below exception, but the updated version does not fail, test.javafx.stage.FocusedWindowTest > testLeak FAILED junit.framework.AssertionFailedError: Expected: <null> but was: javafx.stage.Stage@5fe60662 at junit.framework.Assert.fail(Assert.java:47) at junit.framework.Assert.assertTrue(Assert.java:20) at junit.framework.Assert.assertNull(Assert.java:233) at junit.framework.Assert.assertNull(Assert.java:226) at test.javafx.stage.FocusedWindowTest.assertCollectable(FocusedWindowTest.java:133) at test.javafx.stage.FocusedWindowTest.testLeakOnce(FocusedWindowTest.java:116) at test.javafx.stage.FocusedWindowTest.testLeak(FocusedWindowTest.java:84) ------------- PR: https://git.openjdk.java.net/jfx/pull/153