< prev index next >
test/java/awt/TrayIcon/ActionEventTest/ActionEventTest.java
Print this page
@@ -21,14 +21,17 @@
* questions.
*/
/*
* @test
- * @bug 6191390
+ * @bug 6191390 8154328
* @summary Verify that ActionEvent is received with correct modifiers set.
* @library ../../../../lib/testlibrary ../
+ * @library /java/awt/patchlib
+ * @build java.desktop/java.awt.Helper
* @build ExtendedRobot SystemTrayIconHelper
+ * @run main ActionEventTest
*/
import java.awt.Image;
import java.awt.TrayIcon;
import java.awt.SystemTray;
@@ -44,10 +47,11 @@
public class ActionEventTest {
Image image;
TrayIcon icon;
Robot robot;
+ boolean actionPerformed;
public static void main(String[] args) throws Exception {
if (!SystemTray.isSupported()) {
System.out.println("SystemTray not supported on the platform." +
" Marking the test passed.");
@@ -80,10 +84,11 @@
icon = new TrayIcon(
new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB), "ti");
icon.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
+ actionPerformed = true;
int md = ae.getModifiers();
int expectedMask = ActionEvent.ALT_MASK | ActionEvent.CTRL_MASK
| ActionEvent.SHIFT_MASK;
if ((md & expectedMask) != expectedMask) {
@@ -100,10 +105,13 @@
throw new RuntimeException(e);
}
}
public void clear() {
+ robot.keyRelease(KeyEvent.VK_ALT);
+ robot.keyRelease(KeyEvent.VK_SHIFT);
+ robot.keyRelease(KeyEvent.VK_CONTROL);
SystemTray.getSystemTray().remove(icon);
}
void doTest() throws Exception {
robot.keyPress(KeyEvent.VK_ALT);
@@ -121,12 +129,11 @@
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
robot.delay(100);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
- robot.delay(100);
robot.waitForIdle();
- robot.keyRelease(KeyEvent.VK_ALT);
- robot.keyRelease(KeyEvent.VK_SHIFT);
- robot.keyRelease(KeyEvent.VK_CONTROL);
+ if (!actionPerformed) {
+ robot.delay(500);
+ }
}
}
< prev index next >