RFR: 8158801: [TEST_BUG] Mixing tests fail because of focus workaround trick [v4]

Khalid Boulanouare duke at openjdk.org
Fri Jul 18 14:13:49 UTC 2025


On Fri, 18 Jul 2025 04:00:45 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

>> 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.
>
>> 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

@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.

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

PR Comment: https://git.openjdk.org/jdk/pull/25971#issuecomment-3089604981


More information about the client-libs-dev mailing list