8217297: Add support for multiple look and feel for SwingSet SliderDemoTest

Reviewed-by: serb
This commit is contained in:
Vikrant Agarwal 2019-01-22 08:35:14 -08:00 committed by Abdul Kolarkunnu
parent d553ddbd03
commit 35aad86bc4
3 changed files with 19 additions and 10 deletions

View File

@ -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.Component;
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 @@ import org.testng.annotations.Listeners;
* 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 @@ public class SliderDemoTest {
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 @@ public class SliderDemoTest {
}
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 @@ public class SliderDemoTest {
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 @@ public class SliderDemoTest {
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);

View File

@ -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 @@ public class SliderDemo extends JPanel {
* 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());

View File

@ -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.lists.ListKeyboardDriver;
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 @@ public class DefaultDriverInstaller extends ArrayDriverInstaller {
new ScrollPaneDriver(),
new JScrollBarDriver(),
new JSplitPaneDriver(),
new JSliderDriver(),
new KeyboardJSliderScrollDriver(),
createSpinnerDriver(),
new ButtonMouseDriver(),
new JTabMouseDriver(),