JDK-8191269 : Intermittent unit test failure in SwingNodeJDialogTest
  • Type: Bug
  • Component: javafx
  • Sub-Component: swing
  • Affected Version: 10
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2017-11-14
  • Updated: 2021-02-23
  • Resolved: 2017-11-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 10 JDK 8
10Fixed 8-poolResolved
Related Reports
Relates :  
Description
The SwingNodeJDialogTest unit test, which is associated with JDK-8185634, is failing intermittently due to a pair of bugs in the test.

1) The testNodeRemovalBeforeShowHoldEDT method leaves a Stage showing after it finishes running. This means that subsequent tests will not be in a clean state.

2) The testStageCloseAfterShow method currently is written to expect the dialog to not be shown. This is only working by accident, and only if the above test runs before this test (the test order is unspecified which is why the failure is intermittent). Once bug in #1 is fixed, this method should be changed to expect the dialog to be on top, since it will be the only thing showing.
Comments
http://hg.openjdk.java.net/openjfx/10-dev/rt/rev/d9b7ff88960d
16-11-2017

Looks good. +1
16-11-2017

Nice catch! I believe that you meant testStageCloseBeforeShow in case #2 in bug description. I think that testAbove is not very useful in testStageCloseBeforeShow, because it tries to click on stage, which is already closed at the moment. This click may affect the test in a different way depending what is in click location. If we have a big window, then it should get focus and obscure the dialog(I had a maximized IDE window opened, that is why testAbove(false) was erroneously used) So I suggest to omit click in case if stage is closed. --- a/tests/system/src/test/java/test/robot/javafx/embed/swing/SwingNodeBase.java +++ b/tests/system/src/test/java/test/robot/javafx/embed/swing/SwingNodeBase.java @@ -210,9 +210,11 @@ public class SwingNodeBase { int checkLoc = BASE_LOCATION + 3 * BASE_SIZE /4; int clickLoc = BASE_LOCATION + BASE_SIZE / 4; - robot.mouseMove(clickLoc, clickLoc); - robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); - robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + if (myApp.stage != null && myApp.stage.isShowing()) { + robot.mouseMove(clickLoc, clickLoc); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + } if (above) { Assert.assertEquals("JDialog is not above JavaFX stage", diff -r 70758983aa19 tests/system/src/test/java/test/robot/javafx/embed/swing/SwingNodeJDialogTest.java --- a/tests/system/src/test/java/test/robot/javafx/embed/swing/SwingNodeJDialogTest.java +++ b/tests/system/src/test/java/test/robot/javafx/embed/swing/SwingNodeJDialogTest.java @@ -84,7 +84,7 @@ public class SwingNodeJDialogTest extend myApp.createStageAndDialog(); myApp.closeStage(); myApp.showDialog(); - testAbove(false); + testAbove(true); myApp.disposeDialog(); } @@ -102,7 +102,7 @@ public class SwingNodeJDialogTest extend latch.await(); myApp.detachSwingNode(); testAbove(false); - myApp.disposeDialog(); + myApp.closeStageAndDialog(); myApp.attachSwingNode(); }
15-11-2017

[~azvegint] Can you take a look at this along with my proposed fix?
14-11-2017

The following diff should fix the failing test: --- a/tests/system/src/test/java/test/robot/javafx/embed/swing/SwingNodeJDialogTest.java +++ b/tests/system/src/test/java/test/robot/javafx/embed/swing/SwingNodeJDialogTest.java @@ -84,7 +84,7 @@ myApp.createStageAndDialog(); myApp.closeStage(); myApp.showDialog(); - testAbove(false); + testAbove(true); myApp.disposeDialog(); } @@ -102,7 +102,7 @@ latch.await(); myApp.detachSwingNode(); testAbove(false); - myApp.disposeDialog(); + myApp.closeStageAndDialog(); myApp.attachSwingNode(); }
14-11-2017

I note that the individual tests are somewhat fragile in that a failure in one test is likely to cause failures in subsequent tests. This is because each test relies on state being restored by the previous test (in this case, the stage and dialog being closed and the SwingNode being reattached). If there is an assertion failure in a test, the cleanup logic will be skipped, since it is not in an "@After" method nor in a try ... finally block. This might be a good thing for a follow-on issue, but as long as there are no failing tests, it won't cause problems.
14-11-2017

Note that the fix for this testbug will need to be backported to 8.
14-11-2017