author | dermashov |
Mon, 21 Jul 2014 12:29:45 +0400 | |
changeset 25786 | 266ca40a0af2 |
permissions | -rw-r--r-- |
25786
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
1 |
/* |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
2 |
* Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved. |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
4 |
* |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
8 |
* |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
13 |
* accompanied this code). |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
14 |
* |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
18 |
* |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
21 |
* questions. |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
22 |
*/ |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
23 |
|
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
24 |
import java.awt.*; |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
25 |
import java.beans.PropertyChangeEvent; |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
26 |
import java.beans.PropertyChangeListener; |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
27 |
import java.io.InputStream; |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
28 |
|
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
29 |
/* |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
30 |
* @test |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
31 |
* @bug 4758438 |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
32 |
* @summary Testcase to check the implementation of RFE 4758438 |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
33 |
* The RFE suggests that the GNOME desktop properties |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
34 |
* should be made accessible through the |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
35 |
* Toolkit.getDesktopProperty() API. |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
36 |
* @author Girish R (girish.ramachandran@sun.com) |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
37 |
* @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com) |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
38 |
* @run shell rfe4758438.sh |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
39 |
*/ |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
40 |
|
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
41 |
public class rfe4758438 implements PropertyChangeListener { |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
42 |
|
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
43 |
enum PROPS { |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
44 |
drag_threshold( |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
45 |
"org.gnome.settings-daemon.peripherals.mouse drag-threshold", |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
46 |
"/desktop/gnome/peripherals/mouse/drag_threshold", |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
47 |
"gnome.Net/DndDragThreshold", |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
48 |
"int", |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
49 |
new String[]{"5", "6"}), |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
50 |
double_click( |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
51 |
"org.gnome.settings-daemon.peripherals.mouse double-click", |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
52 |
"/desktop/gnome/peripherals/mouse/double_click", |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
53 |
"gnome.Net/DoubleClickTime", |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
54 |
"int", |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
55 |
new String[]{"200","300"}), |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
56 |
cursor_blink( |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
57 |
"org.gnome.desktop.interface cursor-blink", |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
58 |
"/desktop/gnome/interface/cursor_blink", |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
59 |
"gnome.Net/CursorBlink", |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
60 |
"bool", |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
61 |
new String[]{"true","false"}), |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
62 |
cursor_blink_time( |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
63 |
"org.gnome.desktop.interface cursor-blink-time", |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
64 |
"/desktop/gnome/interface/cursor_blink_time", |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
65 |
"gnome.Net/CursorBlinkTime", |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
66 |
"int", |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
67 |
new String[]{"1000","1500"}), |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
68 |
gtk_theme( |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
69 |
"org.gnome.desktop.interface gtk-theme", |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
70 |
"/desktop/gnome/interface/gtk_theme", |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
71 |
"gnome.Net/ThemeName", |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
72 |
"string", |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
73 |
new String[]{"Crux","Simple"}); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
74 |
|
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
75 |
public final String gsettings; |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
76 |
public final String gconftool; |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
77 |
public final String java; |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
78 |
public final String type; |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
79 |
public final String[] values; |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
80 |
|
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
81 |
PROPS(String gsettings, String gconftool, String java, String type, String[] values){ |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
82 |
this.gsettings = gsettings; |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
83 |
this.gconftool = gconftool; |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
84 |
this.java = java; |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
85 |
this.type = type; |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
86 |
this.values = values; |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
87 |
} |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
88 |
} |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
89 |
|
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
90 |
static boolean useGsettings; |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
91 |
static String tool; |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
92 |
Toolkit toolkit = Toolkit.getDefaultToolkit(); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
93 |
String changedProperty; |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
94 |
Object changedValue; |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
95 |
Object lock = new Object(); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
96 |
|
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
97 |
/** |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
98 |
* Implementation of PropertyChangeListener method |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
99 |
*/ |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
100 |
public void propertyChange(PropertyChangeEvent event) { |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
101 |
changedProperty = event.getPropertyName(); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
102 |
changedValue = toolkit.getDesktopProperty(changedProperty); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
103 |
System.out.println("Property "+changedProperty+" changed. Changed value: "+changedValue); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
104 |
synchronized(lock) { |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
105 |
try { |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
106 |
lock.notifyAll(); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
107 |
} catch (Exception e) { |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
108 |
} |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
109 |
} |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
110 |
} |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
111 |
|
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
112 |
public static void main(String[] args) throws Exception { |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
113 |
useGsettings = System.getProperty("useGsettings").equals("true"); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
114 |
tool = System.getProperty("tool"); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
115 |
|
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
116 |
String osName = System.getProperty("os.name"); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
117 |
if (!"Linux".equals(osName) && !"SunOS".equals(osName)) |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
118 |
System.out.println("This test need not be run on this platform"); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
119 |
else |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
120 |
new rfe4758438().doTest(); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
121 |
} |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
122 |
|
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
123 |
void doTest() throws Exception { |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
124 |
for (PROPS p : PROPS.values()) |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
125 |
toolkit.addPropertyChangeListener(p.java, this); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
126 |
|
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
127 |
for (PROPS p : PROPS.values()) { |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
128 |
Thread.sleep(1000); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
129 |
doTest(p); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
130 |
} |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
131 |
System.out.println("Test passed"); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
132 |
} |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
133 |
|
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
134 |
/** |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
135 |
* Do the test for each property. Find the current value |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
136 |
* of the property, set the property to a value not equal |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
137 |
* to the current value, check if the propertyChange event |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
138 |
* is triggered. Reset the property to the actual value. |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
139 |
*/ |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
140 |
void doTest(PROPS property) throws Exception { |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
141 |
//Choose the test value which is not same as the current value |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
142 |
Object obj = toolkit.getDesktopProperty(property.java); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
143 |
if (obj == null) |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
144 |
throw new RuntimeException("No such property available: " + property.java); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
145 |
|
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
146 |
//For boolean type values, getDesktopProperty method returns Integer objects |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
147 |
if (property.type.equals("bool")) { |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
148 |
if (obj.equals(new Integer(1))) { |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
149 |
obj = new String("true"); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
150 |
} else { |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
151 |
obj = new String("false"); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
152 |
} |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
153 |
} |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
154 |
Object value = property.values[0]; |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
155 |
if (obj.toString().equals(value)) { |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
156 |
value = property.values[1]; |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
157 |
} |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
158 |
|
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
159 |
//Create the command to execute |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
160 |
StringBuffer sb = new StringBuffer(tool); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
161 |
if (useGsettings) { |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
162 |
sb.append(" set "); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
163 |
sb.append(property.gsettings); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
164 |
sb.append(" "); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
165 |
} else { |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
166 |
sb.append(" --set --type="); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
167 |
sb.append(property.type); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
168 |
sb.append(" "); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
169 |
sb.append(property.gconftool); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
170 |
sb.append(" "); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
171 |
} |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
172 |
String tempCommand = sb.toString(); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
173 |
sb.append(value.toString()); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
174 |
|
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
175 |
//Initialize the variables and execute the command |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
176 |
changedProperty = ""; |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
177 |
changedValue = null; |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
178 |
if (executeCommand(sb.toString()) != 0) |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
179 |
throw new RuntimeException("Could not execute the command"); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
180 |
|
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
181 |
synchronized(lock) { |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
182 |
try { |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
183 |
lock.wait(5000); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
184 |
} catch (Exception e) { |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
185 |
} |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
186 |
} |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
187 |
if (property.type.equals("bool")) { |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
188 |
if (changedValue.equals(new Integer(1))) { |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
189 |
changedValue = new String("true"); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
190 |
} else { |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
191 |
changedValue = new String("false"); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
192 |
} |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
193 |
} |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
194 |
|
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
195 |
//Check if the event got triggered |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
196 |
if (!changedProperty.equals(property.java)) { |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
197 |
//Reset the property |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
198 |
executeCommand(tempCommand + obj.toString()); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
199 |
throw new RuntimeException("PropertyChangedEvent did not occur for " + property.java); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
200 |
} else if (!changedValue.toString().equals(value.toString())) { |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
201 |
//Reset the property |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
202 |
executeCommand(tempCommand + obj.toString()); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
203 |
throw new RuntimeException("New value of the property is different from " + |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
204 |
"the value supplied"); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
205 |
} |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
206 |
|
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
207 |
//Reset the property |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
208 |
executeCommand(tempCommand + obj.toString()); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
209 |
} |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
210 |
|
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
211 |
/** |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
212 |
* Uses the gconftool-2 command to change the value of the property. |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
213 |
* Gets the output of the command and prints the output |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
214 |
*/ |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
215 |
int executeCommand(String command) throws Exception { |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
216 |
System.out.println("Executing " + command); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
217 |
Process process = Runtime.getRuntime().exec(command); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
218 |
|
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
219 |
InputStream is = process.getInputStream(); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
220 |
InputStream es = process.getErrorStream(); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
221 |
StringBuilder stdout = new StringBuilder(); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
222 |
StringBuilder stderr = new StringBuilder(); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
223 |
|
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
224 |
process.waitFor(); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
225 |
|
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
226 |
while (is.available() > 0) |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
227 |
stdout.append((char) is.read()); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
228 |
|
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
229 |
while (es.available() > 0) |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
230 |
stderr.append((char) es.read()); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
231 |
|
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
232 |
if (stdout.length() > 0) |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
233 |
System.out.println(stdout.toString()); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
234 |
if (stderr.length() > 0) |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
235 |
System.err.println(stderr.toString()); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
236 |
return process.exitValue(); |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
237 |
} |
266ca40a0af2
8049694: Migrate functional AWT_DesktopProperties/Automated tests to OpenJDK
dermashov
parents:
diff
changeset
|
238 |
} |