On Wed, 21 May 2025 11:46:50 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:

>>> When I try to iterate the test for all L&F, the test result of first L&F is 
>>> explicitly taken for other L&F too. Any idea why ?
>> 
>> Indeed, `PassFailJFrame` doesn't support repeating tests. It never was a 
>> scenario that we thought of. There are lots of static fields, including the 
>> latch that's used to wait for the test result. The instruction frame and 
>> list of windows are also static fields.
>> 
>> Supporting repeating tests such as in this scenario would require a 
>> substantial redesign of the internal structures… Everything should be an 
>> instance field instead, that instance could be stored in a static variable 
>> to support all the static methods provided. Redesigning the `PassFailJFrame` 
>> framework this way would take significant amount of time.
>
>> > When I try to iterate the test for all L&F, the test result of first L&F 
>> > is explicitly taken for other L&F too. Any idea why ?
>> 
>> Indeed, `PassFailJFrame` doesn't support repeating tests. It never was a 
>> scenario that we thought of. There are lots of static fields, including the 
>> latch that's used to wait for the test result. The instruction frame and 
>> list of windows are also static fields.
>> 
>> Supporting repeating tests such as in this scenario would require a 
>> substantial redesign of the internal structures… Everything should be an 
>> instance field instead, that instance could be stored in a static variable 
>> to support all the static methods provided. Redesigning the `PassFailJFrame` 
>> framework this way would take significant amount of time.
> 
> I submitted the following enhancements:
> 
> * [JDK-8357455](https://bugs.openjdk.org/browse/JDK-8357455): Support running 
> multiple PassFailJFrame test cases in one process;
> * [JDK-8357456](https://bugs.openjdk.org/browse/JDK-8357456): Ensure 
> JFileChooser doesn't render file names as HTML in all L&Fs support.

As a workaround, I suggest testing Metal, the default L&F, and the system L&F 
on the platforms.

This can be achieved by having two sets of jtreg test tags:


/*
 * @test id=metal
 * @bug 8139228
 * @summary JFileChooser should not render Directory names in HTML format
 * @library /java/awt/regtesthelpers
 * @build PassFailJFrame
 * @run main/manual HTMLFileName metal
 */

/*
 * @test id=system
 * @bug 8139228
 * @summary JFileChooser should not render Directory names in HTML format
 * @library /java/awt/regtesthelpers
 * @build PassFailJFrame
 * @run main/manual HTMLFileName system
 */


Then add the following to your `main` method:


    public static void main(String[] args) throws Exception {
        if (args.length < 1) {
            throw new IllegalArgumentException("Look-and-Feel keyword is 
required");
        }

        final String lafClassName;
        switch (args[0]) {
            case "metal" -> lafClassName = 
UIManager.getCrossPlatformLookAndFeelClassName();
            case "system" -> lafClassName = 
UIManager.getSystemLookAndFeelClassName();
            default -> throw new IllegalArgumentException("Unsupported 
Look-and-Feel keyword: " + args[0]);
        }

        SwingUtilities.invokeAndWait(() -> {
            try {
                UIManager.setLookAndFeel(lafClassName);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        });

        PassFailJFrame.builder()
                // other configuration
                .awaitAndCheck();


I tested it, and it works perfectly on Windows.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/24439#discussion_r2100110185

Reply via email to