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 ../../../lib/testlibrary 32 * @build jdk.testlibrary.OSInfo 33 * @run main UITest 34 */ 35 import javax.swing.*; 36 import javax.swing.UIManager.LookAndFeelInfo; 37 import jdk.testlibrary.OSInfo; 38 import jdk.testlibrary.OSInfo.OSType; 39 40 public class UITest { 41 42 public static void main(String[] args) { 43 OSType os = OSInfo.getOSType(); 44 LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels(); 45 46 switch (os) { 47 case WINDOWS: 48 49 // Make sure we don't have GTK. 50 if (hasLAF("gtk", lafInfo)) { 51 throw new RuntimeException("On windows, but GTK is present"); 52 } 53 54 // Make sure we don't have Aqua. 55 if (hasLAF("mac", lafInfo)) { 56 throw new RuntimeException("On windows, but Aqua is present"); 57 } 58 59 // Make sure we have Windows. 60 if (!hasLAF("windows", lafInfo)) { 61 throw new RuntimeException("On windows and don't have Windows"); 62 } 63 64 break; 65 66 case MACOSX: 67 68 // Make sure we don't have GTK. 69 if (hasLAF("gtk", lafInfo)) { 70 throw new RuntimeException("On mac, but GTK is present"); 71 } 72 73 // Make sure we don't have Windows. 74 if (hasLAF("windows", lafInfo)) { 75 throw new RuntimeException("On mac, but Windows is present"); 76 } 77 78 // Make sure we have Aqua. 79 if (!hasLAF("mac", lafInfo)) { 80 throw new RuntimeException("On mac and don't have Aqua"); 81 } 82 83 break; 84 85 default: 86 // Not windows and mac 87 88 // Make sure we don't have Windows. 89 if (hasLAF("windows", lafInfo)) { 90 throw new RuntimeException("Not on windows and have Windows"); 91 } 92 93 // Make sure we don't have Aqua. 94 if (hasLAF("mac", lafInfo)) { 95 throw new RuntimeException("Not on mac and have Aqua"); 96 } 97 98 // Make sure we have GTK. 99 if (!hasLAF("gtk", lafInfo)) { 100 throw new RuntimeException( 101 "Not on Windows and Mac and don't have GTK!"); 102 } 103 } 104 105 } 106 107 public static boolean hasLAF(String name, LookAndFeelInfo[] lafInfo) { 108 109 for (int counter = 0; counter < lafInfo.length; counter++) { 110 if (lafInfo[counter].getName().toLowerCase().indexOf(name) != -1) { 111 return true; 112 } 113 } 114 return false; 115 } 116 }