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 * @key headful
27 * @bug 6827786
28 * @summary Tests duplicate mnemonics
29 * @author Peter Zhelezniakov
30 * @library ../../regtesthelpers
31 * @library ../../../../lib/testlibrary
32 * @modules java.desktop/sun.awt
33 * @build jdk.testlibrary.OSInfo
34 * @build Util
35 * @run main bug6827786
36 */
37 import jdk.testlibrary.OSInfo;
38 import java.awt.*;
39 import java.awt.event.KeyEvent;
40 import javax.swing.*;
41
42 public class bug6827786 {
43
44 private static JMenu menu;
45 private static Component focusable;
46
47 public static void main(String[] args) throws Exception {
48 Robot robot = new Robot();
49 robot.setAutoDelay(50);
50 // move mouse outside menu to prevent auto selection
51 robot.mouseMove(100,100);
52
53 SwingUtilities.invokeAndWait(new Runnable() {
54
55 public void run() {
56 createAndShowGUI();
57 }
58 });
59
60 robot.waitForIdle();
61
62 SwingUtilities.invokeAndWait(new Runnable() {
63
64 public void run() {
65 focusable.requestFocus();
66 }
67 });
68
69 robot.waitForIdle();
70 checkfocus();
71
72 // select menu
73 if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
74 Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_F);
75 } else {
76 Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_F);
77 }
78 // select submenu
79 Util.hitKeys(robot, KeyEvent.VK_S);
80 robot.waitForIdle();
81 // verify submenu is selected
82 verify(1);
83
84 Util.hitKeys(robot, KeyEvent.VK_S);
85 robot.waitForIdle();
86 // verify last item is selected
87 verify(2);
88
89 Util.hitKeys(robot, KeyEvent.VK_S);
90 robot.waitForIdle();
91 // selection should wrap to first item
92 verify(0);
93
|
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 * @key headful
27 * @bug 6827786
28 * @summary Tests duplicate mnemonics
29 * @author Peter Zhelezniakov
30 * @library ../../regtesthelpers
31 * @library /test/lib
32 * @modules java.desktop/sun.awt
33 * @build jdk.test.lib.Platform
34 * @build Util
35 * @run main bug6827786
36 */
37
38 import jdk.test.lib.Platform;
39 import java.awt.*;
40 import java.awt.event.KeyEvent;
41 import javax.swing.*;
42
43 public class bug6827786 {
44
45 private static JMenu menu;
46 private static Component focusable;
47
48 public static void main(String[] args) throws Exception {
49 Robot robot = new Robot();
50 robot.setAutoDelay(50);
51 // move mouse outside menu to prevent auto selection
52 robot.mouseMove(100,100);
53
54 SwingUtilities.invokeAndWait(new Runnable() {
55
56 public void run() {
57 createAndShowGUI();
58 }
59 });
60
61 robot.waitForIdle();
62
63 SwingUtilities.invokeAndWait(new Runnable() {
64
65 public void run() {
66 focusable.requestFocus();
67 }
68 });
69
70 robot.waitForIdle();
71 checkfocus();
72
73 // select menu
74 if (Platform.isOSX()) {
75 Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_F);
76 } else {
77 Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_F);
78 }
79 // select submenu
80 Util.hitKeys(robot, KeyEvent.VK_S);
81 robot.waitForIdle();
82 // verify submenu is selected
83 verify(1);
84
85 Util.hitKeys(robot, KeyEvent.VK_S);
86 robot.waitForIdle();
87 // verify last item is selected
88 verify(2);
89
90 Util.hitKeys(robot, KeyEvent.VK_S);
91 robot.waitForIdle();
92 // selection should wrap to first item
93 verify(0);
94
|