RFR: 8158801: [TEST_BUG] Mixing tests fail because of focus workaround trick [v27]
Khalid Boulanouare
duke at openjdk.org
Wed Sep 3 09:14:47 UTC 2025
On Wed, 3 Sep 2025 03:58:56 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:
>> The GlassPaneOverlappingTestBase tests are not multi-frame tests, they do not use multiple frames where each frame has an AWT component to test Swing with that AWT component. If the frame is disposed in the SimpleOverlappingTestBase class, the frame will disappear and the test will fail. This applies only the the GlassPane tests (extending GlassPaneOverlappingTestBase)
>
> But the frame should be disposed *after* the test is executed, more specifically in finally block so am still not sure about this addition
@prsadhuk My understanding is that test which extend `GlassPaneOverlappingTestBase` use only on frame for testing all AWT component. If you have a look at implementation of method `prepareControls` in both `GlassPaneOverlappingTestBase` and in `SimpleOverlappingTestBase`, you will notice that in `GlassPaneOverlappingTestBase` we create only one instance frame, and we use this same frame for the whole lifecycle of the test for all AWT component. `performTest` method will test an AWT component at a time, and if we dispose of the ancestor frame, the test fails, because the next AWT component is expected to run on the same ancestor frame. On the contrary, in tests extending `SimpleOverlappingTestBase` each AWT component runs on its own Frame which is created on `prepareControls` method, so disposing that frame at the end of the `performTest` method, does not affect the next AWT components, because they have their own frame.
For this reason I introduced the flag `multiFramesTest` to differentiate between multi-frames tests (Extending `SimpleOverlappingTestBase`) and one frame tests (Extending `GlassPaneOverlappingTestBase`).
On slightly different topic, parent class OverlappingTestBase have method `cleanup` which is never used, but we can use to dispose of frame created by `GlassPaneOverlappingTestBase`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25971#discussion_r2318328990
More information about the client-libs-dev
mailing list