Skip to content

8158801: [TEST_BUG] Mixing tests fail because of focus workaround trick #25971

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 42 commits into
base: master
Choose a base branch
from

Conversation

kboulanou
Copy link
Contributor

@kboulanou kboulanou commented Jun 25, 2025

Many Mixing tests failed because the work around click lands on the minimizing area in the window control and causes the tests to fail.

This fix changes the width of base frames which allows most of tests to pass.


Progress

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

Issue

  • JDK-8158801: [TEST_BUG] Mixing tests fail because of focus workaround trick (Bug - P4)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 25971

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/25971.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 25, 2025

👋 Welcome back kboulanou! 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

openjdk bot commented Jun 25, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot added the rfr Pull request is ready for review label Jun 25, 2025
@openjdk
Copy link

openjdk bot commented Jun 25, 2025

@kboulanou The following label will be automatically applied to this pull request:

  • client

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the client client-libs-dev@openjdk.org label Jun 25, 2025
@mlbridge
Copy link

mlbridge bot commented Jun 25, 2025

@prsadhuk
Copy link
Contributor

What do you mean by "focus workaround trick" and " minimizing area in the window control"? Are you seeing click is happening on the minimize button on the frame and frame getting iconified?
In that case instead of changing the frame width/height, guess you can set with frame.setUndecorated to have undecorated windows..Also, I have seen this test renders the frame on the top-left corner, it will be good to keep it at the center of the frame using setLocationRelativeTo(null)

@kboulanou
Copy link
Contributor Author

In Windows machines, the click lands on the reduce control of the window, and this causes the windows to be iconified and the test fails.

I have tested with undecorated frames, but the test continues to fail. The test needs to click on the middle of the Windows title bar (Outside of the controls) to pass.

I will set the frames (The background undecorated frame, and the heavyweight component frames) on center as you have suggested.

@prsadhuk
Copy link
Contributor

In Windows machines, the click lands on the reduce control of the window, and this causes the windows to be iconified and the test fails.

WHich test in particular? or is it all tests have this behavior?

The test needs to click on the middle of the Windows title bar (Outside of the controls) to pass.

I tried JMenuBarOverlapping.java but I dont see any click on title bar..The cursor in on top-left of "Test Menu" menu..
If clicking on the title bar is needed to make it gain focus, probably you can try with calling frame.requestFocus and use CountDownLatch with timeout to wait till FOCUS_GAINED event is received and release the latch in focusGained() and then start the test

@myankelev
Copy link
Member

Minor: could you please update the copyright years?

@kboulanou
Copy link
Contributor Author

@prsadhuk I have reviewed the code again and I can point out where we do have the workaround click. It can be found in class SimpleOverlappingTestBase, in method performTest. Following is an excerpt of the source code:

/* this is a workaround for certain jtreg(?) focus issue:
           tests fail starting after failing mixing tests but always pass alone.
         */
        JFrame ancestor = (JFrame)(testedComponent.getTopLevelAncestor());
        if( ancestor != null ) {
            Point ancestorLoc = ancestor.getLocationOnScreen();
            ancestorLoc.translate(isOel7orLater() ? 5 :
                                             ancestor.getWidth() / 2 - 15, 2);
            robot.mouseMove(ancestorLoc.x, ancestorLoc.y);
            Util.waitForIdle(robot);
            robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.delay(50);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
            Util.waitForIdle(robot);
        }

I will use requestFocus as you have suggested and see if I get tests to pass.

@kboulanou
Copy link
Contributor Author

I will update copyright years for changed classes.

@kboulanou
Copy link
Contributor Author

@prsadhuk after applying your suggested change, I can see that it has fixed the issue for most of the tests but still the following tests didn't pass on Windows compared with the original fix of changing frame width :

java/awt/Mixing/AWT_Mixing/JProgressBarInGlassPaneOverlapping.java
java/awt/Mixing/AWT_Mixing/JScrollBarInGlassPaneOverlapping.java
java/awt/Mixing/AWT_Mixing/JSliderInGlassPaneOverlapping.java
java/awt/Mixing/AWT_Mixing/JTextAreaInGlassPaneOverlapping.java
java/awt/Mixing/AWT_Mixing/JTextFieldInGlassPaneOverlapping.java
java/awt/Mixing/AWT_Mixing/JToggleButtonInGlassPaneOverlapping.java
java/awt/Mixing/AWT_Mixing/OpaqueOverlapping.java

I will check why these tests had failed.

@openjdk
Copy link

openjdk bot commented Jul 22, 2025

@kboulanou Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information.

@kboulanou
Copy link
Contributor Author

@prsadhuk All tests passed after the applying both changes: Awaiting time set to one second and checking if component has focus first before requesting focus.

Copy link
Member

@aivanov-jdk aivanov-jdk left a comment

Choose a reason for hiding this comment

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

Strangely enough, these changes make no difference for me when I run Mixing tests locally. The same number of tests fails with and without this fix. However, it seems to affect the CI.

Additionally, I still see the windows / frames are minimised on Windows. I don't think this is expected, is it? Thus, your previous suggestion for increasing the size of the windows looks reasonable to me.

@kboulanou
Copy link
Contributor Author

@aivanov-jdk both increasing the width of the frames and the requesting focus in frames worked for me. The test creates many frames and once a test completed for an AWT component, the next frame is created and shown on top of previously created frame (Maybe we can improve this by disposing the frame that finished testing ...). For each AWT component, a mixing frame is created. I will try on Windows and see if I can catch anything.

@kboulanou
Copy link
Contributor Author

@aivanov-jdk I have tested all tests with the new modifications and they passed.

@kboulanou
Copy link
Contributor Author

@aivanov-jdk I have tested on a Windows 11 Pro, before and after the fix in this PR, and I can see only 3 tests failing after an initial 26 failures.

@kboulanou
Copy link
Contributor Author

@prsadhuk I have updated this PR to center all possible tests in the middle of the screen.

@kboulanou
Copy link
Contributor Author

Centered some missed frames. Tested all de-problem listed tests on all platforms and tests passed.

@@ -64,6 +64,7 @@ protected void prepareControls() {
frame = new JFrame("Mixing : Dropdown Overlapping test");
frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS));
frame.setSize(200, 200);
frame.setLocationRelativeTo(null);
Copy link
Member

Choose a reason for hiding this comment

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

Are we disposing this frame somewhere(it's applicable to all the test files)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@manukumarvs in the original test, frames are not disposed. I will include disposing frame after testing the heavyweight component.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems there are two types of testing, some use one frame (GlassPane) and others uses multiple frames. I have updated code to dispose of multiple frames. Currently testing my changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client client-libs-dev@openjdk.org rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

7 participants