test/sun/awt/dnd/8024061/bug8024061.java

Print this page

        

@@ -23,15 +23,14 @@
 
 /* @test
  * @bug 8024061
  * @summary Checks that no exception is thrown if dragGestureRecognized
  *          takes a while to complete.
+ * @library ../../../../lib/testlibrary
+ * @build jdk.testlibrary.OSInfo
+ * @run main bug8024061 
  */
-import sun.awt.OSInfo;
-import sun.awt.OSInfo.OSType;
-import sun.awt.SunToolkit;
-
 import java.awt.*;
 import java.awt.datatransfer.DataFlavor;
 import java.awt.datatransfer.Transferable;
 import java.awt.datatransfer.UnsupportedFlavorException;
 import java.awt.dnd.DnDConstants;

@@ -53,10 +52,12 @@
 import java.lang.reflect.InvocationTargetException;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
 import javax.swing.*;
+import jdk.testlibrary.OSInfo;
+
 
 /**
  * If dragGestureRecognized() takes a while to complete and if user performs a drag quickly,
  * an exception is thrown from DropTargetListener.dragEnter when it calls
  * DropTargetDragEvent.getTransferable().

@@ -104,12 +105,12 @@
         drop.place(panel1, new Point(10, 10));
         frame.setVisible(true);
     }
 
     public static void main(String[] args) throws AWTException, InvocationTargetException, InterruptedException {
-        OSType type = OSInfo.getOSType();
-        if (type != OSType.LINUX && type != OSType.SOLARIS) {
+        OSInfo.OSType type = OSInfo.getOSType();
+        if (type != OSInfo.OSType.LINUX && type != OSInfo.OSType.SOLARIS) {
             System.out.println("This test is for Linux and Solaris only... " +
                                "skipping!");
             return;
         }
 

@@ -120,12 +121,11 @@
                 dnd[0] = new bug8024061();
             }
         });
         final Robot robot = new Robot();
         robot.setAutoDelay(10);
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
-        toolkit.realSync();
+        robot.waitForIdle();
 
         JFrame frame = dnd[0].frame;
         Point point = frame.getLocationOnScreen();
         Point here = new Point(point.x + 35, point.y + 45);
         Point there = new Point(point.x + 120, point.y + 45);

@@ -136,11 +136,11 @@
             here.x += 20;
             robot.mouseMove(here.x, here.y);
             System.out.println("x = " + here.x);
         }
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
-        toolkit.realSync();
+        robot.waitForIdle();
         robot.mousePress(InputEvent.BUTTON1_MASK);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
         System.out.println("finished");
 
         try {