author | rchamyal |
Wed, 17 Aug 2016 14:48:13 +0530 | |
changeset 40704 | 357253747dae |
parent 39848 | e06eb1994d3d |
permissions | -rw-r--r-- |
39848
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
1 |
/* |
40704
357253747dae
8161913: [PIT] java/awt/Window/8159168/SetShapeTest.java mostly fails
rchamyal
parents:
39848
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
357253747dae
8161913: [PIT] java/awt/Window/8159168/SetShapeTest.java mostly fails
rchamyal
parents:
39848
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
357253747dae
8161913: [PIT] java/awt/Window/8159168/SetShapeTest.java mostly fails
rchamyal
parents:
39848
diff
changeset
|
4 |
* |
357253747dae
8161913: [PIT] java/awt/Window/8159168/SetShapeTest.java mostly fails
rchamyal
parents:
39848
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
357253747dae
8161913: [PIT] java/awt/Window/8159168/SetShapeTest.java mostly fails
rchamyal
parents:
39848
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
357253747dae
8161913: [PIT] java/awt/Window/8159168/SetShapeTest.java mostly fails
rchamyal
parents:
39848
diff
changeset
|
7 |
* published by the Free Software Foundation. |
357253747dae
8161913: [PIT] java/awt/Window/8159168/SetShapeTest.java mostly fails
rchamyal
parents:
39848
diff
changeset
|
8 |
* |
357253747dae
8161913: [PIT] java/awt/Window/8159168/SetShapeTest.java mostly fails
rchamyal
parents:
39848
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
357253747dae
8161913: [PIT] java/awt/Window/8159168/SetShapeTest.java mostly fails
rchamyal
parents:
39848
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
357253747dae
8161913: [PIT] java/awt/Window/8159168/SetShapeTest.java mostly fails
rchamyal
parents:
39848
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
357253747dae
8161913: [PIT] java/awt/Window/8159168/SetShapeTest.java mostly fails
rchamyal
parents:
39848
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
357253747dae
8161913: [PIT] java/awt/Window/8159168/SetShapeTest.java mostly fails
rchamyal
parents:
39848
diff
changeset
|
13 |
* accompanied this code). |
357253747dae
8161913: [PIT] java/awt/Window/8159168/SetShapeTest.java mostly fails
rchamyal
parents:
39848
diff
changeset
|
14 |
* |
357253747dae
8161913: [PIT] java/awt/Window/8159168/SetShapeTest.java mostly fails
rchamyal
parents:
39848
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
357253747dae
8161913: [PIT] java/awt/Window/8159168/SetShapeTest.java mostly fails
rchamyal
parents:
39848
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
357253747dae
8161913: [PIT] java/awt/Window/8159168/SetShapeTest.java mostly fails
rchamyal
parents:
39848
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
357253747dae
8161913: [PIT] java/awt/Window/8159168/SetShapeTest.java mostly fails
rchamyal
parents:
39848
diff
changeset
|
18 |
* |
357253747dae
8161913: [PIT] java/awt/Window/8159168/SetShapeTest.java mostly fails
rchamyal
parents:
39848
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
357253747dae
8161913: [PIT] java/awt/Window/8159168/SetShapeTest.java mostly fails
rchamyal
parents:
39848
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
357253747dae
8161913: [PIT] java/awt/Window/8159168/SetShapeTest.java mostly fails
rchamyal
parents:
39848
diff
changeset
|
21 |
* questions. |
39848
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
22 |
*/ |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
23 |
|
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
24 |
/** |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
25 |
* @test |
40704
357253747dae
8161913: [PIT] java/awt/Window/8159168/SetShapeTest.java mostly fails
rchamyal
parents:
39848
diff
changeset
|
26 |
* @key headful |
357253747dae
8161913: [PIT] java/awt/Window/8159168/SetShapeTest.java mostly fails
rchamyal
parents:
39848
diff
changeset
|
27 |
* @bug 8159168 8161913 |
39848
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
28 |
* @summary [hidpi] Window.setShape() works incorrectly on HiDPI |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
29 |
* @run main/othervm -Dsun.java2d.uiScale=2 SetShapeTest |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
30 |
*/ |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
31 |
import java.awt.BorderLayout; |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
32 |
import java.awt.Color; |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
33 |
import java.awt.Frame; |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
34 |
import java.awt.Panel; |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
35 |
import java.awt.Rectangle; |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
36 |
import java.awt.Window; |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
37 |
import java.awt.geom.Area; |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
38 |
import java.awt.geom.Rectangle2D; |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
39 |
import java.awt.Robot; |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
40 |
import javax.swing.SwingUtilities; |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
41 |
|
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
42 |
public class SetShapeTest { |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
43 |
|
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
44 |
private static Window window; |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
45 |
private static Frame background; |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
46 |
|
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
47 |
public static void main(String[] args) throws Exception { |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
48 |
createUI(); |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
49 |
Robot robot = new Robot(); |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
50 |
robot.waitForIdle(); |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
51 |
Rectangle rect = window.getBounds(); |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
52 |
rect.x += rect.width - 10; |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
53 |
rect.y += rect.height - 10; |
40704
357253747dae
8161913: [PIT] java/awt/Window/8159168/SetShapeTest.java mostly fails
rchamyal
parents:
39848
diff
changeset
|
54 |
robot.delay(1000); |
39848
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
55 |
Color c = robot.getPixelColor(rect.x, rect.y); |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
56 |
try { |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
57 |
if (!c.equals(Color.RED)) { |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
58 |
throw new RuntimeException("Test Failed"); |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
59 |
} |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
60 |
} finally { |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
61 |
SwingUtilities.invokeAndWait(new Runnable() { |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
62 |
@Override |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
63 |
public void run() { |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
64 |
background.dispose(); |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
65 |
window.dispose(); |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
66 |
} |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
67 |
}); |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
68 |
} |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
69 |
} |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
70 |
|
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
71 |
private static void createUI() throws Exception { |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
72 |
SwingUtilities.invokeAndWait(new Runnable() { |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
73 |
@Override |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
74 |
public void run() { |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
75 |
background = new Frame(); |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
76 |
background.setUndecorated(true); |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
77 |
background.setBackground(Color.blue); |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
78 |
background.setSize(300, 300); |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
79 |
background.setLocation(100, 100); |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
80 |
background.setVisible(true); |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
81 |
window = new Window(background); |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
82 |
window.setBackground(Color.red); |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
83 |
window.add(new Panel(), BorderLayout.CENTER); |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
84 |
window.setLocation(200, 200); |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
85 |
window.setSize(100, 100); |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
86 |
Area a = new Area(); |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
87 |
a.add(new Area(new Rectangle2D.Double(0, 0, 100, 100))); |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
88 |
window.setShape(a); |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
89 |
window.setVisible(true); |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
90 |
window.toFront(); |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
91 |
} |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
92 |
}); |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
93 |
} |
e06eb1994d3d
8159168: [hidpi] Window.setShape() works incorrectly on HiDPI
rchamyal
parents:
diff
changeset
|
94 |
} |