RFR: 8285698: Create a test to check the focus stealing of JPopupMenu from JComboBox

Phil Race prr at openjdk.java.net
Mon May 9 18:13:11 UTC 2022


On Wed, 27 Apr 2022 11:22:48 GMT, Manukumar V S <mvs at openjdk.org> wrote:

> This test verifies that showing a JPopupMenu shouldn't steal the focus out of current focused component..
> This fix moves an unstable closed test to open but updated to be more comprehensive in testing multiple Look and Feels and with some stabilisation improvements. The closed test had some dependencies with some proprietary libraries which are all removed here.
> 
> Testing:
> Tested using mach5 10 times per platform and got all Pass.

test/jdk/javax/swing/JPopupMenu/JPopupMenuFocusStealTest.java line 104:

> 102:                 SwingUtilities
> 103:                         .invokeAndWait(JPopupMenuFocusStealTest::disposeFrame);
> 104:             }

I know it'll work but similarly to another review (https://github.com/openjdk/jdk/pull/8477/files)
it seems to me that you can recode as
 SwingUtilities.invokeAndWait(
                         () -> isFocusOwner.set(comboBox.isFocusOwner()));
SwingUtilities
                         .invokeAndWait(JPopupMenuFocusStealTest::disposeFrame);
 if (isFocusOwner.get()) {
                     System.out.println("Test Passed for " + laf);
                 } else {
                     throw new RuntimeException("Test Failed for " + laf);
                 }

and don't need the finally block

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

PR: https://git.openjdk.java.net/jdk/pull/8426



More information about the client-libs-dev mailing list