author | prr |
Fri, 20 Apr 2018 09:44:45 -0700 | |
changeset 50000 | a4a0d0ece022 |
parent 49090 | 82c1fe23c469 |
permissions | -rw-r--r-- |
39033
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
1 |
/* |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
4 |
* |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
8 |
* |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
13 |
* accompanied this code). |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
14 |
* |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
18 |
* |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
21 |
* questions. |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
22 |
*/ |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
23 |
|
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
24 |
/* @test |
49090
82c1fe23c469
8196196: Headful tests should not be run in headless mode
serb
parents:
47216
diff
changeset
|
25 |
* @key headful |
50000
a4a0d0ece022
8200313: java/awt/Gtk/GtkVersionTest/GtkVersionTest.java fails
prr
parents:
49090
diff
changeset
|
26 |
* @bug 8156121 8200313 |
39033
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
27 |
* @summary "Fail forward" fails for GTK3 if no GTK2 available |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
28 |
* @modules java.desktop/sun.awt |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
29 |
* @requires (os.family == "linux") |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
30 |
* @run main GtkVersionTest |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
31 |
*/ |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
32 |
|
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
33 |
import sun.awt.UNIXToolkit; |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
34 |
|
50000
a4a0d0ece022
8200313: java/awt/Gtk/GtkVersionTest/GtkVersionTest.java fails
prr
parents:
49090
diff
changeset
|
35 |
import java.awt.Toolkit; |
a4a0d0ece022
8200313: java/awt/Gtk/GtkVersionTest/GtkVersionTest.java fails
prr
parents:
49090
diff
changeset
|
36 |
import java.io.BufferedReader; |
a4a0d0ece022
8200313: java/awt/Gtk/GtkVersionTest/GtkVersionTest.java fails
prr
parents:
49090
diff
changeset
|
37 |
import java.io.InputStreamReader; |
39033
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
38 |
|
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
39 |
public class GtkVersionTest { |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
40 |
public static class LoadGtk { |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
41 |
public static void main(String[] args) { |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
42 |
((UNIXToolkit)Toolkit.getDefaultToolkit()).loadGTK(); |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
43 |
} |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
44 |
} |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
45 |
|
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
46 |
public static void main(String[] args) throws Exception { |
50000
a4a0d0ece022
8200313: java/awt/Gtk/GtkVersionTest/GtkVersionTest.java fails
prr
parents:
49090
diff
changeset
|
47 |
test(null, "3"); |
39033
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
48 |
test("2", "2"); |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
49 |
test("2.2", "2"); |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
50 |
test("3", "3"); |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
51 |
} |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
52 |
|
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
53 |
private static void test(String version, String expect) throws Exception { |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
54 |
System.out.println( "Test " + |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
55 |
(version == null ? "no" : " GTK" + version) + " preference."); |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
56 |
Process p = Runtime.getRuntime().exec(System.getProperty("java.home") + |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
57 |
"/bin/java " + |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
58 |
(version == null ? "" : "-Djdk.gtk.version=" + version) + |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
59 |
" -Djdk.gtk.verbose=true " + |
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
39033
diff
changeset
|
60 |
"--add-exports=java.desktop/sun.awt=ALL-UNNAMED " + |
39033
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
61 |
"-cp " + System.getProperty("java.class.path", ".") + |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
62 |
" GtkVersionTest$LoadGtk"); |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
63 |
p.waitFor(); |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
64 |
|
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
65 |
try (BufferedReader br = new BufferedReader( |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
66 |
new InputStreamReader(p.getErrorStream()))) { |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
67 |
String line; |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
68 |
while ((line = br.readLine()) != null) { |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
69 |
System.out.println(line); |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
70 |
if (line.contains("Looking for GTK" + expect + " library")) { |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
71 |
return; |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
72 |
} else if (line.contains("Looking for GTK")) { |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
73 |
break; |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
74 |
} |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
75 |
} |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
76 |
throw new RuntimeException("Wrong GTK library version: \n" + line); |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
77 |
} |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
78 |
} |
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
79 |
|
d61135c3795c
8156121: "Fail forward" fails for GTK3 if no GTK2 available
ssadetsky
parents:
diff
changeset
|
80 |
} |