author | goetz |
Tue, 14 Jun 2016 10:44:59 +0200 | |
changeset 39056 | d99e63b6d962 |
parent 31660 | 1a4e2e5c15e1 |
child 39861 | cb667c7942dd |
permissions | -rw-r--r-- |
24539 | 1 |
/* |
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
2 |
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. |
24539 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
||
25 |
import com.sun.awt.AWTUtilities; |
|
26 |
import java.awt.Frame; |
|
27 |
import java.awt.Panel; |
|
28 |
import java.awt.Point; |
|
29 |
import java.awt.Rectangle; |
|
30 |
import java.awt.Robot; |
|
31 |
import java.awt.event.InputEvent; |
|
32 |
import java.awt.event.MouseAdapter; |
|
33 |
import java.awt.event.MouseEvent; |
|
34 |
import javax.swing.JButton; |
|
35 |
import javax.swing.SwingUtilities; |
|
25129
3961e8fcb668
8044157: [TEST_BUG] Improve recently submitted AWT_Mixing tests
yan
parents:
24539
diff
changeset
|
36 |
import test.java.awt.regtesthelpers.Util; |
24539 | 37 |
|
38 |
/** |
|
39 |
* AWT/Swing overlapping test for opaque Swing components. |
|
40 |
* <p>This test verify if AWT components are drawn correctly under opaque components. |
|
41 |
* <p>See <a href="https://bugs.openjdk.java.net/browse/JDK-6776743">JDK-6776743</a> for details |
|
42 |
* <p>See base class for test info. |
|
43 |
*/ |
|
44 |
/* |
|
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
45 |
* @test |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
46 |
* @key headful |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
47 |
* @bug 6776743 |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
48 |
* @summary Opaque overlapping test for each AWT component |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
49 |
* @library ../../regtesthelpers |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
50 |
* @modules java.desktop/com.sun.awt |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
51 |
* java.desktop/java.awt.peer |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
52 |
* java.desktop/sun.awt |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
53 |
* @build Util |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
54 |
* @run main OpaqueOverlapping |
24539 | 55 |
*/ |
56 |
public class OpaqueOverlapping extends OverlappingTestBase { |
|
57 |
||
58 |
{ |
|
59 |
useClickValidation = false; |
|
60 |
failMessage = "Opacity test mismatchs"; |
|
61 |
||
62 |
// CR 6994264 (Choice autohides dropdown on Solaris 10) |
|
63 |
skipClassNames = new String[] { "Choice" }; |
|
64 |
} |
|
65 |
private String testSeq; |
|
66 |
private final static String checkSeq = "010000101"; |
|
67 |
private Point heavyLoc; |
|
68 |
private JButton light; |
|
69 |
private Frame frame = null; |
|
70 |
||
71 |
protected void prepareControls() { |
|
72 |
testSeq = ""; |
|
73 |
// Create components |
|
74 |
if(frame != null) { |
|
75 |
frame.setVisible(false); |
|
76 |
} |
|
77 |
frame = new Frame("OpaqueOverlapping mixing test"); |
|
78 |
final Panel panel = new Panel(); |
|
79 |
panel.setLayout(null); |
|
80 |
||
81 |
propagateAWTControls(panel); |
|
82 |
||
83 |
// Overlap the buttons |
|
84 |
currentAwtControl.setBounds(30, 30, 200, 200); |
|
85 |
||
86 |
light = new JButton(" LW Button "); |
|
87 |
light.setBounds(10, 10, 50, 50); |
|
88 |
||
89 |
// Put the components into the frame |
|
90 |
panel.add(light); |
|
91 |
frame.add(panel); |
|
92 |
frame.setBounds(50, 50, 400, 400); |
|
93 |
frame.setVisible(true); |
|
94 |
||
95 |
currentAwtControl.addMouseListener(new MouseAdapter() { |
|
96 |
@Override |
|
97 |
public void mouseClicked(MouseEvent e) { |
|
98 |
panel.setComponentZOrder(light, 0); |
|
99 |
frame.validate(); |
|
100 |
testSeq = testSeq + "0"; |
|
101 |
} |
|
102 |
}); |
|
103 |
light.addActionListener(new java.awt.event.ActionListener() { |
|
104 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
105 |
panel.setComponentZOrder(currentAwtControl, 0); |
|
106 |
frame.validate(); |
|
107 |
testSeq = testSeq + "1"; |
|
108 |
} |
|
109 |
}); |
|
110 |
} |
|
111 |
||
112 |
@Override |
|
113 |
protected boolean performTest() { |
|
114 |
try { |
|
115 |
SwingUtilities.invokeAndWait(new Runnable() { |
|
116 |
public void run() { |
|
117 |
heavyLoc = currentAwtControl.getLocationOnScreen(); |
|
118 |
} |
|
119 |
}); |
|
120 |
} catch (Exception e) { |
|
121 |
} |
|
122 |
Robot robot = Util.createRobot(); |
|
123 |
robot.setAutoDelay(ROBOT_DELAY); |
|
124 |
||
125 |
Util.waitForIdle(robot); |
|
126 |
||
127 |
// Move the mouse pointer to the position where both |
|
128 |
// components overlap |
|
129 |
robot.mouseMove(heavyLoc.x + 5, heavyLoc.y + 5); |
|
130 |
||
131 |
// Now perform the click at this point for 9 times |
|
132 |
// In the middle of the process toggle the opaque |
|
133 |
// flag value. |
|
134 |
for (int i = 0; i < 9; ++i) { |
|
135 |
if (i == 3) { |
|
136 |
AWTUtilities.setComponentMixingCutoutShape(light, |
|
137 |
new Rectangle()); |
|
138 |
} |
|
139 |
if (i == 6) { |
|
140 |
AWTUtilities.setComponentMixingCutoutShape(light, |
|
141 |
null); |
|
142 |
} |
|
143 |
||
144 |
robot.mousePress(InputEvent.BUTTON1_MASK); |
|
145 |
robot.mouseRelease(InputEvent.BUTTON1_MASK); |
|
146 |
Util.waitForIdle(robot); |
|
147 |
||
148 |
if (currentAwtControl.getClass() == java.awt.Choice.class && i != 1 && i != 6 && i != 8) { |
|
149 |
// due to the fact that Choice doesn't get mouseClicked event if its dropdown is shown |
|
150 |
robot.mousePress(InputEvent.BUTTON1_MASK); |
|
151 |
robot.mouseRelease(InputEvent.BUTTON1_MASK); |
|
152 |
Util.waitForIdle(robot); |
|
153 |
} |
|
154 |
} |
|
155 |
||
156 |
Util.waitForIdle(robot); |
|
157 |
||
158 |
boolean result = testSeq.equals(checkSeq); |
|
159 |
if (!result) { |
|
160 |
System.err.println("Expected: " + checkSeq); |
|
161 |
System.err.println("Observed: " + testSeq); |
|
162 |
} |
|
163 |
return result; |
|
164 |
} |
|
165 |
||
166 |
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class |
|
167 |
public static void main(String args[]) throws InterruptedException { |
|
168 |
instance = new OpaqueOverlapping(); |
|
169 |
OverlappingTestBase.doMain(args); |
|
170 |
} |
|
171 |
} |