RFR: 8328560: java/awt/event/MouseEvent/ClickDuringKeypress/ClickDuringKeypress.java imports Applet
Alexander Zvegintsev
azvegint at openjdk.org
Wed Mar 20 01:00:26 UTC 2024
On Tue, 19 Mar 2024 23:30:39 GMT, Phil Race <prr at openjdk.org> wrote:
> This seems to have been some previous not very complete conversion of a test from applet to main.
> It even still had Applet imported and miscellaneous comments. I've cleaned it up.
test/jdk/java/awt/event/MouseEvent/ClickDuringKeypress/ClickDuringKeypress.java line 25:
> 23:
> 24: /*
> 25: @test 1.2 98/08/05
Now we don't have `@test` at all.
test/jdk/java/awt/event/MouseEvent/ClickDuringKeypress/ClickDuringKeypress.java line 29:
> 27: @summary Tests that clicking mouse and pressing keys generates correct amount of click-counts
> 28: @run main ClickDuringKeypress
> 29: */
We usually move this block just before a class declaration, for better readability.
test/jdk/java/awt/event/MouseEvent/ClickDuringKeypress/ClickDuringKeypress.java line 53:
> 51: static volatile Frame frame;
> 52: static volatile Robot robot;
> 53: static volatile ClickDuringKeypress clicker;
Suggestion:
static final ClickDuringKeypress clicker = new ClickDuringKeypress();
`clicker` can be made final
test/jdk/java/awt/event/MouseEvent/ClickDuringKeypress/ClickDuringKeypress.java line 61:
> 59: robot = new Robot();
> 60: robot.mouseMove(200, 200);
> 61: EventQueue.invokeAndWait(frame::show);
Suggestion:
EventQueue.invokeAndWait(() -> frame.setVisible(true));
`show` is deprecated.
test/jdk/java/awt/event/MouseEvent/ClickDuringKeypress/ClickDuringKeypress.java line 96:
> 94: throw new RuntimeException("Not Activated. Test fails");
> 95: }
> 96: }
Do we really need this synchronization?
Shouldn't the standard
robot.waitForIdle();
robot.delay(1000);
be enough?
test/jdk/java/awt/event/MouseEvent/ClickDuringKeypress/ClickDuringKeypress.java line 111:
> 109: for (int i = 0; i < CLICKCOUNT / 2; i++) {
> 110: robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
> 111: robot.delay(10);
Here and after
Suggestion:
We have already called `robot.setAutoDelay(DOUBLE_CLICK_AUTO_DELAY);` before. We can set `DOUBLE_CLICK_AUTO_DELAY` to 20 and remove the multiple `robot.delay(10)` calls.
Probably we also want to add `setAutoWaitForIdle(true)`
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/18386#discussion_r1531318899
PR Review Comment: https://git.openjdk.org/jdk/pull/18386#discussion_r1531326699
PR Review Comment: https://git.openjdk.org/jdk/pull/18386#discussion_r1531347759
PR Review Comment: https://git.openjdk.org/jdk/pull/18386#discussion_r1531333655
PR Review Comment: https://git.openjdk.org/jdk/pull/18386#discussion_r1531344366
PR Review Comment: https://git.openjdk.org/jdk/pull/18386#discussion_r1531365101
More information about the client-libs-dev
mailing list