author | goetz |
Tue, 14 Jun 2016 10:44:59 +0200 | |
changeset 39056 | d99e63b6d962 |
parent 28087 | 622b2f420bc3 |
permissions | -rw-r--r-- |
23316
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
1 |
/* |
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
28087
diff
changeset
|
2 |
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. |
23316
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
4 |
* |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
8 |
* |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
13 |
* accompanied this code). |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
14 |
* |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
18 |
* |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
21 |
* questions. |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
22 |
*/ |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
23 |
|
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
24 |
/* |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
25 |
@test |
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
28087
diff
changeset
|
26 |
@key headful |
23316
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
27 |
@bug 8017472 |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
28 |
@summary MouseEvent has wrong coordinates when using multiple monitors |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
29 |
@run main MouseEventTest |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
30 |
*/ |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
31 |
|
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
32 |
import java.awt.*; |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
33 |
import java.awt.event.MouseAdapter; |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
34 |
import java.awt.event.MouseEvent; |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
35 |
|
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
36 |
public class MouseEventTest { |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
37 |
static volatile boolean crossed = false; |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
38 |
|
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
23316
diff
changeset
|
39 |
static void sleep(Robot robot) throws InterruptedException { |
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
23316
diff
changeset
|
40 |
robot.waitForIdle(); |
23316
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
41 |
Thread.sleep(500); |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
42 |
} |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
43 |
|
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
44 |
public static void main(String[] args) throws AWTException, InterruptedException { |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
45 |
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
46 |
GraphicsDevice[] gds = ge.getScreenDevices(); |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
47 |
if (gds.length < 2) { |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
48 |
System.out.println("It's a multiscreen test... skipping!"); |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
49 |
return; |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
50 |
} |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
51 |
|
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
52 |
for (int i = 0; i < gds.length; ++i) { |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
53 |
GraphicsDevice gd = gds[i]; |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
54 |
GraphicsConfiguration gc = gd.getDefaultConfiguration(); |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
55 |
Rectangle screen = gc.getBounds(); |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
56 |
Robot robot = new Robot(gd); |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
57 |
robot.setAutoDelay(100); |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
58 |
|
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
59 |
|
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
60 |
Frame frame = new Frame(gc); |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
61 |
frame.setUndecorated(true); |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
62 |
frame.setSize(200, 200); |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
63 |
frame.setLocation(screen.x + 200, screen.y + 200); |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
64 |
frame.setBackground(Color.YELLOW); |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
65 |
frame.setVisible(true); |
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
23316
diff
changeset
|
66 |
sleep(robot); |
23316
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
67 |
|
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
68 |
Point loc = frame.getLocationOnScreen(); |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
69 |
Dimension size = frame.getSize(); |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
70 |
final Point point = new Point( |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
71 |
loc.x + size.width / 2, |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
72 |
loc.y + size.height / 2); |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
73 |
|
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
74 |
crossed = false; |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
75 |
|
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
76 |
frame.addMouseMotionListener(new MouseAdapter() { |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
77 |
@Override |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
78 |
public void mouseMoved(MouseEvent e) { |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
79 |
if (point.equals(e.getLocationOnScreen())) { |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
80 |
crossed = true; |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
81 |
} |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
82 |
} |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
83 |
}); |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
84 |
|
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
85 |
robot.mouseMove(point.x - 1, point.y - 1); |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
86 |
robot.mouseMove(point.x, point.y); |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
87 |
|
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
23316
diff
changeset
|
88 |
sleep(robot); |
23316
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
89 |
frame.dispose(); |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
90 |
|
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
91 |
if (!crossed) { |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
92 |
throw new RuntimeException("An expected mouse motion event was not received on the screen #" + i); |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
93 |
} |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
94 |
} |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
95 |
|
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
96 |
System.out.println("Test PASSED!"); |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
97 |
} |
e14d8640b158
8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents:
diff
changeset
|
98 |
} |