author | serb |
Sun, 22 Dec 2013 21:12:43 +0400 | |
changeset 23248 | 3418855fb2c5 |
child 28087 | 622b2f420bc3 |
permissions | -rw-r--r-- |
23248
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
1 |
/* |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
4 |
* |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
8 |
* |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
13 |
* accompanied this code). |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
14 |
* |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
18 |
* |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
21 |
* questions. |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
22 |
*/ |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
23 |
|
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
24 |
import java.awt.AWTException; |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
25 |
import java.awt.Color; |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
26 |
import java.awt.Frame; |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
27 |
import java.awt.Graphics; |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
28 |
import java.awt.Point; |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
29 |
import java.awt.Robot; |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
30 |
import java.awt.Toolkit; |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
31 |
import java.awt.Window; |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
32 |
|
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
33 |
import sun.awt.SunToolkit; |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
34 |
|
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
35 |
/** |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
36 |
* @test |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
37 |
* @bug 8001472 |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
38 |
* @summary Background of the window should not depend from the paint()/update() |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
39 |
* @author Sergey Bylokhov |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
40 |
*/ |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
41 |
public final class BackgroundIsNotUpdated extends Window { |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
42 |
|
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
43 |
public BackgroundIsNotUpdated(final Frame owner) { |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
44 |
super(owner); |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
45 |
} |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
46 |
|
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
47 |
@Override |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
48 |
public void paint(final Graphics ignored) { |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
49 |
// Intentionally left blank |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
50 |
} |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
51 |
|
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
52 |
@Override |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
53 |
public void update(final Graphics ignored) { |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
54 |
// Intentionally left blank |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
55 |
} |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
56 |
|
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
57 |
public static void main(final String[] args) throws AWTException { |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
58 |
final Window window = new BackgroundIsNotUpdated(null); |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
59 |
window.setSize(300, 300); |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
60 |
window.setLocationRelativeTo(null); |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
61 |
window.setVisible(true); |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
62 |
sleep(); |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
63 |
window.setBackground(Color.GREEN); |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
64 |
sleep(); |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
65 |
final Robot robot = new Robot(); |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
66 |
robot.setAutoDelay(200); |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
67 |
Point point = window.getLocationOnScreen(); |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
68 |
Color color = robot.getPixelColor(point.x + window.getWidth() / 2, |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
69 |
point.y + window.getHeight() / 2); |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
70 |
window.dispose(); |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
71 |
if (!color.equals(Color.GREEN)) { |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
72 |
throw new RuntimeException( |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
73 |
"Expected: " + Color.GREEN + " , Actual: " + color); |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
74 |
} |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
75 |
} |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
76 |
|
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
77 |
private static void sleep() { |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
78 |
try { |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
79 |
((SunToolkit) Toolkit.getDefaultToolkit()).realSync(); |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
80 |
Thread.sleep(1000); |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
81 |
} catch (InterruptedException ignored) { |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
82 |
} |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
83 |
} |
3418855fb2c5
8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff
changeset
|
84 |
} |