7148531: [macosx] In test, the window does not have time to resize before make a screenshot
authorserb
Tue, 14 Oct 2014 18:58:06 +0400
changeset 27275 dcd284dffa27
parent 27274 62de2c957523
child 27276 86db3fc5e0ec
7148531: [macosx] In test, the window does not have time to resize before make a screenshot Reviewed-by: alexsch, azvegint
jdk/test/sun/java2d/DirectX/OnScreenRenderingResizeTest/OnScreenRenderingResizeTest.java
--- a/jdk/test/sun/java2d/DirectX/OnScreenRenderingResizeTest/OnScreenRenderingResizeTest.java	Mon Oct 13 09:09:41 2014 -0700
+++ b/jdk/test/sun/java2d/DirectX/OnScreenRenderingResizeTest/OnScreenRenderingResizeTest.java	Tue Oct 14 18:58:06 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -89,8 +89,13 @@
             public void update(Graphics g) {}
         };
         frame.setBackground(bgColor);
+        frame.setUndecorated(true);
         frame.pack();
-        frame.setSize(FRAME_W, FRAME_H);
+
+        GraphicsConfiguration gc = frame.getGraphicsConfiguration();
+        Rectangle gcBounds = gc.getBounds();
+        frame.setBounds(gcBounds.width / 4, gcBounds.height / 4, FRAME_W, FRAME_H);
+
         frame.addWindowListener(new WindowAdapter() {
             public void windowClosing(WindowEvent e) {
                 done = true;
@@ -108,9 +113,8 @@
             ex.printStackTrace();
         }
 
-        GraphicsConfiguration gc = frame.getGraphicsConfiguration();
-        int maxW = gc.getBounds().width /2;
-        int maxH = gc.getBounds().height/2;
+        int maxW = gcBounds.width /2;
+        int maxH = gcBounds.height/2;
         int minW = frame.getWidth();
         int minH = frame.getHeight();
         int incW = 10, incH = 10, cnt = 0;
@@ -155,6 +159,7 @@
             Insets in = frame.getInsets();
             frame.getGraphics().drawImage(output, in.left, in.top, null);
             if (cnt == 90 && robot != null) {
+                robot.waitForIdle();
                 // area where we blitted to should be either white or green
                 Point p = frame.getLocationOnScreen();
                 p.translate(in.left+10, in.top+10);
@@ -172,7 +177,7 @@
                                   frame.getWidth()-in.left-in.right,
                                   frame.getHeight()-in.top-in.bottom-5-IMAGE_H));
                 int accepted2[] = { Color.white.getRGB() };
-                checkBI(bi, accepted1);
+                checkBI(bi, accepted2);
             }
 
             Thread.yield();