On Tue, 16 Jan 2024 10:52:34 GMT, songpv-imt <d...@openjdk.org> wrote:

>> The root cause of the bug is because mousePress() method is invoked before 
>> mouseMove() event is completely processed causing the drag & drop behavior 
>> not being able to be recognized properly. This in turn makes the method 
>> dragSourceListener.isDropFinished() returns false and fail the test. To fix 
>> this, setAutoWaitForIdle(true) and Thread.Sleep is called to make sure the 
>> mouseMove() event is processed completely before moving to execute the 
>> mousePress() method.
>> 
>> JBS issue: [JDK-8317287](https://bugs.openjdk.org/browse/JDK-8317287)
>
> songpv-imt has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Update InterJVMGetDropSuccessTest.java
>   - Remove robot.setWaitForIdle(true) and add robot.waitForIdle() after 
> mouseMove
>   - Change FRAME_ACTIVATION_TIMEOUT to 1000
>   - Remove unused pointInComponent and pointInComponentImpl methods
>   - Use Java-style array declaration for successCodes
>   - Use per-class imports instead of wildcard imports

Changes requested by aivanov (Reviewer).

test/jdk/java/awt/dnd/InterJVMGetDropSuccessTest/InterJVMGetDropSuccessTest.java
 line 1:

> 1: /*

You missed two spots that I talked about:


@@ -89,7 +68,9 @@ public void start() {
         frame.setVisible(true);
 
         try {
-            Thread.sleep(Util.FRAME_ACTIVATION_TIMEOUT);
+            Robot robot = new Robot();
+            robot.waitForIdle();
+            robot.delay(Util.FRAME_ACTIVATION_TIMEOUT);
 
             Point p = frame.getLocationOnScreen();
             Dimension d = frame.getSize();
@@ -250,13 +230,14 @@ public void run(String[] args) {
             frame.setBounds(300, 200, 150, 150);
             frame.setVisible(true);
 
-            Thread.sleep(Util.FRAME_ACTIVATION_TIMEOUT);
+            Robot robot = new Robot();
+            robot.waitForIdle();
+            robot.delay(Util.FRAME_ACTIVATION_TIMEOUT);
 
             Point sourcePoint = Util.getCenterLocationOnScreen(frame);
 
             Point targetPoint = new Point(x + w / 2, y + h / 2);
 
-            Robot robot = new Robot();
             robot.mouseMove(sourcePoint.x, sourcePoint.y);
             robot.waitForIdle();
             robot.delay(50);


---

`MOUSE_RELEASE_TIMEOUT` is still present in the test but it's unused.

test/jdk/java/awt/dnd/InterJVMGetDropSuccessTest/InterJVMGetDropSuccessTest.java
 line 57:

> 55: import java.awt.dnd.DragGestureEvent;
> 56: import java.io.File;
> 57: import java.io.InputStream;

The imports are sorted alphabetically, to make it easier for you, this is how 
my IDE organises imports:
 ```suggestion
import java.awt.Frame;
import java.awt.Component;
import java.awt.Point;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Toolkit;
import java.awt.AWTEvent;
import java.awt.Robot;
import java.awt.event.AWTEventListener;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DragGestureListener;
import java.awt.dnd.DragSourceAdapter;
import java.awt.dnd.DragSourceDropEvent;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetAdapter;
import java.awt.dnd.DragGestureRecognizer;
import java.awt.dnd.DragSource;
import java.awt.dnd.DropTargetListener;
import java.awt.dnd.DragGestureEvent;
import java.io.File;
import java.io.InputStream;

test/jdk/java/awt/dnd/InterJVMGetDropSuccessTest/InterJVMGetDropSuccessTest.java
 line 62:

> 60: 
> 61:     private int returnCode = Util.CODE_NOT_RETURNED;
> 62:     private final boolean successCodes[] = new boolean[]{ true, false };

Suggestion:

    private final boolean[] successCodes = { true, false };

Use Java-style array declaration; it means the brackets are with the type 
`boolean[]` rather than the field/variable name.

-------------

PR Review: https://git.openjdk.org/jdk/pull/16396#pullrequestreview-1823245946
PR Review Comment: https://git.openjdk.org/jdk/pull/16396#discussion_r1453379932
PR Review Comment: https://git.openjdk.org/jdk/pull/16396#discussion_r1453377254
PR Review Comment: https://git.openjdk.org/jdk/pull/16396#discussion_r1453375260

Reply via email to