RFR: 8065097: [macosx] javax/swing/Popup/TaskbarPositionTest.java fails because Popup is one pixel off

Alexey Ivanov aivanov at openjdk.org
Wed Jun 29 13:39:57 UTC 2022


On Wed, 29 Jun 2022 08:28:20 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

> Test seems to fail in macOS citing popup location is 1 pixel off compared to combobox position ie
> `p.y 154 cpos.y 155`
> 
> But in macOS, popup location, if 1st entry is selected, is 1 pixel higher than combobox so it's expected as can be seen below
> <img width="661" alt="Screenshot 2022-06-29 at 1 53 42 PM" src="https://user-images.githubusercontent.com/43534309/176389227-4e568117-ffce-4b4a-92d7-ab5c78c4ce08.png">
> 
> so test is updated to add 1 pixel to popup location. 
> It will not affect windows and linux as popup is placed below the combobox in those platforms so 1 pixel higher will not make any difference.
> Also, added some stability fixes..Test passed for several iterations in all platforms in CI..

Changes requested by aivanov (Reviewer).

test/jdk/javax/swing/Popup/TaskbarPositionTest.java line 108:

> 106: 
> 107:         // Place the frame near the bottom. This is a pretty wild guess.
> 108:         frame.setLocation(0, (int) screenBounds.getHeight() - 2 * frame.getHeight());

The cast to `int` is unnecessary.

Below calculations let position the frame exactly at the bottom of the screen (excluding insets):


            frame.setLocation(0, screenBounds.y + screenBounds.height - frame.getHeight());

test/jdk/javax/swing/Popup/TaskbarPositionTest.java line 121:

> 119:         }
> 120: 
> 121:         frame.setLocationRelativeTo(null);

This line puts the frame in the centre of the screen and the test becomes useless. The frame *must be located* at the bottom of the screen to verify the popup windows are shown on top of the taskbar / dock. In fact, the popups are located so that bottom of the popup is at the bottom of the combobox / menu item.

test/jdk/javax/swing/Popup/TaskbarPositionTest.java line 350:

> 348:             Point pt = new Point(2, 2);
> 349:             SwingUtilities.convertPointToScreen(pt, panel);
> 350:             robot.mouseMove((int) pt.getX(), (int) pt.getY());

Suggestion:

            robot.mouseMove(pt.getX(), pt.getY());


Cast to `int` is redundant, isn't it?

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

PR: https://git.openjdk.org/jdk/pull/9321



More information about the client-libs-dev mailing list