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 * @key headful
27 * @bug 8020209
28 * @summary [macosx] Mac OS X key event confusion for "COMMAND PLUS"
29 * @author leonid.romanov@oracle.com
30 * @library ../../../../../lib/testlibrary
31 * @build jdk.testlibrary.OSInfo
32 * @run main bug8020209
33 */
34
35 import java.awt.*;
36 import java.awt.event.*;
37
38 import jdk.testlibrary.OSInfo;
39
40 public class bug8020209 {
41 static volatile int listenerCallCounter = 0;
42
43 static AWTKeyStroke keyStrokes[] = {
44 AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_DECIMAL, InputEvent.META_MASK),
45 AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_EQUALS, InputEvent.META_MASK),
46 AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_ESCAPE, InputEvent.CTRL_MASK),
47 };
48
49 public static void main(String[] args) throws Exception {
50 if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
51 System.out.println("This test is for MacOS only. Automatically passed on other platforms.");
52 return;
53 }
54
55 System.setProperty("apple.laf.useScreenMenuBar", "true");
56
57 Robot robot = new Robot();
58 robot.setAutoDelay(50);
59
60 createAndShowGUI();
61 robot.waitForIdle();
62
63 for (int i = 0; i < keyStrokes.length; ++i) {
64 AWTKeyStroke ks = keyStrokes[i];
65
66 int modKeyCode = getModKeyCode(ks.getModifiers());
67 robot.keyPress(modKeyCode);
68
69 robot.keyPress(ks.getKeyCode());
70 robot.keyRelease(ks.getKeyCode());
|
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 * @key headful
27 * @bug 8020209
28 * @summary [macosx] Mac OS X key event confusion for "COMMAND PLUS"
29 * @author leonid.romanov@oracle.com
30 * @library /test/lib
31 * @build jdk.test.lib.Platform
32 * @run main bug8020209
33 */
34
35 import java.awt.*;
36 import java.awt.event.*;
37
38 import jdk.test.lib.Platform;
39
40 public class bug8020209 {
41 static volatile int listenerCallCounter = 0;
42
43 static AWTKeyStroke keyStrokes[] = {
44 AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_DECIMAL, InputEvent.META_MASK),
45 AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_EQUALS, InputEvent.META_MASK),
46 AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_ESCAPE, InputEvent.CTRL_MASK),
47 };
48
49 public static void main(String[] args) throws Exception {
50 if (!Platform.isOSX()) {
51 System.out.println("This test is for MacOS only. Automatically passed on other platforms.");
52 return;
53 }
54
55 System.setProperty("apple.laf.useScreenMenuBar", "true");
56
57 Robot robot = new Robot();
58 robot.setAutoDelay(50);
59
60 createAndShowGUI();
61 robot.waitForIdle();
62
63 for (int i = 0; i < keyStrokes.length; ++i) {
64 AWTKeyStroke ks = keyStrokes[i];
65
66 int modKeyCode = getModKeyCode(ks.getModifiers());
67 robot.keyPress(modKeyCode);
68
69 robot.keyPress(ks.getKeyCode());
70 robot.keyRelease(ks.getKeyCode());
|