On Thu, 28 Aug 2025 05:51:40 GMT, Damon Nguyen <[email protected]> wrote:
>> When testing jtreg manual tests, some tests were out of date. This PR is an
>> attempt at updating the test and automating it.
>>
>> `MouseDraggedOriginatedByScrollBarTest.java` works as expected when compared
>> to native apps and outputs drag events even when the mouse pointer is
>> dragged off of the scrollbar and window altogether. Events should still
>> fire, but the previous instructions may make this confusing since it reads
>> as if no events should be output to the textarea at all.
>
> Damon Nguyen has updated the pull request incrementally with one additional
> commit since the last revision:
>
> Review comment edits
Changes requested by aivanov (Reviewer).
test/jdk/java/awt/List/MouseDraggedOriginatedByScrollBarTest.java line 85:
> 83: System.out.println(me.toString());
> 84: throw new RuntimeException("Test failed. Mouse
> dragged " +
> 85: "event detected.");
Suggestion:
throw new RuntimeException("Mouse dragged event detected.");
Being concise is better, isn't it? An exception is already an indicator that
the test failed, let's just provide the reason.
test/jdk/java/awt/List/MouseDraggedOriginatedByScrollBarTest.java line 94:
> 92: System.out.println(me.toString());
> 93: throw new RuntimeException("Test failed. Mouse
> pressed " +
> 94: "event detected.");
Suggestion:
throw new RuntimeException("Mouse pressed event detected.");
Similarly.
test/jdk/java/awt/List/MouseDraggedOriginatedByScrollBarTest.java line 127:
> 125: loc = p;
> 126: });
> 127: robot.mouseMove(loc.x - 10, loc.y + 20);
Suggestion:
EventQueue.invokeAndWait(() -> {
Point p = list.getLocationOnScreen();
p.translate(list.getWidth() - 10, 20);
loc = p;
});
robot.mouseMove(loc.x, loc.y);
Prepare the correct location inside `invokeAndWait`. The offsets could be
declared constants, which may result in clearer code.
test/jdk/java/awt/List/MouseDraggedOriginatedByScrollBarTest.java line 131:
> 129: for (int i = 0; i < 30; i++) {
> 130: robot.mouseMove(loc.x, loc.y + 1);
> 131: }
Suggestion:
for (int i = 0; i < 30; i++) {
robot.mouseMove(loc.x, loc.y + i);
}
I forgot to replace `1` with `i` in my earlier suggestion.
This for-loop depends on the fact that `loc` contains the initial location for
dragging the mouse. That is, the initial `robot.mouseMove` has to have
arguments `(loc.x, loc.y)`, otherwise the mouse jumps `(+10, -20)` pixels.
-------------
PR Review: https://git.openjdk.org/jdk/pull/26636#pullrequestreview-3183967641
PR Review Comment: https://git.openjdk.org/jdk/pull/26636#discussion_r2321219872
PR Review Comment: https://git.openjdk.org/jdk/pull/26636#discussion_r2321221314
PR Review Comment: https://git.openjdk.org/jdk/pull/26636#discussion_r2321230525
PR Review Comment: https://git.openjdk.org/jdk/pull/26636#discussion_r2321244068