<AWT Dev> RFR: 8253682: The AppletInitialFocusTest1.java is unstable

Sergey Bylokhov serb at openjdk.java.net
Tue Sep 29 10:23:28 UTC 2020


On Tue, 29 Sep 2020 10:03:05 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

> The test assumes that the code below will trigger the focus event on the button2 immediately after setVisible(), but
> the window can become visible really fast before button2.requestFocus(); is called, so temporarily the button1 will get
> a focus for a small moment.
>         add(button1);
>         add(button2);
>         setVisible(true);
>         button2.requestFocus();
> 
> After the fix, the test will wait for the last focus event, and after that, it checks that the correct button is
> focused.

test/jdk/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest1.java line 60:

> 58:         }
> 59:         /*
> 60:          * This applet is designed to be run only with appletviewer,

This is the old code assumed that the test is executed via appletviewer as an applet.

test/jdk/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest1.java line 71:

> 69:     }
> 70:
> 71:     public void focusLost(FocusEvent e) {

Won't fail immediately but wait for some other focus events.

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

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


More information about the awt-dev mailing list