author | goetz |
Tue, 14 Jun 2016 10:44:59 +0200 | |
changeset 39056 | d99e63b6d962 |
parent 33506 | 6e0fca73abc9 |
permissions | -rw-r--r-- |
33506
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
1 |
/* |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
4 |
* |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
8 |
* |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
13 |
* accompanied this code). |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
14 |
* |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
18 |
* |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
21 |
* questions. |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
22 |
*/ |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
23 |
|
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
33506
diff
changeset
|
24 |
/* |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
33506
diff
changeset
|
25 |
* @test |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
33506
diff
changeset
|
26 |
* @key headful |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
33506
diff
changeset
|
27 |
* @bug 8011616 |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
33506
diff
changeset
|
28 |
* @summary JWindow.getLocation and JWindow.getLocationOnScreen return different |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
33506
diff
changeset
|
29 |
* values on Unity |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
33506
diff
changeset
|
30 |
* @author Semyon Sadetsky |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
33506
diff
changeset
|
31 |
*/ |
33506
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
32 |
|
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
33 |
import java.awt.*; |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
34 |
|
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
35 |
public class ScreenLocationTest { |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
36 |
|
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
37 |
|
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
38 |
public static void main(String[] args) throws Exception { |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
39 |
testLocation(); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
40 |
testSize(); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
41 |
System.out.println("ok"); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
42 |
} |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
43 |
|
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
44 |
public static void testLocation() throws Exception { |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
45 |
Window window = new Window((Frame) null); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
46 |
window.setSize(100, 100); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
47 |
window.setLocation(0, 0); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
48 |
window.setVisible(true); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
49 |
|
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
50 |
Robot robot = new Robot(); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
51 |
robot.delay(200); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
52 |
robot.waitForIdle(); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
53 |
|
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
54 |
Point location1 = window.getLocation(); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
55 |
Point location2 = window.getLocationOnScreen(); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
56 |
window.setLocation(10000, 10000); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
57 |
|
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
58 |
if (!location1.equals(location2)) { |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
59 |
window.dispose(); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
60 |
throw new RuntimeException("getLocation is different"); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
61 |
} |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
62 |
|
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
63 |
robot.delay(200); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
64 |
robot.waitForIdle(); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
65 |
location1 = window.getLocation(); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
66 |
location2 = window.getLocationOnScreen(); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
67 |
|
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
68 |
if (!location1.equals(location2)) { |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
69 |
window.dispose(); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
70 |
throw new RuntimeException("getLocation is different"); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
71 |
} |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
72 |
|
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
73 |
window.dispose(); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
74 |
} |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
75 |
|
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
76 |
public static void testSize() throws Exception { |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
77 |
Window window = new Window((Frame) null); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
78 |
window.setSize(Integer.MAX_VALUE, Integer.MAX_VALUE); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
79 |
window.setVisible(true); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
80 |
|
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
81 |
Robot robot = new Robot(); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
82 |
robot.delay(200); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
83 |
robot.waitForIdle(); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
84 |
|
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
85 |
Dimension size = window.getSize(); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
86 |
if (size.width == Integer.MAX_VALUE || |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
87 |
size.height == Integer.MAX_VALUE) { |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
88 |
window.dispose(); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
89 |
throw new RuntimeException("size is wrong"); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
90 |
} |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
91 |
|
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
92 |
window.dispose(); |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
93 |
} |
6e0fca73abc9
8011616: JWindow.getLocation and JWindow.getLocationOnScreen return different values on Unity
ssadetsky
parents:
diff
changeset
|
94 |
} |