JDK-8093011 : [Dialogs] Write unit tests
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: 8u40
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2014-08-14
  • Updated: 2015-06-12
  • Resolved: 2014-10-22
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 8
8u40Fixed
Related Reports
Relates :  
Description
There are a number of corner cases that need to be unit tests in the dialogs API. Here's a list of some areas that need testing (over and above the simple unit tests all API should get):

1) Tests to ensure that a forcibly closed dialog is handled correctly:
a) One, non-cancel button (dialog should close)
b) Multiple buttons, all non-cancel (dialog should not close)
c) Multiple buttons, with one cancel button (dialog should close)
d) Multiple buttons, with multiple cancel buttons (dialog should close, the first cancel button should be used)

2) Tests to ensure that a closed dialog returns the correct value, depending on its R type, including:
a) Test to see what result and showAndWait() return when R is Void
b) Test to see what result and showAndWait() return when R is ButtonType
c) Test to see what result and showAndWait() return when R is String, and no resultConverter has been specified (expect a class cast exception in the unit test)
d) Test to see what result and showAndWait() return when R is String, when a resultConverter has been specified that returns null (expect Optional.empty())
e) Test to see what result and showAndWait() return when R is String, when a resultConverter has been specified that returns a valid String

3) Test all cases above to ensure that non-blocking and blocking dialogs have the same result values given the same user input.
Comments
Changeset: http://hg.openjdk.java.net/openjfx/8u-dev/rt/rev/59c49e51814b
22-10-2014

Attaching a first pass at a possible approach of testing both blocking and non-blocking dialogs. In essence, there is one class that contains all the tests: AlertTest (at present). This class has a boolean flag set to run non-blocking by default, which means that all the tests are non-blocking and can be part of the normal unit test run. This file is then (unfortunately) duplicated into rt/tests/system (due to rt/tests not seeing unit tests in rt/modules/controls). I've then written an application that loads and runs the tests in a blocking fashion. Whilst the blocking tests run fine from my IDE, I am unable to test from the command line as other tests fail before my tests are run. @Kevin: How do you feel about this approach?
21-08-2014