RFR: 8341978: Improve JButton/bug4490179.java

Alisen Chung achung at openjdk.org
Tue Oct 15 22:47:12 UTC 2024


On Fri, 11 Oct 2024 16:54:20 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

> At first, I noticed bug4490179.java didn't release mouse button 1, which could affect the following tests.
> 
> I started looking at the test and updated it to use `CountDownLatch` instead of delays.
> 
> @azvegint handled releasing mouse button 1 in https://github.com/openjdk/jdk/pull/19339#discussion_r1609201116.
> 
> The updated version first verifies `mouseButton3Released` event is received and ensures `actionPerformed` is not received at this time.
> 
> Then mouse button is released; this should trigger two events: `mouseButton1Released` and `actionPerformed`. It is verified that these events are received.
> 
> I kept debugging prints, they help understanding which actions lead to which events.
> 
> The updated test reproduces the original, it is easily verified using Java 8; the updated test is stable in CI.
> 
> 
> The `javax/swing/JButton/bug4490179.java` test is also modified in https://github.com/openjdk/jdk/pull/20861, @mrserb, could you take a look? I was going to suggested factoring out the changes to this test from #20861, yet I modified it myself. I realised it when I started creating the PR.

just some formatting comments, test is working fine for me on macos

test/jdk/javax/swing/JButton/bug4490179.java line 58:

> 56:     private static volatile Point buttonCenter;
> 57: 
> 58:     private static final CountDownLatch windowGainedFocus = new CountDownLatch(1);

line here is too long and probably should be put in 2 lines

test/jdk/javax/swing/JButton/bug4490179.java line 123:

> 121: 
> 122:                 if (actionPerformed.await(100, MILLISECONDS)) {
> 123:                     throw new RuntimeException("Action event triggered by releasing button 3");

line here also should be put into 2 lines

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

Marked as reviewed by achung (Committer).

PR Review: https://git.openjdk.org/jdk/pull/21474#pullrequestreview-2370817634
PR Review Comment: https://git.openjdk.org/jdk/pull/21474#discussion_r1802093884
PR Review Comment: https://git.openjdk.org/jdk/pull/21474#discussion_r1802094338


More information about the client-libs-dev mailing list