8217297: Add support for multiple look and feel for SwingSet SliderDemoTest
authorakolarkunnu
Tue, 22 Jan 2019 08:35:14 -0800
changeset 53670 997dc1dff075
parent 53669 420d0198e26a
child 53671 9fb26c4d8eaa
8217297: Add support for multiple look and feel for SwingSet SliderDemoTest Reviewed-by: serb Contributed-by: vikrant.v.agarwal@oracle.com
test/jdk/sanity/client/SwingSet/src/SliderDemoTest.java
test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/slider/SliderDemo.java
test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/drivers/DefaultDriverInstaller.java
--- a/test/jdk/sanity/client/SwingSet/src/SliderDemoTest.java	Sat Jan 19 10:09:46 2019 -0800
+++ b/test/jdk/sanity/client/SwingSet/src/SliderDemoTest.java	Tue Jan 22 08:35:14 2019 -0800
@@ -1,6 +1,6 @@
 
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2019, 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,6 +27,8 @@
 import java.awt.event.KeyEvent;
 import java.util.function.Predicate;
 
+import javax.swing.UIManager;
+
 import static org.testng.AssertJUnit.*;
 import org.testng.annotations.Test;
 import org.netbeans.jemmy.ClassReference;
@@ -52,7 +54,7 @@
  *          java.logging
  * @build org.jemmy2ext.JemmyExt
  * @build com.sun.swingset3.demos.slider.SliderDemo
- * @run testng SliderDemoTest
+ * @run testng/timeout=600 SliderDemoTest
  */
 @Listeners(GuiTestListener.class)
 public class SliderDemoTest {
@@ -63,9 +65,12 @@
     private static final int HORIZONTAL_MINOR_TICKS_SLIDER_MAXIMUM = 11;
     private static final int VERTICAL_MINOR_TICKS_SLIDER_MINIMUM = 0;
     private static final int VERTICAL_MINOR_TICKS_SLIDER_MAXIMUM = 100;
+    private String currentLookAndFeel;
 
-    @Test
-    public void test() throws Exception {
+    @Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)
+    public void test(String lookAndFeel) throws Exception {
+        UIManager.setLookAndFeel(lookAndFeel);
+        currentLookAndFeel = lookAndFeel;
         new ClassReference(SliderDemo.class.getCanonicalName()).startApplication();
         JFrameOperator frame = new JFrameOperator(DEMO_TITLE);
         plain(frame, HORIZONTAL_PLAIN_SLIDER);
@@ -143,6 +148,7 @@
     }
 
     private void checkKeyboard(JSliderOperator jso) {
+        boolean isMotif = currentLookAndFeel.equals("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
         checkKeyPress(jso, KeyEvent.VK_HOME,
                 jSlider -> jSlider.getValue() == jso.getMinimum());
 
@@ -156,7 +162,7 @@
             checkKeyPress(jso, KeyEvent.VK_RIGHT,
                     jSlider -> jSlider.getValue() >= expectedValue);
         }
-        {
+        if (!isMotif) {
             int expectedValue = jso.getValue() + 11;
             checkKeyPress(jso, KeyEvent.VK_PAGE_UP,
                     jSlider -> jSlider.getValue() >= expectedValue);
@@ -175,7 +181,7 @@
             checkKeyPress(jso, KeyEvent.VK_LEFT,
                     jSlider -> jSlider.getValue() <= expectedValue);
         }
-        {
+        if (!isMotif) {
             int expectedValue = jso.getValue() - 11;
             checkKeyPress(jso, KeyEvent.VK_PAGE_DOWN,
                     jSlider -> jSlider.getValue() <= expectedValue);
--- a/test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/slider/SliderDemo.java	Sat Jan 19 10:09:46 2019 -0800
+++ b/test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/slider/SliderDemo.java	Tue Jan 22 08:35:14 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2019, 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
@@ -73,6 +73,9 @@
      * main method allows us to run as a standalone demo.
      */
     public static void main(String[] args) {
+        //Ensure slider value is not printed above the slider handle
+        //which is the default behavior in GTK look and feel.
+        UIManager.put("Slider.paintValue", Boolean.FALSE);
         JFrame frame = new JFrame(SliderDemo.class.getAnnotation(DemoProperties.class).value());
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         frame.getContentPane().add(new SliderDemo());
--- a/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/drivers/DefaultDriverInstaller.java	Sat Jan 19 10:09:46 2019 -0800
+++ b/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/drivers/DefaultDriverInstaller.java	Tue Jan 22 08:35:14 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2019, 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
@@ -41,7 +41,7 @@
 import org.netbeans.jemmy.drivers.menus.DefaultJMenuDriver;
 import org.netbeans.jemmy.drivers.menus.QueueJMenuDriver;
 import org.netbeans.jemmy.drivers.scrolling.JScrollBarDriver;
-import org.netbeans.jemmy.drivers.scrolling.JSliderDriver;
+import org.netbeans.jemmy.drivers.scrolling.KeyboardJSliderScrollDriver;
 import org.netbeans.jemmy.drivers.scrolling.JSplitPaneDriver;
 import org.netbeans.jemmy.drivers.scrolling.ScrollPaneDriver;
 import org.netbeans.jemmy.drivers.scrolling.ScrollbarDriver;
@@ -109,7 +109,7 @@
                     new ScrollPaneDriver(),
                     new JScrollBarDriver(),
                     new JSplitPaneDriver(),
-                    new JSliderDriver(),
+                    new KeyboardJSliderScrollDriver(),
                     createSpinnerDriver(),
                     new ButtonMouseDriver(),
                     new JTabMouseDriver(),