RFR: 8281745: Create a regression test for JDK-4514331 [v2]

Sergey Bylokhov serb at openjdk.java.net
Thu Feb 17 05:12:07 UTC 2022


On Tue, 15 Feb 2022 08:49:54 GMT, Manukumar V S <mvs at openjdk.org> wrote:

>> Create a regression test for JDK-4514331.
>> It checks whether pressing 'Tab' key always shift focus to next component, even though the current focus is in JTextArea and some text is already selected.
>> 
>> Testing:
>> I have verified this test with JDK 1.3.1 and JDK 1.4.1 .
>> The issue is reproducible with JDK 1.3.1 and the test failed there, where the bug was originally reported and the test passed in JDK 1.4.1 where the issue was fixed.
>> I have tested it in Linux, Mac and Windows platforms and it passed everywhere.
>
> Manukumar V S has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Fixed review comments: frame created in EDT, waitForIdle() added after frame creation, editor access in EDT

test/jdk/javax/swing/JTextArea/4514331/TabShiftsFocusToNextComponent.java line 72:

> 70:             try {
> 71:                 SwingUtilities.invokeAndWait(() -> frame = new JFrame());
> 72:                 robot.waitForIdle();

This robot.waitForIdle(); is not needed, the frame is not visible, so no native peers are created->there are no events to flush. Call it after the invokeAndWait below where the actual window will be created on the screen.

test/jdk/javax/swing/JTextArea/4514331/TabShiftsFocusToNextComponent.java line 77:

> 75:                     setLookAndFeel(laf);
> 76:                     createUI();
> 77:                     editorLoc.set(editor.getLocationOnScreen());

the Editor location might be outdated here, it is better to show the frame in one invokeAndWait block, then call waitForIdle to flush all events, then request the location in screen for the editor on another invokeAndWait block.

test/jdk/javax/swing/JTextArea/4514331/TabShiftsFocusToNextComponent.java line 111:

> 109:             @Override
> 110:             public void focusGained(FocusEvent e) {
> 111:                 passed = true;

the "passed" var is set on EDT and then used on the main thread, I suggest marking it as volatile.

test/jdk/javax/swing/JTextArea/4514331/TabShiftsFocusToNextComponent.java line 128:

> 126:         try {
> 127:             UIManager.setLookAndFeel(laf);
> 128:             System.out.println("LookAndFeel: " + laf);

you should catch the UnsupportedLookAndFeelException, the gtk L&F might not be supported even on the headful system.

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

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



More information about the client-libs-dev mailing list