8210052: Enable testing for all the available look and feels in SwingSet3 demo tests
authorvagarwal
Wed, 12 Sep 2018 11:51:39 +0530
changeset 51921 372cbac1a862
parent 51920 26a17d160081
child 51922 16c6d8d35fd7
8210052: Enable testing for all the available look and feels in SwingSet3 demo tests Reviewed-by: shurailine, serb
test/jdk/sanity/client/SwingSet/src/ButtonDemoScreenshotTest.java
test/jdk/sanity/client/SwingSet/src/ButtonDemoTest.java
test/jdk/sanity/client/SwingSet/src/ComboBoxDemoTest.java
test/jdk/sanity/client/SwingSet/src/ListDemoTest.java
test/jdk/sanity/client/SwingSet/src/OptionPaneDemoTest.java
test/jdk/sanity/client/SwingSet/src/ProgressBarDemoTest.java
test/jdk/sanity/client/SwingSet/src/ScrollPaneDemoTest.java
test/jdk/sanity/client/SwingSet/src/SpinnerDemoTest.java
test/jdk/sanity/client/SwingSet/src/TabbedPaneDemoTest.java
test/jdk/sanity/client/SwingSet/src/TableDemoTest.java
test/jdk/sanity/client/SwingSet/src/ToggleButtonDemoTest.java
test/jdk/sanity/client/SwingSet/src/TreeDemoTest.java
--- a/test/jdk/sanity/client/SwingSet/src/ButtonDemoScreenshotTest.java	Sun Sep 09 19:07:34 2018 -0700
+++ b/test/jdk/sanity/client/SwingSet/src/ButtonDemoScreenshotTest.java	Wed Sep 12 11:51:39 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, 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
@@ -36,6 +36,7 @@
 import java.awt.Robot;
 import java.awt.image.BufferedImage;
 
+import javax.swing.UIManager;
 import static com.sun.swingset3.demos.button.ButtonDemo.DEMO_TITLE;
 import static org.jemmy2ext.JemmyExt.*;
 
@@ -66,8 +67,9 @@
         sComparator = new StrictImageComparator();
     }
 
-    @Test
-    public void test() throws Exception {
+    @Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)
+    public void test(String lookAndFeel) throws Exception {
+        UIManager.setLookAndFeel(lookAndFeel);
         Robot rob = new Robot();
 
         new ClassReference(ButtonDemo.class.getCanonicalName()).startApplication();
@@ -112,19 +114,22 @@
                     assertNotBlack(pressedImage[0]);
                     return !sComparator.compare(initialButtonImage, pressedImage[0]);
                 }
+
                 public String getDescription() {
                     return "Button with new image";
                 }
             });
         } finally {
-            if(pressedImage[0] != null) save(pressedImage[0], "button" + i + "_pressed.png");
+            if (pressedImage[0] != null) {
+                save(pressedImage[0], "button" + i + "_pressed.png");
+            }
             button.releaseMouse();
             //additional instrumentation for JDK-8198920. To be removed after the bug is fixed
             button.getOutput().printTrace("JDK-8198920: Button released at " + System.currentTimeMillis());
             try {
                 button.waitState(comp -> actionListenerCalled.get());
                 button.getOutput().printTrace("JDK-8198920: Action listener was called by " + System.currentTimeMillis());
-            } catch(org.netbeans.jemmy.TimeoutExpiredException e) {
+            } catch (org.netbeans.jemmy.TimeoutExpiredException e) {
                 button.getOutput().printTrace("JDK-8198920: Action listener was not called by " + System.currentTimeMillis());
             }
             //end of instrumentation for JDK-8198920
--- a/test/jdk/sanity/client/SwingSet/src/ButtonDemoTest.java	Sun Sep 09 19:07:34 2018 -0700
+++ b/test/jdk/sanity/client/SwingSet/src/ButtonDemoTest.java	Wed Sep 12 11:51:39 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, 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
@@ -28,6 +28,7 @@
 import java.util.concurrent.BlockingQueue;
 import javax.swing.ButtonModel;
 import javax.swing.JButton;
+import javax.swing.UIManager;
 import javax.swing.event.ChangeEvent;
 import static org.testng.AssertJUnit.*;
 import org.testng.annotations.Test;
@@ -93,8 +94,9 @@
         "isArmed = false, isEnabled = true, isPressed = false, isSelected = false"
     };
 
-    @Test
-    public void test() throws Exception {
+    @Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)
+    public void test(String lookAndFeel) throws Exception {
+        UIManager.setLookAndFeel(lookAndFeel);
 
         new ClassReference(ButtonDemo.class.getCanonicalName()).startApplication();
 
--- a/test/jdk/sanity/client/SwingSet/src/ComboBoxDemoTest.java	Sun Sep 09 19:07:34 2018 -0700
+++ b/test/jdk/sanity/client/SwingSet/src/ComboBoxDemoTest.java	Wed Sep 12 11:51:39 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, 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
@@ -24,6 +24,7 @@
 import org.jtregext.GuiTestListener;
 import com.sun.swingset3.demos.combobox.ComboBoxDemo;
 import static org.testng.AssertJUnit.*;
+import javax.swing.UIManager;
 import org.testng.annotations.Test;
 import org.netbeans.jemmy.ClassReference;
 import org.netbeans.jemmy.operators.JComboBoxOperator;
@@ -50,6 +51,7 @@
 public class ComboBoxDemoTest {
 
     private static enum ComboBoxInfo {
+
         PRESETS("Presets:"),
         HAIR("Hair:"),
         EYES_N_NOSE("Eyes & Nose:"),
@@ -63,9 +65,9 @@
 
     }
 
-    @Test
-    public void test() throws Exception {
-
+    @Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)
+    public void test(String lookAndFeel) throws Exception {
+        UIManager.setLookAndFeel(lookAndFeel);
         new ClassReference(ComboBoxDemo.class.getCanonicalName()).startApplication();
 
         JFrameOperator frame = new JFrameOperator(DEMO_TITLE);
--- a/test/jdk/sanity/client/SwingSet/src/ListDemoTest.java	Sun Sep 09 19:07:34 2018 -0700
+++ b/test/jdk/sanity/client/SwingSet/src/ListDemoTest.java	Wed Sep 12 11:51:39 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, 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
@@ -26,6 +26,7 @@
 
 import java.awt.Component;
 import javax.swing.JList;
+import javax.swing.UIManager;
 
 import org.netbeans.jemmy.ClassReference;
 import org.netbeans.jemmy.ComponentChooser;
@@ -67,14 +68,16 @@
             public boolean checkComponent(Component comp) {
                 return getUIValue(listOp, (JList list) -> list.getModel().getSize()) == size;
             }
+
             public String getDescription() {
                 return "Model size to be equal to " + size;
             }
         });
     }
 
-    @Test
-    public void test() throws Exception {
+    @Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)
+    public void test(String lookAndFeel) throws Exception {
+        UIManager.setLookAndFeel(lookAndFeel);
 
         new ClassReference(ListDemo.class.getCanonicalName()).startApplication();
 
--- a/test/jdk/sanity/client/SwingSet/src/OptionPaneDemoTest.java	Sun Sep 09 19:07:34 2018 -0700
+++ b/test/jdk/sanity/client/SwingSet/src/OptionPaneDemoTest.java	Wed Sep 12 11:51:39 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, 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
@@ -70,8 +70,9 @@
     public static final String YES = "Yes";
     public static final String SELECT_AN_OPTION = UIManager.getString("OptionPane.titleText");
 
-    @Test
-    public void test() throws Exception {
+    @Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)
+    public void test(String lookAndFeel) throws Exception {
+        UIManager.setLookAndFeel(lookAndFeel);
 
         new ClassReference(OptionPaneDemo.class.getCanonicalName()).startApplication();
 
@@ -94,7 +95,7 @@
     private void useInputDialog(JFrameOperator jfo, String textToType, String buttonToPush) {
         new JButtonOperator(jfo, INPUT_BUTTON).pushNoBlock();
         JDialogOperator jdo = new JDialogOperator(INPUT);
-        if(textToType != null) {
+        if (textToType != null) {
             JTextFieldOperator jto = new JTextFieldOperator(jdo);
             jto.typeText(textToType);
             jto.waitText(textToType);
@@ -146,7 +147,7 @@
     }
 
     private void callADialogAndClose(JFrameOperator jfo, String buttonToOpenDialog,
-                                     String dialogTitle, String buttonToPush) {
+            String dialogTitle, String buttonToPush) {
         new JButtonOperator(jfo, buttonToOpenDialog).pushNoBlock();
         JDialogOperator jdo = new JDialogOperator(dialogTitle);
         new JButtonOperator(jdo, buttonToPush).push();
--- a/test/jdk/sanity/client/SwingSet/src/ProgressBarDemoTest.java	Sun Sep 09 19:07:34 2018 -0700
+++ b/test/jdk/sanity/client/SwingSet/src/ProgressBarDemoTest.java	Wed Sep 12 11:51:39 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, 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
@@ -25,6 +25,7 @@
 import com.sun.swingset3.demos.progressbar.ProgressBarDemo;
 import static com.sun.swingset3.demos.progressbar.ProgressBarDemo.*;
 import java.awt.Component;
+import javax.swing.UIManager;
 import static org.testng.AssertJUnit.*;
 import org.testng.annotations.Test;
 import org.netbeans.jemmy.ClassReference;
@@ -55,9 +56,9 @@
 
     private final static long PROGRESS_BAR_TIMEOUT = 180000;
 
-    @Test
-    public void test() throws Exception {
-
+    @Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)
+    public void test(String lookAndFeel) throws Exception {
+        UIManager.setLookAndFeel(lookAndFeel);
         new ClassReference(ProgressBarDemo.class.getCanonicalName()).startApplication();
 
         JFrameOperator frame = new JFrameOperator(DEMO_TITLE);
--- a/test/jdk/sanity/client/SwingSet/src/ScrollPaneDemoTest.java	Sun Sep 09 19:07:34 2018 -0700
+++ b/test/jdk/sanity/client/SwingSet/src/ScrollPaneDemoTest.java	Wed Sep 12 11:51:39 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, 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
@@ -25,6 +25,7 @@
 import com.sun.swingset3.demos.scrollpane.ScrollPaneDemo;
 import static com.sun.swingset3.demos.scrollpane.ScrollPaneDemo.DEMO_TITLE;
 import static org.testng.AssertJUnit.*;
+import javax.swing.UIManager;
 import org.testng.annotations.Test;
 import org.netbeans.jemmy.ClassReference;
 import org.netbeans.jemmy.operators.JFrameOperator;
@@ -49,8 +50,9 @@
 @Listeners(GuiTestListener.class)
 public class ScrollPaneDemoTest {
 
-    @Test
-    public void test() throws Exception {
+    @Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)
+    public void test(String lookAndFeel) throws Exception {
+        UIManager.setLookAndFeel(lookAndFeel);
 
         new ClassReference(ScrollPaneDemo.class.getName()).startApplication();
 
--- a/test/jdk/sanity/client/SwingSet/src/SpinnerDemoTest.java	Sun Sep 09 19:07:34 2018 -0700
+++ b/test/jdk/sanity/client/SwingSet/src/SpinnerDemoTest.java	Wed Sep 12 11:51:39 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, 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
@@ -25,6 +25,7 @@
 import com.sun.swingset3.demos.spinner.SpinnerDemo;
 import static com.sun.swingset3.demos.spinner.SpinnerDemo.DEMO_TITLE;
 import java.text.DecimalFormat;
+import javax.swing.UIManager;
 import static org.testng.AssertJUnit.*;
 import org.testng.annotations.Test;
 import org.netbeans.jemmy.ClassReference;
@@ -54,8 +55,9 @@
     private static final int SPINNERS_COUNT = 9;
     private static final DecimalFormat decimalFormat = new DecimalFormat();
 
-    @Test
-    public void test() throws Exception {
+    @Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)
+    public void test(String lookAndFeel) throws Exception {
+        UIManager.setLookAndFeel(lookAndFeel);
         new ClassReference(SpinnerDemo.class.getCanonicalName()).startApplication();
 
         JFrameOperator frame = new JFrameOperator(DEMO_TITLE);
--- a/test/jdk/sanity/client/SwingSet/src/TabbedPaneDemoTest.java	Sun Sep 09 19:07:34 2018 -0700
+++ b/test/jdk/sanity/client/SwingSet/src/TabbedPaneDemoTest.java	Wed Sep 12 11:51:39 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, 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
@@ -26,6 +26,7 @@
 import static com.sun.swingset3.demos.tabbedpane.TabbedPaneDemo.*;
 import static org.jemmy2ext.JemmyExt.getLabeledContainerOperator;
 import static org.testng.AssertJUnit.*;
+import javax.swing.UIManager;
 import org.testng.annotations.Test;
 import org.netbeans.jemmy.ClassReference;
 import org.netbeans.jemmy.operators.ContainerOperator;
@@ -52,8 +53,9 @@
 @Listeners(GuiTestListener.class)
 public class TabbedPaneDemoTest {
 
-    @Test
-    public void test() throws Exception {
+    @Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)
+    public void test(String lookAndFeel) throws Exception {
+        UIManager.setLookAndFeel(lookAndFeel);
         new ClassReference(TabbedPaneDemo.class.getCanonicalName()).startApplication();
 
         JFrameOperator mainFrame = new JFrameOperator(DEMO_TITLE);
--- a/test/jdk/sanity/client/SwingSet/src/TableDemoTest.java	Sun Sep 09 19:07:34 2018 -0700
+++ b/test/jdk/sanity/client/SwingSet/src/TableDemoTest.java	Wed Sep 12 11:51:39 2018 +0530
@@ -33,6 +33,7 @@
 import java.util.List;
 
 import javax.swing.JTable;
+import javax.swing.UIManager;
 
 import org.jtregext.GuiTestListener;
 import org.netbeans.jemmy.ClassReference;
@@ -104,8 +105,9 @@
      *
      * @throws Exception
      */
-    @Test
-    public void test() throws Exception {
+    @Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)
+    public void test(String lookAndFeel) throws Exception {
+        UIManager.setLookAndFeel(lookAndFeel);
 
         new ClassReference(TableDemo.class.getCanonicalName()).startApplication();
 
--- a/test/jdk/sanity/client/SwingSet/src/ToggleButtonDemoTest.java	Sun Sep 09 19:07:34 2018 -0700
+++ b/test/jdk/sanity/client/SwingSet/src/ToggleButtonDemoTest.java	Wed Sep 12 11:51:39 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, 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
@@ -28,6 +28,7 @@
 import com.sun.swingset3.demos.togglebutton.ToggleButtonDemo;
 import static com.sun.swingset3.demos.togglebutton.ToggleButtonDemo.*;
 import java.util.function.BiFunction;
+import javax.swing.UIManager;
 import org.jemmy2ext.JemmyExt.ByClassChooser;
 import static org.jemmy2ext.JemmyExt.EXACT_STRING_COMPARATOR;
 import static org.jemmy2ext.JemmyExt.getBorderTitledJPanelOperator;
@@ -65,8 +66,9 @@
 @Listeners(GuiTestListener.class)
 public class ToggleButtonDemoTest {
 
-    @Test
-    public void test() throws Exception {
+    @Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)
+    public void test(String lookAndFeel) throws Exception {
+        UIManager.setLookAndFeel(lookAndFeel);
         new ClassReference(ToggleButtonDemo.class.getCanonicalName()).startApplication();
 
         JFrameOperator mainFrame = new JFrameOperator(ToggleButtonDemo.class.getAnnotation(DemoProperties.class).value());
--- a/test/jdk/sanity/client/SwingSet/src/TreeDemoTest.java	Sun Sep 09 19:07:34 2018 -0700
+++ b/test/jdk/sanity/client/SwingSet/src/TreeDemoTest.java	Wed Sep 12 11:51:39 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, 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
@@ -25,6 +25,7 @@
 import static com.sun.swingset3.demos.tree.TreeDemo.DEMO_TITLE;
 
 import java.awt.Component;
+import javax.swing.UIManager;
 import javax.swing.tree.TreePath;
 
 import org.jtregext.GuiTestListener;
@@ -68,14 +69,16 @@
             public boolean checkComponent(Component comp) {
                 return tree.getRowCount() == count;
             }
+
             public String getDescription() {
                 return "A tree to have " + count + " rows";
             }
         });
     }
 
-    @Test
-    public void test() throws Exception {
+    @Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)
+    public void test(String lookAndFeel) throws Exception {
+        UIManager.setLookAndFeel(lookAndFeel);
 
         new ClassReference(TreeDemo.class.getCanonicalName()).startApplication();