--- old/modules/javafx.controls/src/test/java/test/javafx/scene/control/MenuBarTest.java 2017-01-06 14:40:27.142885999 +0530 +++ new/modules/javafx.controls/src/test/java/test/javafx/scene/control/MenuBarTest.java 2017-01-06 14:40:26.922776000 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,6 +45,7 @@ import test.com.sun.javafx.pgstub.StubToolkit; import test.com.sun.javafx.scene.control.infrastructure.KeyEventFirer; +import test.com.sun.javafx.scene.control.infrastructure.KeyModifier; import test.com.sun.javafx.scene.control.infrastructure.MouseEventGenerator; import com.sun.javafx.scene.control.ContextMenuContent; import com.sun.javafx.scene.control.MenuBarMenuButtonShim; @@ -338,6 +339,7 @@ double xval = (menuBar.localToScene(menuBar.getLayoutBounds())).getMinX(); double yval = (menuBar.localToScene(menuBar.getLayoutBounds())).getMinY(); + // Click on menu1 to open it MenuButton mb = MenuBarSkinShim.getNodeForMenu(skin, 0); mb.getScene().getWindow().requestFocus(); SceneHelper.processMouseEvent(scene, @@ -346,10 +348,43 @@ MouseEventGenerator.generateMouseEvent(MouseEvent.MOUSE_RELEASED, xval+20, yval+20)); assertTrue(menu1.isShowing()); + // Right key press should skip menu2 that is disabled and + // should open up menu3 KeyEventFirer keyboard = new KeyEventFirer(mb.getScene()); keyboard.doKeyPress(KeyCode.RIGHT); tk.firePulse(); assertTrue(menu3.isShowing()); + + // Another right key press should cycle back and open menu1 + keyboard.doKeyPress(KeyCode.RIGHT); + tk.firePulse(); + assertTrue(menu1.isShowing()); + + // Left key press should cycle to end and open menu3 + keyboard.doKeyPress(KeyCode.LEFT); + tk.firePulse(); + assertTrue(menu3.isShowing()); + + // Another Left key press should skip menu2 that is disabled + // and should open up menu1 + keyboard.doKeyPress(KeyCode.LEFT); + tk.firePulse(); + assertTrue(menu1.isShowing()); + + + // Now, close the exapanded menu1, + keyboard.doKeyPress(KeyCode.ESCAPE); + tk.firePulse(); + + // Disable all menus and test menu selection key press + menu1.setDisable(true); + menu3.setDisable(true); + + keyboard.doKeyPress(KeyCode.RIGHT, KeyModifier.ALT); + tk.firePulse(); + assertFalse(menu1.isShowing()); + assertFalse(menu2.isShowing()); + assertFalse(menu3.isShowing()); }