[Rev 01] RFR: 8244418: MenuBar: IOOB exception on requestFocus on empty bar

Ajit Ghaisas aghaisas at openjdk.java.net
Mon May 18 05:52:22 UTC 2020


On Sun, 17 May 2020 10:04:58 GMT, Jeanette Winzenburg <fastegal at openjdk.org> wrote:

>> Ajit Ghaisas has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   review_fixes
>
> modules/javafx.controls/src/test/java/test/javafx/scene/control/MenuBarTest.java line 134:
> 
>> 133:         int focusedIndex = MenuBarSkinShim.getFocusedIndex(skin);
>> 134:         assertEquals(focusedIndex, -1);
>> 135:     }
> 
> the assert should be the other way round, expected value should be the first parameter :)
> 
> didn't notice on first read and now only when writing a test case against our argument, c&p'ed the test as-is, replaced
> the requestFocus with simulating the notification from traversalListener and was confused about its value being -1
> Here's that modified test method (requires test api in MenuBarSkin and shim):
> 
>     @Test public void testSimulateTraverseIntoOnEmptyMenubar() {
>         menuBar.setFocusTraversable(true);
> 
>         AnchorPane root = new AnchorPane();
>         root.getChildren().add(menuBar);
>         startApp(root);
> 
>         MenuBarSkin skin = (MenuBarSkin)menuBar.getSkin();
>         assertTrue(skin != null);
> 
>         // simulate notification from traversalListener
>         MenuBarSkinShim.setFocusedIndex(skin, 0);
>         int focusedIndex = MenuBarSkinShim.getFocusedIndex(skin);
>         assertEquals(-1, focusedIndex);
>     }

Corrected the similar asserts in this file.

Thanks for suggestion on test. Yes. At best, we can simulate this with Shim.
I have added it now.

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

PR: https://git.openjdk.java.net/jfx/pull/216


More information about the openjfx-dev mailing list