test/java/awt/event/KeyEvent/8020209/bug8020209.java
Print this page
*** 24,63 ****
/*
* @test
* @bug 8020209
* @summary [macosx] Mac OS X key event confusion for "COMMAND PLUS"
* @author leonid.romanov@oracle.com
* @run main bug8020209
*/
- import sun.awt.*;
import java.awt.*;
import java.awt.event.*;
public class bug8020209 {
static volatile int listenerCallCounter = 0;
static AWTKeyStroke keyStrokes[] = {
AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_DECIMAL, InputEvent.META_MASK),
AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_EQUALS, InputEvent.META_MASK),
AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_ESCAPE, InputEvent.CTRL_MASK),
};
public static void main(String[] args) throws Exception {
! if (sun.awt.OSInfo.getOSType() != sun.awt.OSInfo.OSType.MACOSX) {
System.out.println("This test is for MacOS only. Automatically passed on other platforms.");
return;
}
System.setProperty("apple.laf.useScreenMenuBar", "true");
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
createAndShowGUI();
! toolkit.realSync();
for (int i = 0; i < keyStrokes.length; ++i) {
AWTKeyStroke ks = keyStrokes[i];
int modKeyCode = getModKeyCode(ks.getModifiers());
--- 24,65 ----
/*
* @test
* @bug 8020209
* @summary [macosx] Mac OS X key event confusion for "COMMAND PLUS"
* @author leonid.romanov@oracle.com
+ * @library ../../../../../lib/testlibrary
+ * @build jdk.testlibrary.OSInfo
* @run main bug8020209
*/
import java.awt.*;
import java.awt.event.*;
+ import jdk.testlibrary.OSInfo;
+
public class bug8020209 {
static volatile int listenerCallCounter = 0;
static AWTKeyStroke keyStrokes[] = {
AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_DECIMAL, InputEvent.META_MASK),
AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_EQUALS, InputEvent.META_MASK),
AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_ESCAPE, InputEvent.CTRL_MASK),
};
public static void main(String[] args) throws Exception {
! if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
System.out.println("This test is for MacOS only. Automatically passed on other platforms.");
return;
}
System.setProperty("apple.laf.useScreenMenuBar", "true");
Robot robot = new Robot();
robot.setAutoDelay(50);
createAndShowGUI();
! robot.waitForIdle();
for (int i = 0; i < keyStrokes.length; ++i) {
AWTKeyStroke ks = keyStrokes[i];
int modKeyCode = getModKeyCode(ks.getModifiers());
*** 66,76 ****
robot.keyPress(ks.getKeyCode());
robot.keyRelease(ks.getKeyCode());
robot.keyRelease(modKeyCode);
! toolkit.realSync();
if (listenerCallCounter != 4) {
throw new Exception("Test failed: KeyListener for '" + ks.toString() +
"' called " + listenerCallCounter + " times instead of 4!");
}
--- 68,78 ----
robot.keyPress(ks.getKeyCode());
robot.keyRelease(ks.getKeyCode());
robot.keyRelease(modKeyCode);
! robot.waitForIdle();
if (listenerCallCounter != 4) {
throw new Exception("Test failed: KeyListener for '" + ks.toString() +
"' called " + listenerCallCounter + " times instead of 4!");
}