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 }
|
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 }
|