author | serb |
Wed, 21 Feb 2018 12:49:00 -0800 | |
changeset 49096 | eaef201ec301 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
25137
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
1 |
/* |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
2 |
* Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
4 |
* |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
8 |
* |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
13 |
* accompanied this code). |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
14 |
* |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
18 |
* |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
21 |
* questions. |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
22 |
*/ |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
23 |
|
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
24 |
import java.awt.*; |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
25 |
import java.awt.image.BufferedImage; |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
26 |
|
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
27 |
|
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
28 |
/* |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
29 |
* @test |
49096
eaef201ec301
8198333: ProblemList should be updated for headless mode
serb
parents:
47216
diff
changeset
|
30 |
* @key headful |
25137
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
31 |
* @summary Test the methods TrayIcon.getSize and SystemTray.getTrayIconSize. |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
32 |
* There is no way to check whether the values returned are correct, |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
33 |
* so its checked whether the value is greater than a minimum |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
34 |
* @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com) |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
35 |
* @run main TrayIconSizeTest |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
36 |
*/ |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
37 |
|
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
38 |
public class TrayIconSizeTest { |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
39 |
|
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
40 |
public static void main(String[] args) throws Exception { |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
41 |
if (! SystemTray.isSupported()) { |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
42 |
System.out.println("SystemTray not supported on the platform under test. " + |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
43 |
"Marking the test passed"); |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
44 |
} else { |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
45 |
new TrayIconSizeTest().doTest(); |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
46 |
} |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
47 |
} |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
48 |
|
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
49 |
void doTest() throws Exception { |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
50 |
|
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
51 |
SystemTray tray = SystemTray.getSystemTray(); |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
52 |
Dimension dim = tray.getTrayIconSize(); |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
53 |
|
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
54 |
if (dim.width <= 5 || dim.height <= 5) |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
55 |
throw new RuntimeException("FAIL: value returned by getTrayIconSize is not correct: " + dim); |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
56 |
|
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
57 |
TrayIcon icon = new TrayIcon(new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB)); |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
58 |
|
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
59 |
if (! icon.getSize().equals(dim)) |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
60 |
throw new RuntimeException("FAIL: TrayIcon.getSize did not return the same value as " + |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
61 |
"getTrayIconSize when TrayIcon not added" + "\n" + |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
62 |
"SystemTray.getTrayIconSize(): " + dim + "\n" + |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
63 |
"TrayIcon.getSize(): " + icon.getSize()); |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
64 |
|
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
65 |
tray.add(icon); |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
66 |
|
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
67 |
if (icon.getSize().width <= 5 || icon.getSize().height <= 5) |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
68 |
throw new RuntimeException("FAIL: value returned by TrayIcon.getSize is not correct: " + icon.getSize()); |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
69 |
} |
43055e2deee9
8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff
changeset
|
70 |
} |