8216353: Use utility APIs introduced in org/netbeans/jemmy/util/LookAndFeel class in client sanity test cases
Reviewed-by: serb
--- a/test/jdk/sanity/client/SwingSet/src/FileChooserDemoTest.java Wed Mar 13 00:04:22 2019 -0700
+++ b/test/jdk/sanity/client/SwingSet/src/FileChooserDemoTest.java Wed Mar 13 00:51:28 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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
@@ -61,6 +61,7 @@
import org.netbeans.jemmy.operators.JDialogOperator;
import org.netbeans.jemmy.operators.JComponentOperator.JComponentByTipFinder;
import org.netbeans.jemmy.util.Platform;
+import org.netbeans.jemmy.util.LookAndFeel;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Listeners;
import org.jemmy2ext.JemmyExt.ByToolTipChooser;
@@ -141,9 +142,7 @@
fileChooser = new JFileChooserOperator(JFileChooserOperator.findJFileChooser((Container) frame.getSource()));
// In Aqua, GTK and Motif L&Fs, JFileChooser does not have
// "Go Home", "Up One Level", "Get Details", "Get List" buttons.
- if (!UIManager.getLookAndFeel().getID().equals("Aqua")
- && !UIManager.getLookAndFeel().getID().equals("Motif")
- && !UIManager.getLookAndFeel().getID().equals("GTK")) {
+ if (!LookAndFeel.isAqua() && !LookAndFeel.isMotif() && !LookAndFeel.isGTK()) {
File previousDirectory = fileChooser.getCurrentDirectory();
fileChooser.goHome();
// In Windows, pressing goHome navigates to Desktop inside the home directory.
@@ -157,7 +156,7 @@
fileChooser.rescanCurrentDirectory();
// In Windows and Windows Classic L&F, List and Details views are
// implemented as a popup menu item
- if(UIManager.getLookAndFeel().getID().equals("Windows")) {
+ if(LookAndFeel.isWindows() || LookAndFeel.isWindowsClassic()) {
JButtonOperator popupButton = new JButtonOperator(fileChooser, new JComponentByTipFinder(
UIManager.getString("FileChooser.viewMenuButtonToolTipText", fileChooser.getLocale())));
popupButton.push();
@@ -274,8 +273,7 @@
fileChooserDialog = new JDialogOperator(OPEN);
String openButtonText = OPEN;
// In GTK and Motif L&F, open button text is 'OK'
- if (UIManager.getLookAndFeel().getID().equals("Motif")
- || UIManager.getLookAndFeel().getID().equals("GTK")) {
+ if (LookAndFeel.isMotif() || LookAndFeel.isGTK()) {
openButtonText = OK;
}
openButton = new JButtonOperator(fileChooser, openButtonText);
--- a/test/jdk/sanity/client/SwingSet/src/SliderDemoTest.java Wed Mar 13 00:04:22 2019 -0700
+++ b/test/jdk/sanity/client/SwingSet/src/SliderDemoTest.java Wed Mar 13 00:51:28 2019 -0700
@@ -36,6 +36,8 @@
import org.netbeans.jemmy.operators.JFrameOperator;
import org.netbeans.jemmy.operators.JSliderOperator;
import org.netbeans.jemmy.accessibility.AccessibleNameChooser;
+import org.netbeans.jemmy.util.LookAndFeel;
+
import static com.sun.swingset3.demos.slider.SliderDemo.*;
import org.testng.annotations.Listeners;
@@ -65,12 +67,10 @@
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(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);
@@ -148,7 +148,7 @@
}
private void checkKeyboard(JSliderOperator jso) {
- boolean isMotif = currentLookAndFeel.equals("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
+ boolean isMotif = LookAndFeel.isMotif();
checkKeyPress(jso, KeyEvent.VK_HOME,
jSlider -> jSlider.getValue() == jso.getMinimum());
--- a/test/jdk/sanity/client/SwingSet/src/SplitPaneDemoTest.java Wed Mar 13 00:04:22 2019 -0700
+++ b/test/jdk/sanity/client/SwingSet/src/SplitPaneDemoTest.java Wed Mar 13 00:51:28 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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,6 +41,7 @@
import org.netbeans.jemmy.operators.JRadioButtonOperator;
import org.netbeans.jemmy.operators.JSplitPaneOperator;
import org.netbeans.jemmy.operators.JTextFieldOperator;
+import org.netbeans.jemmy.util.LookAndFeel;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
@@ -76,7 +77,7 @@
JSplitPaneOperator splitPane = new JSplitPaneOperator(frame);
// OneTouch feature is not available in GTK L&F
- if(!"GTK".equals(UIManager.getLookAndFeel().getID())) {
+ if(!LookAndFeel.isGTK()) {
// Toggle OneTouch Expandable
checkOneTouch(frame, splitPane, true);
checkOneTouch(frame, splitPane, false);
@@ -89,7 +90,7 @@
// TODO Skipping this code for Motif L&F as the fix for "CODETOOLS-7902324"
// is deferred now
- if(!("Motif".equals(UIManager.getLookAndFeel().getID()))) {
+ if(!LookAndFeel.isMotif()) {
// Check moving the divider
checkDividerMoves(frame, splitPane, false);
checkDividerMoves(frame, splitPane, true);
--- a/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/drivers/DefaultDriverInstaller.java Wed Mar 13 00:04:22 2019 -0700
+++ b/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/drivers/DefaultDriverInstaller.java Wed Mar 13 00:51:28 2019 -0700
@@ -53,6 +53,7 @@
import org.netbeans.jemmy.drivers.windows.DefaultInternalFrameDriver;
import org.netbeans.jemmy.drivers.windows.DefaultWindowDriver;
import org.netbeans.jemmy.drivers.windows.InternalFramePopupMenuDriver;
+import org.netbeans.jemmy.util.LookAndFeel;
/**
* Installs all necessary drivers for Jemmy operators except low-level drivers
@@ -122,9 +123,9 @@
new ChoiceDriver(),
new DefaultFrameDriver(),
new DefaultWindowDriver(),
- "Motif".equals(UIManager.getLookAndFeel().getID())? new InternalFramePopupMenuDriver(): new DefaultInternalFrameDriver(),
- "Motif".equals(UIManager.getLookAndFeel().getID())? new InternalFramePopupMenuDriver(): new DefaultInternalFrameDriver(),
- "Motif".equals(UIManager.getLookAndFeel().getID())? new InternalFramePopupMenuDriver(): new DefaultInternalFrameDriver(),
+ LookAndFeel.isMotif()? new InternalFramePopupMenuDriver(): new DefaultInternalFrameDriver(),
+ LookAndFeel.isMotif()? new InternalFramePopupMenuDriver(): new DefaultInternalFrameDriver(),
+ LookAndFeel.isMotif()? new InternalFramePopupMenuDriver(): new DefaultInternalFrameDriver(),
new APIFocusDriver(),
new MouseFocusDriver(),
(shortcutEvents ? new QueueJMenuDriver() : new DefaultJMenuDriver()),
--- a/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/JFileChooserOperator.java Wed Mar 13 00:04:22 2019 -0700
+++ b/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/JFileChooserOperator.java Wed Mar 13 00:51:28 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2017, 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
@@ -43,7 +43,6 @@
import javax.swing.JTextField;
import javax.swing.JToggleButton;
import javax.swing.ListModel;
-import javax.swing.UIManager;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileSystemView;
import javax.swing.filechooser.FileView;
@@ -60,6 +59,7 @@
import org.netbeans.jemmy.Timeouts;
import org.netbeans.jemmy.Waitable;
import org.netbeans.jemmy.Waiter;
+import org.netbeans.jemmy.util.LookAndFeel;
/**
*
@@ -344,8 +344,7 @@
int index = 0;
// In GTK and Motif L&F, there are two JLists, one is to list folders
// and second one one is to list files
- if (UIManager.getLookAndFeel().getID().equals("Motif")
- || UIManager.getLookAndFeel().getID().equals("GTK")) {
+ if (LookAndFeel.isMotif() || LookAndFeel.isGTK()) {
index =1;
}
return innerSearcher.
@@ -445,7 +444,7 @@
// In Windows and Windows Classic L&F, there is no 'Go Home' button,
// but there is a toggle button to go desktop. In Windows platform
// 'Go Home' button usually navigates to Desktop only.
- if(UIManager.getLookAndFeel().getID().equals("Windows")) {
+ if(LookAndFeel.isWindows() || LookAndFeel.isWindowsClassic()) {
homeOper =new JToggleButtonOperator(this, 1);
} else {
homeOper = new JButtonOperator(getHomeButton());
--- a/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/JInternalFrameOperator.java Wed Mar 13 00:04:22 2019 -0700
+++ b/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/JInternalFrameOperator.java Wed Mar 13 00:51:28 2019 -0700
@@ -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
@@ -57,6 +57,7 @@
import org.netbeans.jemmy.drivers.InternalFrameDriver;
import org.netbeans.jemmy.drivers.WindowDriver;
import org.netbeans.jemmy.util.EmptyVisualizer;
+import org.netbeans.jemmy.util.LookAndFeel;
import org.netbeans.jemmy.util.Platform;
/**
@@ -1419,7 +1420,7 @@
return "JInternalFrameOperator.initOperators.ComponentChooser{description = " + getDescription() + '}';
}
}) != null) {
- if("Motif".equals(UIManager.getLookAndFeel().getID())) {
+ if(LookAndFeel.isMotif()) {
popupButtonOper = new JButtonOperator(titleOperator, 0);
} else {
minOper = new JButtonOperator(titleOperator,
@@ -1436,7 +1437,7 @@
maxOper = null;
}
if (isClosable()) {
- if(!"Motif".equals(UIManager.getLookAndFeel().getID())) {
+ if(!LookAndFeel.isMotif()) {
closeOper = new JButtonOperator(titleOperator,
new JComponentByTipFinder(CLOSE_BUTTON_TOOLTIP));
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/util/LookAndFeel.java Wed Mar 13 00:51:28 2019 -0700
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package org.netbeans.jemmy.util;
+
+import javax.swing.UIManager;
+
+/**
+ * Class to provide look and feel related utility APIs
+ */
+public class LookAndFeel {
+
+ /**
+ * Checking whether the current look and feel is Metal L&F
+ *
+ * @return returns true if current look and feel is Metal L&F,
+ * otherwise false
+ */
+ public static boolean isMetal() {
+ return isLookAndFeel("Metal");
+ }
+
+ /**
+ * Checking whether the current look and feel is Nimbus L&F
+ *
+ * @return returns true if current look and feel is Nimbus L&F,
+ * otherwise false
+ */
+ public static boolean isNimbus() {
+ return isLookAndFeel("Nimbus");
+ }
+
+ /**
+ * Checking whether the current look and feel is Motif L&F
+ *
+ * @return returns true if current look and feel is Motif L&F,
+ * otherwise false
+ */
+ public static boolean isMotif() {
+ return isLookAndFeel("Motif");
+ }
+
+ /**
+ * Checking whether the current look and feel is GTK L&F
+ *
+ * @return returns true if current look and feel is GTK L&F,
+ * otherwise false
+ */
+ public static boolean isGTK() {
+ return isLookAndFeel("GTK");
+ }
+
+ /**
+ * Checking whether the current look and feel is Aqua L&F
+ *
+ * @return returns true if current look and feel is Aqua L&F,
+ * otherwise false
+ */
+ public static boolean isAqua() {
+ return isLookAndFeel("Aqua");
+ }
+
+ /**
+ * Checking whether the current look and feel is Windows L&F
+ *
+ * @return returns true if current look and feel is Windows L&F,
+ * otherwise false
+ */
+ public static boolean isWindows() {
+ return UIManager.getLookAndFeel().getClass().
+ getSimpleName().equals("WindowsLookAndFeel");
+ }
+
+ /**
+ * Checking whether the current look and feel is WindowsClassic L&F
+ *
+ * @return returns true if current look and feel is WindowsClassic L&F,
+ * otherwise false
+ */
+ public static boolean isWindowsClassic() {
+ return UIManager.getLookAndFeel().getClass().
+ getSimpleName().equals("WindowsClassicLookAndFeel");
+ }
+
+ private static boolean isLookAndFeel(String id) {
+ return UIManager.getLookAndFeel().getID().equals(id);
+ }
+}
--- a/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/version_info Wed Mar 13 00:04:22 2019 -0700
+++ b/test/jdk/sanity/client/lib/jemmy/src/org/netbeans/jemmy/version_info Wed Mar 13 00:51:28 2019 -0700
@@ -1,6 +1,6 @@
Manifest-version: 1.0
Main-Class: org.netbeans.jemmy.JemmyProperties
Jemmy-MajorVersion: 3.0
-Jemmy-MinorVersion: 7.0
+Jemmy-MinorVersion: 8.0
Jemmy-Build: @BUILD_NUMBER@