RFR: 8320303: Allow PassFailJFrame to accept single window creator
Sergey Bylokhov
serb at openjdk.org
Thu Nov 30 19:58:07 UTC 2023
On Fri, 17 Nov 2023 20:01:55 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
> Enhance `PassFailJFrame` for single-window test UI which is the most common case so that there's no need to return `List.of`.
>
> With this change, the lambda or method reference passed to `Builder.testUI` will return Window instead of `List<Window>` (or `List<? extends Window>`.
>
> This change adds new functional interface `WindowCreator` which returns a single Window; the existing interface is renamed to `WindowListCreator`.
>
> It's backwards compatible change; the [FileChooserSymLinkTest.java](https://github.com/openjdk/jdk/blob/7f47c51aced9c724dbc9b0d8cbd88c49435da460/test/jdk/javax/swing/JFileChooser/FileChooserSymLinkTest.java) test which uses `Builder.testUI` works without change.
>
> It was my main concern that it will be impossible to have two interfaces where one creates a `Windows` and another — `List<Windows>`. The Java compiler automatically selects the correct method based on the return type of the lambda expression, so that both cases are supported. The requirement to return a `List` where only one window is needed bothered me, and I finally solved it.
>
> In addition to that, I added description to all the overloads of the `Builder.testUI` method and updated the sample in the class documentation.
>
> Since the `PassFailJFrame` class isn't supposed to be extended, I marked it `final` to prevent anyone from doing it.
Marked as reviewed by serb (Reviewer).
-------------
PR Review: https://git.openjdk.org/jdk/pull/16717#pullrequestreview-1758335015
More information about the client-libs-dev
mailing list