RFR: 8343736: Test java/awt/Focus/UnaccessibleChoice/AccessibleChoiceTest.java failed: Choice can't be controlled by keyboard

Harshitha Onkar honkar at openjdk.org
Tue Nov 26 01:14:44 UTC 2024


On Fri, 22 Nov 2024 19:24:28 GMT, Damon Nguyen <dnguyen at openjdk.org> wrote:

> Test intermittently fails with a few different Exceptions. Initial report shows `Choice can't be controlled by keyboard` when failing. An additional report of an intermittent failure shows `Button does not have focus`.
> 
> Added some stability fixes. Additional delays, removed extraneous window, and added an additional focus check.
> 
> Debugged using additional screenshots during different failure points. Looks like sometimes the focus is still on the button. So, the delay has been added afterwards. Test passes on 22.04 Ubuntu machine with 100 repeats in CI. Also passed testing on all OS's with 50 repeats in CI.

These are on unchanged lines.

Do we need a delay of 1 sec on line#145?

if (choice.getSelectedItem() != choice.getItem(1)) - This needs to be changed to 
!choice.getSelectedItem().equals(choice.getItem(1))) as it a string comparison.

test/jdk/java/awt/Focus/UnaccessibleChoice/AccessibleChoiceTest.java line 55:

> 53:     Frame frame = new Frame("Accessible Choice Test Frame");
> 54:     Choice choice = new Choice();
> 55:     Button def = new Button("default owner");

More meaningful variable name? or may be `button` would also work

Suggestion:

    Button defaultOwner = new Button("default owner");

test/jdk/java/awt/Focus/UnaccessibleChoice/AccessibleChoiceTest.java line 103:

> 101:         // Focus default button and wait till it gets focus
> 102:         Point loc = def.getLocationOnScreen();
> 103:         robot.mouseMove(loc.x + 5, loc.y + 5);

For test stability it is better to move the click to the center of the button.

robot.mouseMove(loc.x + def.getWidth() / 2, loc.y + def.getHeight() / 2);

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

PR Review: https://git.openjdk.org/jdk/pull/22333#pullrequestreview-2459918102
PR Review Comment: https://git.openjdk.org/jdk/pull/22333#discussion_r1857536176
PR Review Comment: https://git.openjdk.org/jdk/pull/22333#discussion_r1857531021


More information about the client-libs-dev mailing list