1 /* 2 * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 test 26 @bug 6380743 27 @summary Submenu should be shown by mnemonic key press. 28 @author anton.tarasov@...: area=awt.focus 29 @run applet SubMenuShowTest.html 30 */ 31 32 import java.awt.*; 33 import java.awt.event.*; 34 import javax.swing.*; 35 import java.applet.Applet; 36 import java.util.concurrent.atomic.AtomicBoolean; 37 import java.lang.reflect.InvocationTargetException; 38 import test.java.awt.regtesthelpers.Util; 39 import jdk.testlibrary.OSInfo; 40 41 public class SubMenuShowTest extends Applet { 42 Robot robot; 43 JFrame frame = new JFrame("Test Frame"); 44 JMenuBar bar = new JMenuBar(); 45 JMenu menu = new JMenu("Menu"); 46 JMenu submenu = new JMenu("More"); 82 activated.notifyAll(); 83 } 84 } 85 }); 86 87 frame.setVisible(true); 88 Util.waitForIdle(robot); 89 90 boolean isMacOSX = (OSInfo.getOSType() == OSInfo.OSType.MACOSX); 91 if (isMacOSX) { 92 robot.keyPress(KeyEvent.VK_CONTROL); 93 robot.delay(20); 94 } 95 robot.keyPress(KeyEvent.VK_ALT); 96 robot.delay(20); 97 robot.keyPress(KeyEvent.VK_F); 98 robot.delay(20); 99 robot.keyRelease(KeyEvent.VK_F); 100 robot.delay(20); 101 robot.keyRelease(KeyEvent.VK_ALT); 102 if (isMacOSX) { 103 robot.keyRelease(KeyEvent.VK_CONTROL); 104 robot.delay(20); 105 } 106 Util.waitForIdle(robot); 107 108 robot.keyPress(KeyEvent.VK_M); 109 robot.delay(20); 110 robot.keyRelease(KeyEvent.VK_M); 111 Util.waitForIdle(robot); 112 113 robot.keyPress(KeyEvent.VK_SPACE); 114 robot.delay(20); 115 robot.keyRelease(KeyEvent.VK_SPACE); 116 Util.waitForIdle(robot); 117 118 if (!Util.waitForCondition(activated, 2000)) { 119 throw new TestFailedException("a submenu wasn't activated by mnemonic key press"); 120 } 121 | 1 /* 2 * Copyright (c) 2006, 2013, 2016 Oracle and/or its affiliates. All rights 3 * reserved. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 6 * This code is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 only, as 8 * published by the Free Software Foundation. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 */ 24 25 /* 26 test 27 @bug 6380743 8158380 28 @summary Submenu should be shown by mnemonic key press. 29 @author anton.tarasov@...: area=awt.focus 30 @run applet SubMenuShowTest.html 31 */ 32 33 import java.awt.*; 34 import java.awt.event.*; 35 import javax.swing.*; 36 import java.applet.Applet; 37 import java.util.concurrent.atomic.AtomicBoolean; 38 import java.lang.reflect.InvocationTargetException; 39 import test.java.awt.regtesthelpers.Util; 40 import jdk.testlibrary.OSInfo; 41 42 public class SubMenuShowTest extends Applet { 43 Robot robot; 44 JFrame frame = new JFrame("Test Frame"); 45 JMenuBar bar = new JMenuBar(); 46 JMenu menu = new JMenu("Menu"); 47 JMenu submenu = new JMenu("More"); 83 activated.notifyAll(); 84 } 85 } 86 }); 87 88 frame.setVisible(true); 89 Util.waitForIdle(robot); 90 91 boolean isMacOSX = (OSInfo.getOSType() == OSInfo.OSType.MACOSX); 92 if (isMacOSX) { 93 robot.keyPress(KeyEvent.VK_CONTROL); 94 robot.delay(20); 95 } 96 robot.keyPress(KeyEvent.VK_ALT); 97 robot.delay(20); 98 robot.keyPress(KeyEvent.VK_F); 99 robot.delay(20); 100 robot.keyRelease(KeyEvent.VK_F); 101 robot.delay(20); 102 robot.keyRelease(KeyEvent.VK_ALT); 103 Util.waitForIdle(robot); 104 105 if (isMacOSX) { 106 robot.keyRelease(KeyEvent.VK_CONTROL); 107 robot.delay(20); 108 } 109 Util.waitForIdle(robot); 110 111 robot.keyPress(KeyEvent.VK_M); 112 robot.delay(20); 113 robot.keyRelease(KeyEvent.VK_M); 114 Util.waitForIdle(robot); 115 116 robot.keyPress(KeyEvent.VK_SPACE); 117 robot.delay(20); 118 robot.keyRelease(KeyEvent.VK_SPACE); 119 Util.waitForIdle(robot); 120 121 if (!Util.waitForCondition(activated, 2000)) { 122 throw new TestFailedException("a submenu wasn't activated by mnemonic key press"); 123 } 124 |