1 /* 2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test 26 * @bug 4843282 4886871 27 * @summary Makes sure windows is only listed on Windows platform, and 28 * GTK is not on Windows and Mac. 29 * added as tabs 30 * @author Scott Violet 31 * @library /test/lib 32 * @build jdk.test.lib.Platform 33 * @run main UITest 34 */ 35 import javax.swing.*; 36 import javax.swing.UIManager.LookAndFeelInfo; 37 38 import jdk.test.lib.Platform; 39 40 public class UITest { 41 42 public static void main(String[] args) { 43 LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels(); 44 if (Platform.isWindows()) { 45 // Make sure we don't have GTK. 46 if (hasLAF("gtk", lafInfo)) { 47 throw new RuntimeException("On windows, but GTK is present"); 48 } 49 50 // Make sure we don't have Aqua. 51 if (hasLAF("mac", lafInfo)) { 52 throw new RuntimeException("On windows, but Aqua is present"); 53 } 54 55 // Make sure we have Windows. 56 if (!hasLAF("windows", lafInfo)) { 57 throw new RuntimeException("On windows and don't have Windows"); 58 } 59 } else if (Platform.isOSX()) { 60 // Make sure we don't have GTK. 61 if (hasLAF("gtk", lafInfo)) { 62 throw new RuntimeException("On mac, but GTK is present"); 63 } 64 65 // Make sure we don't have Windows. 66 if (hasLAF("windows", lafInfo)) { 67 throw new RuntimeException("On mac, but Windows is present"); 68 } 69 70 // Make sure we have Aqua. 71 if (!hasLAF("mac", lafInfo)) { 72 throw new RuntimeException("On mac and don't have Aqua"); 73 } 74 } else { 75 // Not windows and mac 76 77 // Make sure we don't have Windows. 78 if (hasLAF("windows", lafInfo)) { 79 throw new RuntimeException("Not on windows and have Windows"); 80 } 81 82 // Make sure we don't have Aqua. 83 if (hasLAF("mac", lafInfo)) { 84 throw new RuntimeException("Not on mac and have Aqua"); 85 } 86 87 // Make sure we have GTK. 88 if (!hasLAF("gtk", lafInfo)) { 89 throw new RuntimeException( 90 "Not on Windows and Mac and don't have GTK!"); 91 } 92 } 93 } 94 95 public static boolean hasLAF(String name, LookAndFeelInfo[] lafInfo) { 96 97 for (int counter = 0; counter < lafInfo.length; counter++) { 98 if (lafInfo[counter].getName().toLowerCase().indexOf(name) != -1) { 99 return true; 100 } 101 } 102 return false; 103 } 104 }