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.MouseAdapter; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
26 |
import java.awt.event.MouseEvent; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
27 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
28 |
/* |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
29 |
* @test |
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
25559
diff
changeset
|
30 |
* @key headful |
25559
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
31 |
* @summary Check if a Choice present in a window set with opacity less than 1.0 |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
32 |
* shows a translucent drop down |
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 Description: Check if TRANSLUCENT Translucency type is supported on the |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
35 |
* current platform. Proceed if supported. Show a window which contains an |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
36 |
* awt Choice and set with opacity less than 1.0. Another Window having a |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
37 |
* canvas component drawn with an image can be used as the background for |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
38 |
* the test window. Click on the ComboBox to show the drop down. Check if |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
39 |
* the drop down appears translucent. Repeat this for Window, Dialog and |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
40 |
* Frame. |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
41 |
* Expected Result: If TRANSLUCENT Translucency type is supported, the drop down |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
42 |
* should appear translucent. |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
43 |
* |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
44 |
* @author mrkam |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
45 |
* @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com) |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
46 |
* @library ../../../../lib/testlibrary |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
47 |
* @build Common ExtendedRobot |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
48 |
* @run main TranslucentChoice |
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 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
51 |
public class TranslucentChoice extends Common { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
52 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
53 |
Choice south; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
54 |
Component center; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
55 |
Component north; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
56 |
volatile int clicked; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
57 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
58 |
public static void main(String[] ignored) throws Exception { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
59 |
if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.TRANSLUCENT)) |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
60 |
for (Class<Window> windowClass: WINDOWS_TO_TEST){ |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
61 |
new TranslucentChoice(windowClass).doTest(); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
62 |
} |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
63 |
} |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
64 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
65 |
public TranslucentChoice(Class windowClass) throws Exception { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
66 |
super(windowClass); |
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 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
69 |
@Override |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
70 |
public void initBackgroundFrame() { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
71 |
super.initBackgroundFrame(); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
72 |
background.addMouseListener(new MouseAdapter() { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
73 |
@Override |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
74 |
public void mouseClicked(MouseEvent e) { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
75 |
clicked |= 1 << 0; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
76 |
} |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
77 |
}); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
78 |
} |
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 |
@Override |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
81 |
public void initGUI() { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
82 |
if (windowClass.equals(Frame.class)) { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
83 |
window = new Frame(); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
84 |
((Frame) window).setUndecorated(true); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
85 |
} else if (windowClass.equals(Dialog.class)) { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
86 |
window = new Dialog(background); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
87 |
((Dialog) window).setUndecorated(true); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
88 |
} else { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
89 |
window = new Window(background); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
90 |
} |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
91 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
92 |
window.setBackground(FG_COLOR); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
93 |
north = new Button("north"); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
94 |
window.add(north, BorderLayout.NORTH); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
95 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
96 |
center = new List(5); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
97 |
window.add(center, BorderLayout.CENTER); |
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 |
Choice choice = new Choice(); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
100 |
for(int i = 0; i < 20; i++) { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
101 |
choice.add("item " + i); |
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 |
south = choice; |
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.addMouseListener(new MouseAdapter() { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
106 |
@Override |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
107 |
public void mouseClicked(MouseEvent e) { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
108 |
clicked |= 1 << 1; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
109 |
} |
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 |
window.setAlwaysOnTop(true); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
114 |
window.setOpacity(0.3f); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
115 |
window.setLocation(2 * dl, 2 * dl); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
116 |
window.setSize(255, 255); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
117 |
window.pack(); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
118 |
window.setVisible(true); |
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 |
System.out.println("Checking " + window.getClass().getName() + "..."); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
121 |
} |
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 |
@Override |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
124 |
public void doTest() throws Exception { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
125 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
126 |
Point ls = window.getLocationOnScreen(); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
127 |
clicked = 0; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
128 |
checkClick(ls.x + window.getWidth() / 2, ls.y - 5, 0); |
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 |
robot.waitForIdle(2000); |
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 |
ls = south.getLocationOnScreen(); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
133 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
134 |
Point p1 = new Point((int) (ls.x + south.getWidth() * 0.75), ls.y + south.getHeight() * 3); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
135 |
Point p2 = new Point((int) (ls.x + south.getWidth() * 0.75), ls.y - south.getHeight() * 2); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
136 |
Color c1 = robot.getPixelColor(p1.x, p1.y); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
137 |
Color c2 = robot.getPixelColor(p2.x, p2.y); |
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 |
checkClick(ls.x + south.getWidth() / 2, ls.y + south.getHeight() / 2, 1); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
140 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
141 |
robot.waitForIdle(2000); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
142 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
143 |
Color c1b = robot.getPixelColor(p1.x, p1.y); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
144 |
Color c2b = robot.getPixelColor(p2.x, p2.y); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
145 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
146 |
if (!aproximatelyEquals(c1, c1b) && !aproximatelyEquals(south.getBackground(), c1b)) |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
147 |
throw new RuntimeException("Check for opaque drop down failed. Before click: " + c1 + ", after click: " + c1b + ", expected is " + south.getBackground()); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
148 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
149 |
if (!aproximatelyEquals(c2,c2b) && !aproximatelyEquals(south.getBackground(), c2b)) |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
150 |
throw new RuntimeException("Check for opaque drop down failed. Before click: " + c2 + ", after click: " + c2b + ", expected is " + south.getBackground()); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
151 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
152 |
EventQueue.invokeAndWait(() -> { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
153 |
background.dispose(); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
154 |
window.dispose(); |
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 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
157 |
robot.waitForIdle(); |
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 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
160 |
boolean aproximatelyEquals(Color c1, Color c2) { |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
161 |
return ((Math.abs(c1.getRed()-c2.getRed())/256.0 + |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
162 |
Math.abs(c1.getGreen()-c2.getGreen())/256.0 + |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
163 |
Math.abs(c1.getBlue()-c2.getBlue())/256.0)) / 3 < 0.02; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
164 |
} |
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 |
@Override |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
167 |
public void applyShape() { } |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
168 |
|
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 |
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
|
171 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
172 |
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
|
173 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
174 |
clicked = 0; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
175 |
robot.mouseMove(x, y); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
176 |
robot.click(); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
177 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
178 |
for (int i = 0; i < 100; i++) |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
179 |
if ((clicked & (1 << flag)) == 0) |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
180 |
robot.delay(50); |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
181 |
else |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
182 |
break; |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
183 |
|
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
184 |
if ((clicked & (1 << flag)) == 0) |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
185 |
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
|
186 |
} |
a101ec6ccfd3
8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff
changeset
|
187 |
} |