8056911: Remove internal API usage from ExtendedRobot class
authordermashov
Thu, 30 Oct 2014 15:44:37 +0300
changeset 27506 41ccac32e143
parent 27505 bc197defe284
child 27507 6e3bc02ae872
8056911: Remove internal API usage from ExtendedRobot class Reviewed-by: serb
jdk/src/java.desktop/share/classes/java/awt/Robot.java
jdk/test/lib/testlibrary/ExtendedRobot.java
--- a/jdk/src/java.desktop/share/classes/java/awt/Robot.java	Fri Oct 31 00:40:14 2014 +0400
+++ b/jdk/src/java.desktop/share/classes/java/awt/Robot.java	Thu Oct 30 15:44:37 2014 +0300
@@ -34,9 +34,12 @@
 import java.awt.image.WritableRaster;
 import java.awt.peer.RobotPeer;
 import java.lang.reflect.InvocationTargetException;
+import java.security.AccessController;
+
 import sun.awt.AWTPermissions;
 import sun.awt.ComponentFactory;
 import sun.awt.SunToolkit;
+import sun.awt.OSInfo;
 import sun.awt.image.SunWritableRaster;
 
 /**
@@ -555,15 +558,21 @@
      */
     public synchronized void waitForIdle() {
         checkNotDispatchThread();
-        // post a dummy event to the queue so we know when
-        // all the events before it have been processed
+
         try {
             SunToolkit.flushPendingEvents();
-            EventQueue.invokeAndWait( new Runnable() {
-                                            public void run() {
-                                                // dummy implementation
-                                            }
-                                        } );
+            // 7185258: realSync() call blocks all DnD tests on OS X
+            if (AccessController.doPrivileged(OSInfo.getOSTypeAction()) = OSInfo.OSType.MACOSX) {
+                // post a dummy event to the queue so we know when
+                // all the events before it have been processed
+                EventQueue.invokeAndWait( new Runnable() {
+                                                public void run() {
+                                                    // dummy implementation
+                                                }
+                                            } );
+            } else {
+                ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+            }
         } catch(InterruptedException ite) {
             System.err.println("Robot.waitForIdle, non-fatal exception caught:");
             ite.printStackTrace();
--- a/jdk/test/lib/testlibrary/ExtendedRobot.java	Fri Oct 31 00:40:14 2014 +0400
+++ b/jdk/test/lib/testlibrary/ExtendedRobot.java	Thu Oct 30 15:44:37 2014 +0300
@@ -23,9 +23,6 @@
  * questions.
  */
 
-import sun.awt.ExtendedKeyCodes;
-import sun.awt.SunToolkit;
-
 import java.awt.AWTException;
 import java.awt.Robot;
 import java.awt.GraphicsDevice;
@@ -33,6 +30,7 @@
 import java.awt.Point;
 import java.awt.MouseInfo;
 import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
 
 /**
  * ExtendedRobot is a subclass of {@link java.awt.Robot}. It provides some convenience methods that are
@@ -178,8 +176,7 @@
      *          dispatching thread
      */
     public synchronized void waitForIdle(int delayValue) {
-        SunToolkit.flushPendingEvents();
-        ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+        super.waitForIdle();
         delay(delayValue);
     }
 
@@ -382,7 +379,7 @@
      * @see     java.awt.event.KeyEvent
      */
     public void type(char c) {
-        type(ExtendedKeyCodes.getExtendedKeyCodeForChar(c));
+        type(KeyEvent.getExtendedKeyCodeForChar(c));
     }
 
     /**