author | yan |
Mon, 10 Nov 2014 16:23:30 +0300 | |
changeset 27763 | 1fba965925e8 |
parent 21272 | aac4dd1cd15d |
child 40128 | e635645d2a8a |
permissions | -rw-r--r-- |
21272
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
1 |
/* |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
4 |
* |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
8 |
* |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
13 |
* accompanied this code). |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
14 |
* |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
18 |
* |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
21 |
* questions. |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
22 |
*/ |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
23 |
|
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
24 |
/* @test |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
25 |
* @bug 8027025 |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
26 |
* @summary [macosx] getLocationOnScreen returns 0 if parent invisible |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
27 |
* @author Petr Pchelko |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
28 |
* @run main Test8027025 |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
29 |
*/ |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
30 |
|
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
31 |
import javax.swing.*; |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
32 |
import java.awt.*; |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
33 |
import java.util.concurrent.atomic.AtomicReference; |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
34 |
|
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
35 |
public class Test8027025 { |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
36 |
|
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
37 |
private static Frame frame; |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
38 |
private static Window window; |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
39 |
|
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
40 |
public static void main(String[] args) throws Exception { |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
41 |
try { |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
42 |
SwingUtilities.invokeAndWait(() -> { |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
43 |
frame = new Frame("Dummy Frame"); |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
44 |
window = new Window(frame); |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
45 |
window.setSize(200, 200); |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
46 |
window.setLocationRelativeTo(frame); |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
47 |
window.setVisible(true); |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
48 |
}); |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
49 |
|
27763
1fba965925e8
8063102: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 1
yan
parents:
21272
diff
changeset
|
50 |
Robot robot = new Robot(); |
1fba965925e8
8063102: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 1
yan
parents:
21272
diff
changeset
|
51 |
robot.waitForIdle(); |
21272
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
52 |
|
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
53 |
AtomicReference<Point> point = new AtomicReference<>(); |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
54 |
SwingUtilities.invokeAndWait(() -> point.set(window.getLocationOnScreen())); |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
55 |
|
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
56 |
if (point.get().getX() == 0 || point.get().getY() == 0) { |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
57 |
throw new RuntimeException("Test failed. The location was not set"); |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
58 |
} |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
59 |
} finally { |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
60 |
if (frame != null) { |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
61 |
frame.dispose(); |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
62 |
} |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
63 |
if (window != null) { |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
64 |
window.dispose(); |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
65 |
} |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
66 |
} |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
67 |
} |
aac4dd1cd15d
8027025: [macosx] getLocationOnScreen returns 0 if parent invisible
pchelko
parents:
diff
changeset
|
68 |
} |