test/java/awt/Mixing/AWT_Mixing/OverlappingTestBase.java

Print this page

        

@@ -27,11 +27,11 @@
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import javax.swing.*;
-import sun.awt.*;
+import sun.awt.EmbeddedFrame;
 import java.io.*;
 import test.java.awt.regtesthelpers.Util;
 
 /**
  * <p>This class provides basis for AWT Mixing testing.

@@ -139,11 +139,10 @@
     }
 
     public void getVerifyColor() {
         try {
             final int size = 200;
-            final SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
             final Point[] p = new Point[1];
             SwingUtilities.invokeAndWait(new Runnable() {
                 public void run(){
                     JFrame frame = new JFrame("set back");
                     frame.getContentPane().setBackground(AWT_BACKGROUND_COLOR);

@@ -153,11 +152,11 @@
                     frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
                     p[0] = frame.getLocation();
                 }
             });
             Robot robot = new Robot();
-            toolkit.realSync();
+            robot.waitForIdle();
             Thread.sleep(ROBOT_DELAY);
             AWT_VERIFY_COLOR = robot.getPixelColor(p[0].x+size/2, p[0].y+size/2);
             System.out.println("Color will be compared with " + AWT_VERIFY_COLOR + " instead of " + AWT_BACKGROUND_COLOR);
         } catch (Exception e) {
             System.err.println("Cannot get verify color: "+e.getMessage());

@@ -432,21 +431,26 @@
      * @see {@link OverlappingTestBase#propagateAWTControls(java.awt.Container) } for instructions about adding tested AWT control to UI
      */
     protected Component currentAwtControl;
 
     private void testComponent(Component component) throws InterruptedException, InvocationTargetException {
+        Robot robot = null;
+        try {
+            robot = new Robot();
+        }catch(Exception ignorex) {
+        }
         currentAwtControl = component;
         System.out.println("Testing " + currentAwtControl.getClass().getSimpleName());
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 prepareControls();
             }
         });
         if (component != null) {
             Util.waitTillShown(component);
         }
-        Util.waitForIdle(null);
+        Util.waitForIdle(robot);
         try {
             Thread.sleep(500); // wait for graphic effects on systems like Win7
         } catch (InterruptedException ex) {
         }
         if (!instance.performTest()) {

@@ -459,18 +463,23 @@
             }
         });
     }
 
     private void testEmbeddedFrame() throws InvocationTargetException, InterruptedException {
+        Robot robot = null;
+        try {
+            robot = new Robot();
+        }catch(Exception ignorex) {
+        }
         System.out.println("Testing EmbeddedFrame");
         currentAwtControl = null;
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 prepareControls();
             }
         });
-        Util.waitForIdle(null);
+        Util.waitForIdle(robot);
         try {
             Thread.sleep(500); // wait for graphic effects on systems like Win7
         } catch (InterruptedException ex) {
         }
         if (!instance.performTest()) {