RFR: 8150564: Migrate useful ExtendedRobot methods into awt.Robot [v30]
Alexander Zvegintsev
azvegint at openjdk.org
Thu Aug 7 20:57:35 UTC 2025
On Thu, 7 Aug 2025 19:08:32 GMT, Alisen Chung <achung at openjdk.org> wrote:
> i found that dragAndDrop was never used by any tests
This doesn't seem to be true. I see several tests using it:
./java/awt/Window/ShapedAndTranslucentWindows/StaticallyShaped.java:73: robot.dragAndDrop(location.x + dl, location.y + 5, location.x + dl + random.nextInt(dl), location.y + random.nextInt(dl));
./java/awt/Window/ShapedAndTranslucentWindows/StaticallyShaped.java:79: robot.dragAndDrop(location.x + 4, location.y + 4, location.x + random.nextInt(2*dl)-dl, location.y + random.nextInt(2*dl)-dl);
./java/awt/Window/ShapedAndTranslucentWindows/ShapedTranslucent.java:75: robot.dragAndDrop(location.x + dl, location.y + 5, location.x + dl + random.nextInt(dl), location.y + random.nextInt(dl));
./java/awt/Window/ShapedAndTranslucentWindows/ShapedTranslucent.java:81: robot.dragAndDrop(location.x + 4, location.y + 4, location.x + random.nextInt(2*dl)-dl, location.y + random.nextInt(2*dl)-dl);
./java/awt/Window/ShapedAndTranslucentWindows/Translucent.java:72: robot.dragAndDrop(location.x + dl, location.y + 5, location.x + dl + random.nextInt(dl), location.y + random.nextInt(dl));
./java/awt/Window/ShapedAndTranslucentWindows/Translucent.java:78: robot.dragAndDrop(location.x + 4, location.y + 4, location.x + random.nextInt(2*dl)-dl, location.y + random.nextInt(2*dl)-dl);
./java/awt/Window/ShapedAndTranslucentWindows/Shaped.java:75: robot.dragAndDrop(location.x + dl, location.y + 5, location.x + dl + random.nextInt(dl), location.y + random.nextInt(dl));
./java/awt/Window/ShapedAndTranslucentWindows/Shaped.java:81: robot.dragAndDrop(location.x + 4, location.y + 4, location.x + random.nextInt(2*dl)-dl, location.y + random.nextInt(2*dl)-dl);
./java/awt/Window/ShapedAndTranslucentWindows/ShapedTranslucentWindowClick.java:174: robot.dragAndDrop(MouseInfo.getPointerInfo().getLocation(), new Point(x+5, y));
./java/awt/event/MouseEvent/DragToLightweightTest.java:79: robot.dragAndDrop(
./javax/swing/JWindow/ShapedAndTranslucentWindows/Common.java:369: robot.dragAndDrop(location.x + 30, location.y + 5, location.x + dl + random.nextInt(dl), location.y + random.nextInt(dl));
./javax/swing/JWindow/ShapedAndTranslucentWindows/Common.java:375: robot.dragAndDrop(location.x + 4, location.y + 4, location.x + random.nextInt(2*dl)-dl, location.y + random.nextInt(2*dl)-dl);
./javax/swing/JWindow/ShapedAndTranslucentWindows/Common.java:387: robot.dragAndDrop(location.x + 30, location.y + 5, location.x + dl + random.nextInt(dl), location.y + random.nextInt(dl));
./javax/swing/JWindow/ShapedAndTranslucentWindows/Common.java:393: robot.dragAndDrop(location.x + 4, location.y + 4, location.x + random.nextInt(2*dl)-dl, location.y + random.nextInt(2*dl)-dl);
It seems to be a convenient method because it eliminates the need for all this hassle with a single call.
robot.mouseMove(fromX, fromY);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.waitForIdle();
robot.glide(toX, toY);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
robot.waitForIdle();
vs
robot.dragAndDrop(fromX, fromY, toX, toY)
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/22044#discussion_r2261377526
More information about the client-libs-dev
mailing list