--- a/jdk/test/lib/testlibrary/ExtendedRobot.java Mon May 26 14:33:49 2014 +0400
+++ b/jdk/test/lib/testlibrary/ExtendedRobot.java Mon May 26 15:50:10 2014 +0400
@@ -25,7 +25,6 @@
import sun.awt.ExtendedKeyCodes;
import sun.awt.SunToolkit;
-import sun.security.action.GetIntegerAction;
import java.awt.AWTException;
import java.awt.Robot;
@@ -34,8 +33,6 @@
import java.awt.Point;
import java.awt.MouseInfo;
import java.awt.event.InputEvent;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
/**
* ExtendedRobot is a subclass of {@link java.awt.Robot}. It provides some convenience methods that are
@@ -312,6 +309,48 @@
mouseMove(position.x, position.y);
}
+
+ /**
+ * Emulate native drag and drop process using {@code InputEvent.BUTTON1_DOWN_MASK}.
+ * The method successively moves mouse cursor to point with coordinates
+ * ({@code fromX}, {@code fromY}), presses mouse button 1, drag mouse to
+ * point with coordinates ({@code toX}, {@code toY}) and releases mouse
+ * button 1 at last.
+ *
+ * @param fromX Source point x coordinate
+ * @param fromY Source point y coordinate
+ * @param toX Destination point x coordinate
+ * @param toY Destination point y coordinate
+ *
+ * @see #mousePress(int)
+ * @see #glide(int, int, int, int)
+ */
+ public void dragAndDrop(int fromX, int fromY, int toX, int toY){
+ mouseMove(fromX, fromY);
+ mousePress(InputEvent.BUTTON1_DOWN_MASK);
+ waitForIdle();
+ glide(toX, toY);
+ mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+ waitForIdle();
+ }
+
+ /**
+ * Emulate native drag and drop process using {@code InputEvent.BUTTON1_DOWN_MASK}.
+ * The method successively moves mouse cursor to point {@code from},
+ * presses mouse button 1, drag mouse to point {@code to} and releases
+ * mouse button 1 at last.
+ *
+ * @param from Source point
+ * @param to Destination point
+ *
+ * @see #mousePress(int)
+ * @see #glide(int, int, int, int)
+ * @see #dragAndDrop(int, int, int, int)
+ */
+ public void dragAndDrop(Point from, Point to){
+ dragAndDrop(from.x, from.y, to.x, to.y);
+ }
+
/**
* Successively presses and releases a given key.
* <p>