Skip to content

8381443: SystemMenuBarHelpMenuTest fails on macOS#2147

Open
dmarkov20 wants to merge 2 commits intoopenjdk:masterfrom
dmarkov20:fix-8381443
Open

8381443: SystemMenuBarHelpMenuTest fails on macOS#2147
dmarkov20 wants to merge 2 commits intoopenjdk:masterfrom
dmarkov20:fix-8381443

Conversation

@dmarkov20
Copy link
Copy Markdown
Member

@dmarkov20 dmarkov20 commented Apr 13, 2026

The root cause of the test failure is that the robot does not successfully click on the "About" menu item. The test relies on hardcoded cursor coordinates and the Y coordinate value (80) is insufficient on some macOS systems with higher resolutions.

Replace the mouse click on the "About" menu item with keyboard interactions. This removes the dependency on hardcoded cursor positions and makes the test more robust across systems with different resolutions and font sizes.



Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Issue

  • JDK-8381443: SystemMenuBarHelpMenuTest fails on macOS (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/2147/head:pull/2147
$ git checkout pull/2147

Update a local copy of the PR:
$ git checkout pull/2147
$ git pull https://git.openjdk.org/jfx.git pull/2147/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 2147

View PR using the GUI difftool:
$ git pr show -t 2147

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/2147.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link
Copy Markdown

bridgekeeper bot commented Apr 13, 2026

👋 Welcome back dmarkov! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link
Copy Markdown

openjdk bot commented Apr 13, 2026

@dmarkov20 This change is no longer ready for integration - check the PR body for details.

@openjdk openjdk bot added the rfr Ready for review label Apr 13, 2026
@mlbridge
Copy link
Copy Markdown

mlbridge bot commented Apr 13, 2026

Webrevs

@andy-goryachev-oracle
Copy link
Copy Markdown
Contributor

/reviewers 2

@openjdk
Copy link
Copy Markdown

openjdk bot commented Apr 13, 2026

@andy-goryachev-oracle
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 1 Reviewer, 1 Author).

@andy-goryachev-oracle
Copy link
Copy Markdown
Contributor

sorry, it's a test fix. one reviewer is enough
/reviewers 1

@openjdk
Copy link
Copy Markdown

openjdk bot commented Apr 13, 2026

@andy-goryachev-oracle
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 1 (with at least 1 Reviewer).

Copy link
Copy Markdown
Contributor

@andy-goryachev-oracle andy-goryachev-oracle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested on macOS 26.3.1 with two monitors.

robot.mouseMove(MENU_BAR_X, MENU_ABOUT_Y);
robot.mouseClick(MouseButton.PRIMARY);
robot.keyType(KeyCode.DOWN);
robot.keyType(KeyCode.ENTER);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is reasonable.
I suppose the only scenario when the system menu is not focused is when the test must fail, which is exactly what we need.

@openjdk openjdk bot added the ready Ready to be integrated label Apr 13, 2026
@jperedadnr
Copy link
Copy Markdown
Collaborator

There was a reason for the mouse approach: the Spotlight search menu is not a node, it is a pure decoration that macOS adds to the Help menu.

By adding a key event, we are always sure that the first JavaFX menuItem is going to be selected (key events won't be affected by decorations, whether they are there or not), and the test will never fail.

However, the initial intention of this test was precisely to assert that there was a spotlight search decoration added precisely to the "Help" menu. I agree that using a hardcoded Y offset was probably a bad idea (as it didn't take into account multiple resolutions).

Could we find a better way?

@andy-goryachev-oracle
Copy link
Copy Markdown
Contributor

/reviewers 2

@openjdk
Copy link
Copy Markdown

openjdk bot commented Apr 13, 2026

@andy-goryachev-oracle
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 1 Reviewer, 1 Author).

@openjdk openjdk bot removed the ready Ready to be integrated label Apr 13, 2026
@kevinrushforth
Copy link
Copy Markdown
Member

I wonder if taking the screen size into account would help? Either way, the test is likely to be fragile unless we can find a reliable way to calculate the Y value of the About menu.

@andy-goryachev-oracle
Copy link
Copy Markdown
Contributor

maybe we can populate the menu with █ symbols and then detect these blocks in screen capture...

@dmarkov20
Copy link
Copy Markdown
Member Author

It looks like there is no reliable way to calculate the Y position of the About menu item. I would therefore suggest keeping the proposed change since it improves the stability of the test even though it does not cover one of the original scenarios the test was meant to verify. We could cover the Spotlight case in the macOS system menu with a separate manual test instead.
@jperedadnr What do you think?

@jperedadnr
Copy link
Copy Markdown
Collaborator

Technically, we could use an osascript like in the manual test MacOSSystemenuTestBase (see getMenuReaderProcess) to find the About position. But then the whole test, which was added to verify that the spotlight field was inserted when a "Help" menu was added to the system menu bar, could be solved just with this script.

So this test should probably be indeed moved to a manual test, with the sole purpose of visually confirming that the Spotlight is added under a "Help" menu, and optionally, use the osascript to verify it. Keeping it as a system test with the changes from this PR will always pass, so I don't see that much value for the test.

@dmarkov20
Copy link
Copy Markdown
Member Author

Technically, we could use an osascript like in the manual test MacOSSystemenuTestBase (see getMenuReaderProcess) to find the About position. But then the whole test, which was added to verify that the spotlight field was inserted when a "Help" menu was added to the system menu bar, could be solved just with this script.

So this test should probably be indeed moved to a manual test, with the sole purpose of visually confirming that the Spotlight is added under a "Help" menu, and optionally, use the osascript to verify it. Keeping it as a system test with the changes from this PR will always pass, so I don't see that much value for the test.

Well, the test file contains two tests that verify different aspects of the system menu bar behavior on macOS. Overall it still looks useful and I would prefer to keep it with the proposed changes unless there are objections.

As for verifying that the Spotlight field is added under the "Help" menu, I will file a new bug to introduce a separate manual test for that purpose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rfr Ready for review

Development

Successfully merging this pull request may close these issues.

4 participants