4623N/A/*
4623N/A * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
4623N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4623N/A *
4623N/A * This code is free software; you can redistribute it and/or modify it
4623N/A * under the terms of the GNU General Public License version 2 only, as
4623N/A * published by the Free Software Foundation.
4623N/A *
4623N/A * This code is distributed in the hope that it will be useful, but WITHOUT
4623N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4623N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4623N/A * version 2 for more details (a copy is included in the LICENSE file that
4623N/A * accompanied this code).
4623N/A *
4623N/A * You should have received a copy of the GNU General Public License version
4623N/A * 2 along with this work; if not, write to the Free Software Foundation,
4623N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4623N/A *
4623N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4623N/A * or visit www.oracle.com if you need additional information or have any
4623N/A * questions.
4623N/A */
4623N/A
4623N/A/*
4623N/A * @test
4623N/A * @bug 4843282 4886871
4623N/A * @summary Makes sure windows is only listed on Windows platform, and
4623N/A * GTK is not on Windows and Mac.
4623N/A * added as tabs
4623N/A * @author Scott Violet
4623N/A */
4623N/Aimport javax.swing.*;
4623N/Aimport javax.swing.UIManager.LookAndFeelInfo;
4623N/Aimport sun.awt.OSInfo;
4623N/Aimport sun.awt.OSInfo.OSType;
4623N/A
4623N/Apublic class UITest {
4623N/A
4623N/A public static void main(String[] args) {
4623N/A OSType os = OSInfo.getOSType();
4623N/A LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels();
4623N/A
4623N/A switch (os) {
4623N/A case WINDOWS:
4623N/A
4623N/A // Make sure we don't have GTK.
4623N/A if (hasLAF("gtk", lafInfo)) {
4623N/A throw new RuntimeException("On windows, but GTK is present");
4623N/A }
4623N/A
4623N/A // Make sure we don't have Aqua.
4623N/A if (hasLAF("mac", lafInfo)) {
4623N/A throw new RuntimeException("On windows, but Aqua is present");
4623N/A }
4623N/A
4623N/A // Make sure we have Windows.
4623N/A if (!hasLAF("windows", lafInfo)) {
4623N/A throw new RuntimeException("On windows and don't have Windows");
4623N/A }
4623N/A
4623N/A break;
4623N/A
4623N/A case MACOSX:
4623N/A
4623N/A // Make sure we don't have GTK.
4623N/A if (hasLAF("gtk", lafInfo)) {
4623N/A throw new RuntimeException("On mac, but GTK is present");
4623N/A }
4623N/A
4623N/A // Make sure we don't have Windows.
4623N/A if (hasLAF("windows", lafInfo)) {
4623N/A throw new RuntimeException("On mac, but Windows is present");
4623N/A }
4623N/A
4623N/A // Make sure we have Aqua.
4623N/A if (!hasLAF("mac", lafInfo)) {
4623N/A throw new RuntimeException("On mac and don't have Aqua");
4623N/A }
4623N/A
4623N/A break;
4623N/A
4623N/A default:
4623N/A // Not windows and mac
4623N/A
4623N/A // Make sure we don't have Windows.
4623N/A if (hasLAF("windows", lafInfo)) {
4623N/A throw new RuntimeException("Not on windows and have Windows");
4623N/A }
4623N/A
4623N/A // Make sure we don't have Aqua.
4623N/A if (hasLAF("mac", lafInfo)) {
4623N/A throw new RuntimeException("Not on mac and have Aqua");
4623N/A }
4623N/A
4623N/A // Make sure we have GTK.
4623N/A if (!hasLAF("gtk", lafInfo)) {
4623N/A throw new RuntimeException(
4623N/A "Not on Windows and Mac and don't have GTK!");
4623N/A }
4623N/A }
4623N/A
4623N/A }
4623N/A
4623N/A public static boolean hasLAF(String name, LookAndFeelInfo[] lafInfo) {
4623N/A
4623N/A for (int counter = 0; counter < lafInfo.length; counter++) {
4623N/A if (lafInfo[counter].getName().toLowerCase().indexOf(name) != -1) {
4623N/A return true;
4623N/A }
4623N/A }
4623N/A return false;
4623N/A }
4623N/A}