Skip to content

Commit b560f51

Browse files
author
duke
committed
Backport fe828df242a1423f5cef58ab712cbcb34d2f3b3b
1 parent 4addb57 commit b560f51

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

test/jdk/java/awt/Frame/ShapeNotSetSometimes/ShapeNotSetSometimes.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.awt.geom.Area;
3434
import java.awt.geom.Ellipse2D;
3535
import java.awt.geom.Rectangle2D;
36+
import java.awt.image.BufferedImage;
3637
import java.io.File;
3738
import java.io.IOException;
3839
import javax.imageio.ImageIO;
@@ -42,7 +43,7 @@
4243
* @key headful
4344
* @bug 6988428
4445
* @summary Tests whether shape is always set
45-
* @run main/othervm -Dsun.java2d.uiScale=1 ShapeNotSetSometimes
46+
* @run main/othervm/timeout=300 -Dsun.java2d.uiScale=1 ShapeNotSetSometimes
4647
*/
4748

4849
public class ShapeNotSetSometimes {
@@ -147,15 +148,20 @@ private void doTest() throws Exception {
147148
robot.waitForIdle();
148149
robot.delay(500);
149150

151+
Rectangle screenBounds = window.getGraphicsConfiguration().getBounds();
152+
BufferedImage screenCapture = robot.createScreenCapture(screenBounds);
150153
try {
151-
colorCheck(innerPoint.x, innerPoint.y, SHAPE_COLOR, true);
154+
colorCheck(innerPoint.x, innerPoint.y, SHAPE_COLOR,
155+
true, screenCapture);
152156

153157
for (Point point : pointsOutsideToCheck) {
154-
colorCheck(point.x, point.y, BACKGROUND_COLOR, true);
158+
colorCheck(point.x, point.y, BACKGROUND_COLOR,
159+
true, screenCapture);
155160
}
156161

157162
for (Point point : shadedPointsToCheck) {
158-
colorCheck(point.x, point.y, SHAPE_COLOR, false);
163+
colorCheck(point.x, point.y, SHAPE_COLOR,
164+
false, screenCapture);
159165
}
160166
} finally {
161167
EventQueue.invokeAndWait(() -> {
@@ -169,15 +175,12 @@ private void doTest() throws Exception {
169175
}
170176
}
171177

172-
private void colorCheck(int x, int y, Color expectedColor, boolean mustBeExpectedColor) {
178+
private void colorCheck(int x, int y, Color expectedColor,
179+
boolean mustBeExpectedColor, BufferedImage screenCapture) {
173180
int screenX = window.getX() + x;
174181
int screenY = window.getY() + y;
175182

176-
robot.mouseMove(screenX, screenY);
177-
robot.waitForIdle();
178-
robot.delay(50);
179-
180-
Color actualColor = robot.getPixelColor(screenX, screenY);
183+
Color actualColor = new Color(screenCapture.getRGB(screenX, screenY));
181184

182185
System.out.printf(
183186
"Checking %3d, %3d, %35s should %sbe %35s\n",

0 commit comments

Comments
 (0)