RFR: 8315986: javax/swing/JMenuItem/4654927/bug4654927.java: component must be showing on the screen to determine its location [v4]

Alexey Ivanov aivanov at openjdk.org
Thu Oct 5 14:55:35 UTC 2023


On Wed, 4 Oct 2023 13:58:59 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

> So, I think pt 7 "close menu" is happening before pt 8 "drag mouse"....Yes, "point" is being reused but I guess it's ok

It is okay, yet I think it would be clearer and cleaner if the flow was like this:

1. Complete the first case, steps 1–5 above;
2. Click the menu to close it;
3. Drag the mouse.

The comment in the code says, “Drag the mouse”… but before it does so, it once retrieves the coordinates once again, then closes the menu and only now it starts dragging the mouse.

If you store the coordinates to `menuLocation` and `itemLocation` when performing the first test, the code becomes cleaner: one clearly sees the coordinates are re-used. (They're re-used either way but retrieved twice.) Then the sequence of the operations will become clearer too: first case (open menu, click greyed out item); close the menu; now start the second case (click the centre of the menu, which opens the menu again, drag the mouse to the greyed out item, release mouse).

Both @prrace and I interpreted closing the menu as an unexpected thing but it is intentional, the test needs to close the menu before it can verify the second case.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/15677#discussion_r1347554324


More information about the client-libs-dev mailing list