changeset 58785:52311063c4fa

7105119: [TEST_BUG] [macosx] In test UIDefaults.toString() must be called with the invokeLater() Reviewed-by: prr, psadhukhan
author serb
date Tue, 07 Apr 2020 21:56:04 -0700
parents e1910de73600
children e101dba52342
files test/jdk/ProblemList.txt test/jdk/javax/swing/MultiUIDefaults/4300666/bug4300666.java
diffstat 2 files changed, 28 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/test/jdk/ProblemList.txt	Mon Apr 06 20:27:40 2020 -0700
+++ b/test/jdk/ProblemList.txt	Tue Apr 07 21:56:04 2020 -0700
@@ -807,7 +807,6 @@
 javax/swing/JPopupMenu/4966112/bug4966112.java 8064915 macosx-all
 javax/swing/JSpinner/8223788/JSpinnerButtonFocusTest.java 8238085 macosx-all
 javax/swing/MultiUIDefaults/Test6860438.java 8198391 generic-all
-javax/swing/MultiUIDefaults/4300666/bug4300666.java 7105119 macosx-all
 javax/swing/UIDefaults/8146330/UIDefaultKeySizeTest.java 8241228 linux-all,solaris-all
 javax/swing/UITest/UITest.java 8198392 generic-all
 javax/swing/plaf/basic/BasicComboBoxEditor/Test8015336.java 8198394 generic-all
--- a/test/jdk/javax/swing/MultiUIDefaults/4300666/bug4300666.java	Mon Apr 06 20:27:40 2020 -0700
+++ b/test/jdk/javax/swing/MultiUIDefaults/4300666/bug4300666.java	Tue Apr 07 21:56:04 2020 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,12 +27,34 @@
  * @summary Printing UIDefaults throws NoSuchElementExcept
  */
 
-import javax.swing.*;
+import java.awt.EventQueue;
 
-public class bug4300666 {
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
 
-    public static void main(final String[] args) {
-        UIDefaults d = UIManager.getDefaults();
-        d.toString();
+import static javax.swing.UIManager.getInstalledLookAndFeels;
+
+public final class bug4300666 {
+
+    public static void main(final String[] args) throws Exception {
+        for (UIManager.LookAndFeelInfo laf : getInstalledLookAndFeels()) {
+            EventQueue.invokeAndWait(() -> setLookAndFeel(laf));
+            EventQueue.invokeAndWait(() -> {
+                UIDefaults d = UIManager.getDefaults();
+                d.toString();
+            });
+        }
+    }
+
+    private static void setLookAndFeel(UIManager.LookAndFeelInfo laf) {
+        try {
+            UIManager.setLookAndFeel(laf.getClassName());
+        } catch (UnsupportedLookAndFeelException ignored) {
+            System.out.println("Unsupported L&F: " + laf.getClassName());
+        } catch (ClassNotFoundException | InstantiationException
+                | IllegalAccessException e) {
+            throw new RuntimeException(e);
+        }
     }
 }