author | goetz |
Tue, 14 Jun 2016 10:44:59 +0200 | |
changeset 39056 | d99e63b6d962 |
parent 25559 | a101ec6ccfd3 |
permissions | -rw-r--r-- |
25559
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
1 |
/* |
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
25559
diff
changeset
|
2 |
* Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. |
25559
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
4 |
* |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
8 |
* |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
13 |
* accompanied this code). |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
14 |
* |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
18 |
* |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
21 |
* questions. |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
22 |
*/ |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
23 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
24 |
import java.awt.*; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
25 |
import java.awt.event.ComponentAdapter; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
26 |
import java.awt.event.ComponentEvent; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
27 |
import java.awt.event.MouseAdapter; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
28 |
import java.awt.event.MouseEvent; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
29 |
import java.awt.geom.Area; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
30 |
import java.awt.geom.GeneralPath; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
31 |
import java.awt.geom.Rectangle2D; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
32 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
33 |
/* |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
34 |
* @test |
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
25559
diff
changeset
|
35 |
* @key headful |
25559
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
36 |
* @summary Check if a window set with shape clips the contents |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
37 |
* |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
38 |
* Test Description: Check if PERPIXEL_TRANSPARENT Translucency type is supported |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
39 |
* by the current platform. Proceed if it is supported. Apply different types |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
40 |
* of shapes on a Window which contains some awt components. Shape should be |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
41 |
* applied in such a way that some components are partially clipped off. Check |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
42 |
* if the components appear only partially and events work correctly for those |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
43 |
* components - i.e. events occur only on the areas which appear and do not |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
44 |
* occur on the clipped off areas. Events should be checked by clicking on the |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
45 |
* visible and clipped regions. Repeat this for Window, Dialog and Frame. |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
46 |
* Expected Result: If PERPIXEL_TRANSPARENT Translucency type is supported, clicking |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
47 |
* on clipped region should deliver the event to the background (it should be |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
48 |
* another Window behind the test window) |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
49 |
* |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
50 |
* @author mrkam |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
51 |
* @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com) |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
52 |
* @library ../../../../lib/testlibrary |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
53 |
* @build Common ExtendedRobot |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
54 |
* @run main SetShapeAndClick |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
55 |
*/ |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
56 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
57 |
public class SetShapeAndClick extends Common { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
58 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
59 |
Component south, center, north; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
60 |
volatile int clicked; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
61 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
62 |
public static void main(String[] args) throws Exception { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
63 |
if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT)) |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
64 |
for (Class<Window> windowClass: WINDOWS_TO_TEST) |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
65 |
new SetShapeAndClick(windowClass).doTest(); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
66 |
} |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
67 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
68 |
public SetShapeAndClick(Class windowClass) throws Exception { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
69 |
super(windowClass); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
70 |
} |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
71 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
72 |
@Override |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
73 |
public void initBackgroundFrame() { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
74 |
super.initBackgroundFrame(); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
75 |
background.addMouseListener(new MouseAdapter() { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
76 |
@Override |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
77 |
public void mouseClicked(MouseEvent e) { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
78 |
clicked |= 1 << 0; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
79 |
} |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
80 |
}); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
81 |
} |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
82 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
83 |
@Override |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
84 |
public void initGUI() { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
85 |
if (windowClass.equals(Frame.class)) { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
86 |
window = new Frame(); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
87 |
((Frame) window).setUndecorated(true); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
88 |
} else if (windowClass.equals(Dialog.class)) { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
89 |
window = new Dialog(background); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
90 |
((Dialog) window).setUndecorated(true); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
91 |
} else { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
92 |
window = new Window(background); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
93 |
} |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
94 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
95 |
window.setLocation(2 * dl, 2 * dl); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
96 |
window.setPreferredSize(new Dimension(200, 200)); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
97 |
window.setLayout(new BorderLayout()); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
98 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
99 |
window.addComponentListener(new ComponentAdapter() { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
100 |
public void componentResized(ComponentEvent e) { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
101 |
applyShape(); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
102 |
} |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
103 |
}); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
104 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
105 |
south = new Label("South"); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
106 |
south.addMouseListener(new MouseAdapter() { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
107 |
@Override |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
108 |
public void mouseClicked(MouseEvent e) { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
109 |
clicked |= 1 << 3; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
110 |
} |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
111 |
}); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
112 |
window.add(south, BorderLayout.SOUTH); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
113 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
114 |
center = new List(5); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
115 |
center.addMouseListener(new MouseAdapter() { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
116 |
@Override |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
117 |
public void mouseClicked(MouseEvent e) { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
118 |
clicked |= 1 << 2; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
119 |
} |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
120 |
}); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
121 |
window.add(center, BorderLayout.CENTER); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
122 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
123 |
north = new TextField("North"); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
124 |
north.addMouseListener(new MouseAdapter() { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
125 |
@Override |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
126 |
public void mouseClicked(MouseEvent e) { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
127 |
clicked |= 1 << 1; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
128 |
} |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
129 |
}); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
130 |
window.add(north, BorderLayout.NORTH); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
131 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
132 |
window.pack(); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
133 |
window.setVisible(true); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
134 |
window.toFront(); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
135 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
136 |
System.out.println("Checking " + window.getClass().getName() + "..."); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
137 |
} |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
138 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
139 |
@Override |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
140 |
public void doTest() throws Exception { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
141 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
142 |
robot.waitForIdle(); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
143 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
144 |
Point wls = window.getLocationOnScreen(); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
145 |
Point ls; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
146 |
int y; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
147 |
ls = north.getLocationOnScreen(); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
148 |
checkClick(ls.x + north.getWidth() / 3, ls.y + north.getHeight() / 2, 1); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
149 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
150 |
ls = center.getLocationOnScreen(); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
151 |
checkClick(ls.x + center.getWidth() * 3 / 4, ls.y + center.getHeight() * 3 / 4, 2); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
152 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
153 |
ls = south.getLocationOnScreen(); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
154 |
checkClick(ls.x + south.getWidth() * 2 / 3, ls.y + south.getHeight() / 2, 3); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
155 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
156 |
ls = center.getLocationOnScreen(); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
157 |
checkClick(ls.x + center.getWidth() / 4, ls.y + center.getHeight() / 4, 2); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
158 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
159 |
ls = north.getLocationOnScreen(); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
160 |
y = ls.y + north.getHeight() / 2; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
161 |
checkClick(wls.x + 200 - (y - wls.y), y, 0); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
162 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
163 |
EventQueue.invokeAndWait(window::toFront); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
164 |
robot.waitForIdle(); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
165 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
166 |
ls = center.getLocationOnScreen(); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
167 |
y = ls.y + center.getHeight() / 2; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
168 |
checkClick(wls.x + 200 - (y - wls.y), y, 0); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
169 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
170 |
EventQueue.invokeAndWait(window::toFront); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
171 |
robot.waitForIdle(); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
172 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
173 |
ls = south.getLocationOnScreen(); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
174 |
y = ls.y + south.getHeight() / 2; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
175 |
checkClick(wls.x + 200 - (y - wls.y), y, 0); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
176 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
177 |
EventQueue.invokeAndWait(window::dispose); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
178 |
EventQueue.invokeAndWait(background::dispose); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
179 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
180 |
robot.waitForIdle(); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
181 |
} |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
182 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
183 |
@Override |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
184 |
public void applyShape() { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
185 |
Area shape = new Area(new Rectangle2D.Float(0, 0, 200, 200)); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
186 |
GeneralPath gp; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
187 |
gp = new GeneralPath(); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
188 |
gp.moveTo(190, 0); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
189 |
gp.lineTo(200, 0); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
190 |
gp.lineTo(200, 10); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
191 |
gp.lineTo(10, 200); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
192 |
gp.lineTo(0, 200); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
193 |
gp.lineTo(0, 190); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
194 |
gp.closePath(); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
195 |
shape.subtract(new Area(gp)); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
196 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
197 |
window.setShape(shape); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
198 |
} |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
199 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
200 |
void checkClick(int x, int y, int flag) throws Exception { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
201 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
202 |
System.out.println("Trying to click point " + x + ", " + y + ", looking for " + flag + " flag to trigger."); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
203 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
204 |
clicked = 0; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
205 |
robot.mouseMove(x, y); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
206 |
robot.click(); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
207 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
208 |
for (int i = 0; i < 100; i++) |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
209 |
if ((clicked & (1 << flag)) == 0) |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
210 |
robot.delay(50); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
211 |
else |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
212 |
break; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
213 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
214 |
if ((clicked & (1 << flag)) == 0) |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
215 |
throw new RuntimeException("FAIL: Flag " + flag + " is not triggered for point " + x + ", " + y + "!"); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
216 |
} |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
217 |
} |