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 |
import java.awt.BorderLayout; |
|
25 |
import java.awt.Color; |
|
26 |
import java.awt.Container; |
|
27 |
import java.awt.Point; |
|
28 |
import java.awt.Robot; |
|
29 |
import java.awt.event.MouseAdapter; |
|
30 |
import java.awt.event.MouseEvent; |
|
31 |
import javax.swing.JFrame; |
|
32 |
import javax.swing.JInternalFrame; |
|
33 |
import javax.swing.SwingUtilities; |
|
25129
3961e8fcb668
8044157: [TEST_BUG] Improve recently submitted AWT_Mixing tests
yan
parents:
24539
diff
changeset
|
34 |
import test.java.awt.regtesthelpers.Util; |
24539 | 35 |
|
36 |
/** |
|
37 |
* AWT/Swing overlapping test with JInternalFrame being put in GlassPane. |
|
38 |
* See <a href="https://bugs.openjdk.java.net/browse/JDK-6637655">JDK-6637655</a> and |
|
39 |
* <a href="https://bugs.openjdk.java.net/browse/JDK-6985776">JDK-6985776</a>. |
|
40 |
* <p>See base class for details. |
|
41 |
*/ |
|
42 |
/* |
|
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
43 |
* @test |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
44 |
* @key headful |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
45 |
* @bug 6637655 6985776 |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
46 |
* @summary Overlapping test for javax.swing.JScrollPane |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
47 |
* @author sergey.grinev@oracle.com: area=awt.mixing |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
48 |
* @library ../../regtesthelpers |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
49 |
* @modules java.desktop/sun.awt |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
50 |
* java.desktop/java.awt.peer |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
51 |
* @build Util |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31660
diff
changeset
|
52 |
* @run main JGlassPaneInternalFrameOverlapping |
24539 | 53 |
*/ |
54 |
public class JGlassPaneInternalFrameOverlapping extends OverlappingTestBase { |
|
55 |
||
56 |
private boolean lwClicked = true; |
|
57 |
private Point lLoc; |
|
58 |
private Point lLoc2; |
|
59 |
private JInternalFrame internalFrame; |
|
60 |
||
61 |
protected boolean performTest() { |
|
62 |
try { |
|
63 |
SwingUtilities.invokeAndWait(new Runnable() { |
|
64 |
public void run() { |
|
65 |
lLoc = internalFrame.getContentPane().getLocationOnScreen(); |
|
66 |
lLoc2 = lLoc.getLocation(); |
|
67 |
lLoc2.translate(0, internalFrame.getContentPane().getHeight() + 10); |
|
68 |
} |
|
69 |
}); |
|
70 |
} catch (Exception e) { |
|
71 |
e.printStackTrace(); |
|
25129
3961e8fcb668
8044157: [TEST_BUG] Improve recently submitted AWT_Mixing tests
yan
parents:
24539
diff
changeset
|
72 |
throw new RuntimeException("Where is internal frame?"); |
24539 | 73 |
} |
74 |
// run robot |
|
75 |
Robot robot = Util.createRobot(); |
|
76 |
robot.setAutoDelay(ROBOT_DELAY); |
|
77 |
||
78 |
clickAndBlink(robot, lLoc); |
|
79 |
||
80 |
Color c = robot.getPixelColor(lLoc2.x, lLoc2.y); |
|
81 |
robot.mouseMove(lLoc2.x, lLoc2.y); |
|
82 |
if (!c.equals(AWT_BACKGROUND_COLOR) && |
|
83 |
currentAwtControl.getClass() != java.awt.Scrollbar.class && |
|
84 |
currentAwtControl.getClass() != java.awt.Choice.class) { |
|
85 |
fail("The HW component did not pass pixel color check and is not drawn correctly"); |
|
86 |
} |
|
87 |
||
88 |
return lwClicked; |
|
89 |
} |
|
90 |
||
91 |
// {debugClassName = "Choice";} |
|
92 |
||
93 |
@Override |
|
94 |
protected void prepareControls() { |
|
95 |
JFrame frame = new JFrame("Glass Pane children test"); |
|
96 |
frame.setLayout(null); |
|
97 |
||
98 |
Container contentPane = frame.getContentPane(); |
|
99 |
contentPane.setLayout(new BorderLayout()); |
|
100 |
super.propagateAWTControls(contentPane); |
|
101 |
||
102 |
Container glassPane = (Container) frame.getRootPane().getGlassPane(); |
|
103 |
glassPane.setVisible(true); |
|
104 |
glassPane.setLayout(null); |
|
105 |
||
106 |
internalFrame = new JInternalFrame("Internal Frame", true); |
|
107 |
internalFrame.setBounds(50, 0, 200, 100); |
|
108 |
internalFrame.setVisible(true); |
|
109 |
glassPane.add(internalFrame); |
|
110 |
||
111 |
internalFrame.addMouseListener(new MouseAdapter() { |
|
112 |
||
113 |
@Override |
|
114 |
public void mouseClicked(MouseEvent e) { |
|
115 |
lwClicked = true; |
|
116 |
} |
|
117 |
}); |
|
118 |
||
119 |
frame.setSize(300, 180); |
|
120 |
frame.setLocationRelativeTo(null); |
|
121 |
frame.setVisible(true); |
|
122 |
} |
|
123 |
||
124 |
// this strange plumbing stuff is required due to "Standard Test Machinery" in base class |
|
125 |
public static void main(String args[]) throws InterruptedException { |
|
126 |
if (System.getProperty("os.name").toLowerCase().contains("os x")) { |
|
127 |
System.out.println("Aqua L&F ignores setting color to component. Test passes on Mac OS X."); |
|
128 |
return; |
|
129 |
} |
|
130 |
instance = new JGlassPaneInternalFrameOverlapping(); |
|
131 |
OverlappingTestBase.doMain(args); |
|
132 |
} |
|
133 |
} |