author | goetz |
Tue, 14 Jun 2016 10:44:59 +0200 | |
changeset 39056 | d99e63b6d962 |
parent 26750 | d0d6c64a2e2b |
permissions | -rw-r--r-- |
23285
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
1 |
/* |
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
26750
diff
changeset
|
2 |
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. |
23285
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
4 |
* |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
8 |
* |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
13 |
* accompanied this code). |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
14 |
* |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
18 |
* |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
21 |
* questions. |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
22 |
*/ |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
23 |
|
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
24 |
/* |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
25 |
@test |
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
26750
diff
changeset
|
26 |
@key headful |
23285
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
27 |
@bug 8020443 |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
28 |
@summary Frame is not created on the specified GraphicsDevice with two |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
29 |
monitors |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
30 |
@author Oleg Pekhovskiy |
26750
d0d6c64a2e2b
8058726: Update regtests using sun.awt.OSInfo, part 1
yan
parents:
23285
diff
changeset
|
31 |
@library ../../../../lib/testlibrary |
d0d6c64a2e2b
8058726: Update regtests using sun.awt.OSInfo, part 1
yan
parents:
23285
diff
changeset
|
32 |
@build jdk.testlibrary.OSInfo |
23285
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
33 |
@run main MultiScreenInsetsTest |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
34 |
*/ |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
35 |
|
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
36 |
import java.awt.Frame; |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
37 |
import java.awt.GraphicsConfiguration; |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
38 |
import java.awt.GraphicsDevice; |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
39 |
import java.awt.GraphicsEnvironment; |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
40 |
import java.awt.Insets; |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
41 |
import java.awt.Rectangle; |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
42 |
import java.awt.Toolkit; |
26750
d0d6c64a2e2b
8058726: Update regtests using sun.awt.OSInfo, part 1
yan
parents:
23285
diff
changeset
|
43 |
import jdk.testlibrary.OSInfo; |
23285
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
44 |
|
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
45 |
public class MultiScreenInsetsTest { |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
46 |
private static final int SIZE = 100; |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
47 |
|
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
48 |
public static void main(String[] args) throws InterruptedException { |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
49 |
OSInfo.OSType type = OSInfo.getOSType(); |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
50 |
if (type != OSInfo.OSType.LINUX && type != OSInfo.OSType.SOLARIS) { |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
51 |
System.out.println("This test is for Solaris and Linux only..." + |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
52 |
"skipping!"); |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
53 |
return; |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
54 |
} |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
55 |
|
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
56 |
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
57 |
GraphicsDevice[] gds = ge.getScreenDevices(); |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
58 |
if (gds.length < 2) { |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
59 |
System.out.println("It's a multi-screen test... skipping!"); |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
60 |
return; |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
61 |
} |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
62 |
|
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
63 |
for (int screen = 0; screen < gds.length; ++screen) { |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
64 |
GraphicsDevice gd = gds[screen]; |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
65 |
GraphicsConfiguration gc = gd.getDefaultConfiguration(); |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
66 |
Rectangle bounds = gc.getBounds(); |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
67 |
Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc); |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
68 |
|
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
69 |
Frame frame = new Frame(gc); |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
70 |
frame.setLocation(bounds.x + (bounds.width - SIZE) / 2, |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
71 |
bounds.y + (bounds.height - SIZE) / 2); |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
72 |
frame.setSize(SIZE, SIZE); |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
73 |
frame.setUndecorated(true); |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
74 |
frame.setVisible(true); |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
75 |
|
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
76 |
// Maximize Frame to reach the struts |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
77 |
frame.setExtendedState(java.awt.Frame.MAXIMIZED_BOTH); |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
78 |
Thread.sleep(2000); |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
79 |
|
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
80 |
Rectangle frameBounds = frame.getBounds(); |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
81 |
frame.dispose(); |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
82 |
if (bounds.x + insets.left != frameBounds.x |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
83 |
|| bounds.y + insets.top != frameBounds.y |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
84 |
|| bounds.width - insets.right - insets.left != frameBounds.width |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
85 |
|| bounds.height - insets.bottom - insets.top != frameBounds.height) { |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
86 |
throw new RuntimeException("Test FAILED! Wrong screen #" + |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
87 |
screen + " insets: " + insets); |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
88 |
} |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
89 |
} |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
90 |
System.out.println("Test PASSED!"); |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
91 |
} |
ae856aaa48b0
8020443: Frame is not created on the specified GraphicsDevice with two monitors
bagiras
parents:
diff
changeset
|
92 |
} |