Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8176884

Window-based unit tests need to be more robust




      The following new unit tests (at least) have some general stability issues that should be addressed:


      Most of the problems stem from the asynchronous nature of operations that happen when doing various window-related operations such as show(), hide(), etc. This problem is made worse by submitting the operations via a runLater and then not waiting for the runLater to be executed before the main thread proceeds (in many cases using a short sleep in place of a latch or a runAndWait).

      Some of the issues would be helped by enhancements to glass Robot to allow for waiting until an operation is done, but in the mean time we can and should still make the tests as robust as possible.

      I have two specific recommendations regarding the above tests.

      1. Replace all uses of Platform.runLater in the main test thread with Util.runAndWait if they don't already wait on a latch that is directly counted down in the target (Runnable) of that runLater. This has two benefits: first we will be assured that the commands in the target of the runLater have actually executed before we continue; second, any exceptions that occur in the target of the runLater will be captured and re-thrown to the caller.

      2. Any place where we are sleeping to wait for a window to be shown, hidden, minimized, maximized, restored, made full-screen, or made non-full-screen should sleep for 1 second rather than a shorter amount. This isn't a fool-proof number, but many of our other system tests use this number and it has been proven over time to make those tests robust enough for use across a wide range of machines.


        Issue Links



              Unassigned Unassigned
              kcr Kevin Rushforth
              0 Vote for this issue
              4 Start watching this issue