author | serb |
Wed, 21 Feb 2018 12:49:00 -0800 | |
changeset 49096 | eaef201ec301 |
parent 47216 | 71c04702a3d5 |
child 51637 | e9177e7749e7 |
permissions | -rw-r--r-- |
29898 | 1 |
/* |
2 |
* Copyright (c) 2015, 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 |
/* @test |
|
25 |
@bug 8072769 |
|
49096
eaef201ec301
8198333: ProblemList should be updated for headless mode
serb
parents:
47216
diff
changeset
|
26 |
@key headful |
eaef201ec301
8198333: ProblemList should be updated for headless mode
serb
parents:
47216
diff
changeset
|
27 |
@requires (os.family == "windows") |
29898 | 28 |
@summary System tray icon title freezes java |
29 |
@author Semyon Sadetsky |
|
30 |
@library ../../../../lib/testlibrary |
|
31 |
@build jdk.testlibrary.OSInfo |
|
30783
e664daa546bb
8079440: [TESTBUG] @run is missing in java/awt/TrayIcon/8072769/bug8072769.java
sgupta
parents:
29898
diff
changeset
|
32 |
@run main bug8072769 |
29898 | 33 |
*/ |
34 |
||
35 |
import jdk.testlibrary.OSInfo; |
|
36 |
||
37 |
import javax.swing.*; |
|
38 |
import java.awt.*; |
|
39 |
import java.util.Arrays; |
|
40 |
||
41 |
public class bug8072769 { |
|
42 |
||
43 |
public static void main(String[] args) throws Exception { |
|
44 |
if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS) { |
|
45 |
if (SystemTray.isSupported()) { |
|
46 |
test(); |
|
47 |
} else { |
|
48 |
System.out.println("SystemTray not supported. " + |
|
49 |
"Test is skipped."); |
|
50 |
} |
|
51 |
} else { |
|
52 |
System.out.println("Test will only run on Windows platform. " + |
|
53 |
"Test is skipped."); |
|
54 |
} |
|
55 |
System.out.println("ok"); |
|
56 |
} |
|
57 |
||
58 |
private static void test() throws Exception { |
|
59 |
SwingUtilities.invokeAndWait(new Runnable() { |
|
60 |
public void run() { |
|
61 |
final SystemTray tray = SystemTray.getSystemTray(); |
|
62 |
final TrayIcon trayIcon = new TrayIcon(icon.getImage()); |
|
63 |
try { |
|
64 |
tray.add(trayIcon); |
|
65 |
} catch (AWTException e) { |
|
66 |
throw new RuntimeException( |
|
67 |
"TrayIcon could not be added."); |
|
68 |
} |
|
69 |
||
70 |
||
71 |
try { |
|
72 |
trayIcon.displayMessage(createString(63, 'A'), |
|
73 |
createString(255, 'C'), TrayIcon.MessageType.ERROR); |
|
74 |
||
75 |
trayIcon.setToolTip(createString(127, 'B')); |
|
76 |
||
77 |
trayIcon.displayMessage(createString(64, 'A'), |
|
78 |
createString(256, 'C'), TrayIcon.MessageType.ERROR); |
|
79 |
||
80 |
trayIcon.setToolTip(createString(128, 'B')); |
|
81 |
||
82 |
trayIcon.displayMessage(createString(65, 'A'), |
|
83 |
createString(257, 'C'), TrayIcon.MessageType.ERROR); |
|
84 |
||
85 |
trayIcon.setToolTip(createString(129, 'B')); |
|
86 |
} |
|
87 |
finally { |
|
88 |
tray.remove(trayIcon); |
|
89 |
} |
|
90 |
} |
|
91 |
}); |
|
92 |
} |
|
93 |
||
94 |
private static String createString(int len, char letter) { |
|
95 |
char[] chars = new char[len]; |
|
96 |
Arrays.fill(chars, letter); |
|
97 |
chars[len - 2] = '='; |
|
98 |
chars[len - 1] = '>'; |
|
99 |
return new String(chars); |
|
100 |
} |
|
101 |
||
102 |
private static ImageIcon icon = new ImageIcon( |
|
103 |
new byte[]{71, 73, 70, 56, 57, 97, 32, 0, 35, 0, -43, 0, 0, -1, -1, |
|
104 |
-1, -19, -101, 9, -18, -95, 24, -14, -76, 71, -4, -19, -46, |
|
105 |
-3, -13, -31, -17, -88, 40, -12, -63, 102, -10, -51, -124, |
|
106 |
-16, -82, 55, -11, -57, 117, -2, -7, -15, -7, -32, -77, -9, |
|
107 |
-45, -108, -5, -26, -62, -13, -70, 86, -8, -39, -94, 83, |
|
108 |
-126, -95, -8, -38, -93, -6, -26, -63, -9, -45, -109, -4, |
|
109 |
-14, -32, -15, -76, 70, -12, -58, 116, -17, -89, 39, 77, |
|
110 |
121, -106, -3, -8, -17, 104, -111, -84, 126, -95, -72, 93, |
|
111 |
-119, -90, -14, -70, 85, -13, -64, 101, -16, -83, 55, -109, |
|
112 |
-80, -60, -7, -33, -78, -100, -84, -85, 94, -127, -104, -32, |
|
113 |
-99, 39, 127, -120, -114, 83, 113, -124, -12, -9, -7, -16, |
|
114 |
-16, -16, -115, 108, 45, 57, 89, 110, -50, -41, -35, 104, |
|
115 |
-111, -83, 41, 65, 80, 72, 113, -116, 115, -103, -78, 88, |
|
116 |
106, 112, -82, -78, -82, -45, -38, -40, -5, -20, -48, -65, |
|
117 |
-48, -36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
|
118 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, -7, 4, 0, 0, 0, |
|
119 |
0, 0, 44, 0, 0, 0, 0, 32, 0, 35, 0, 0, 6, -1, 64, -128, 112, |
|
120 |
72, 4, 16, 0, 14, -57, 2, 1, 96, 30, -117, -48, 40, -78, |
|
121 |
-55, 96, 28, 28, -125, -62, 0, 96, 48, 74, -91, -116, 102, |
|
122 |
3, 97, 64, 4, 20, -25, -128, 68, -80, 16, 24, 11, 95, 98, |
|
123 |
-29, -64, 72, 11, 2, 120, -68, 96, -64, 39, 116, -29, 0, 12, |
|
124 |
13, 5, 1, 3, 121, -121, -120, 9, 2, 7, 5, 15, 82, 11, 11, |
|
125 |
92, 15, 6, -120, -107, -121, 7, 2, 18, 0, 112, 80, 3, 8, |
|
126 |
104, -106, -95, 122, 88, 97, 68, 5, 11, 4, -95, 32, 8, 16, |
|
127 |
19, 16, 8, 22, -106, -114, 79, 66, 5, 2, 15, 9, -120, 22, |
|
128 |
19, 81, 21, 31, -120, 7, 6, 10, 67, 71, 4, 119, -121, 20, |
|
129 |
-128, 16, -57, 120, 7, -101, -111, -58, 9, -108, 121, -55, |
|
130 |
-128, 0, 16, 121, 123, -117, 67, 5, -71, 121, 30, -42, 67, |
|
131 |
23, -121, 13, 66, 14, 6, 3, -34, 120, 21, -31, 66, 26, -39, |
|
132 |
3, 6, -50, 11, -96, 120, 31, -19, 67, 30, 121, 9, 14, 0, 13, |
|
133 |
124, -121, 68, -32, 19, 98, 6, 15, 58, 71, 18, 12, -27, 97, |
|
134 |
55, 80, 68, 54, 5, 5, 24, 40, 80, 23, 96, -96, -112, 9, -39, |
|
135 |
30, 52, -112, 72, -47, 34, 0, 10, 25, -53, 37, 60, -60, 16, |
|
136 |
-33, 56, 61, 16, -1, 41, -60, 83, 13, 31, -122, 60, 7, 1, |
|
137 |
-48, 59, -124, 65, 3, 62, -116, 48, -5, 57, 72, -112, -18, |
|
138 |
-48, 5, -103, 124, 32, -32, 37, 112, -74, -119, 98, 0, 8, |
|
139 |
-31, 64, -110, 35, 38, 64, 26, 34, -92, 113, 42, 48, -45, |
|
140 |
70, -76, 24, -77, 60, 80, -91, -60, -70, -12, 76, -120, 49, |
|
141 |
92, -120, 4, -40, -116, -126, 51, 79, -80, 97, -36, 80, 89, |
|
142 |
-6, 25, -91, 96, -98, 89, -99, 62, 33, -62, 32, -59, -83, 0, |
|
143 |
82, 80, 32, 1, -72, 53, 13, -113, -42, 102, -103, 54, -127, |
|
144 |
25, 84, 40, 15, -115, 40, 37, 20, 49, 34, 26, 103, 78, 29, |
|
145 |
52, 42, 88, 16, 65, 17, -94, -49, 31, 107, 97, 16, -116, 49, |
|
146 |
32, 35, -61, 6, 14, 33, 56, 68, -120, -80, -96, 11, 1, 78, |
|
147 |
-31, -6, 33, 96, 48, -93, -61, -122, 21, 46, 50, -116, -10, |
|
148 |
-30, -47, -117, -125, 24, 29, 94, -100, -112, 61, -94, 54, |
|
149 |
-108, 20, 38, 90, -112, -128, 81, -61, 90, 16, 0, 59}, |
|
150 |
"try icon"); |
|
151 |
||
152 |
} |