33
33
import java .awt .geom .Area ;
34
34
import java .awt .geom .Ellipse2D ;
35
35
import java .awt .geom .Rectangle2D ;
36
+ import java .awt .image .BufferedImage ;
36
37
import java .io .File ;
37
38
import java .io .IOException ;
38
39
import javax .imageio .ImageIO ;
42
43
* @key headful
43
44
* @bug 6988428
44
45
* @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
46
47
*/
47
48
48
49
public class ShapeNotSetSometimes {
@@ -147,15 +148,20 @@ private void doTest() throws Exception {
147
148
robot .waitForIdle ();
148
149
robot .delay (500 );
149
150
151
+ Rectangle screenBounds = window .getGraphicsConfiguration ().getBounds ();
152
+ BufferedImage screenCapture = robot .createScreenCapture (screenBounds );
150
153
try {
151
- colorCheck (innerPoint .x , innerPoint .y , SHAPE_COLOR , true );
154
+ colorCheck (innerPoint .x , innerPoint .y , SHAPE_COLOR ,
155
+ true , screenCapture );
152
156
153
157
for (Point point : pointsOutsideToCheck ) {
154
- colorCheck (point .x , point .y , BACKGROUND_COLOR , true );
158
+ colorCheck (point .x , point .y , BACKGROUND_COLOR ,
159
+ true , screenCapture );
155
160
}
156
161
157
162
for (Point point : shadedPointsToCheck ) {
158
- colorCheck (point .x , point .y , SHAPE_COLOR , false );
163
+ colorCheck (point .x , point .y , SHAPE_COLOR ,
164
+ false , screenCapture );
159
165
}
160
166
} finally {
161
167
EventQueue .invokeAndWait (() -> {
@@ -169,15 +175,12 @@ private void doTest() throws Exception {
169
175
}
170
176
}
171
177
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 ) {
173
180
int screenX = window .getX () + x ;
174
181
int screenY = window .getY () + y ;
175
182
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 ));
181
184
182
185
System .out .printf (
183
186
"Checking %3d, %3d, %35s should %sbe %35s\n " ,
0 commit comments