8154328: [TEST_BUG] java/awt/TrayIcon/ActionEventTest/ActionEventTest.java
authorarapte
Fri, 06 May 2016 17:43:36 +0300
changeset 38405 ca9b02b01e18
parent 38404 13564d79068f
child 38406 3d483887b110
8154328: [TEST_BUG] java/awt/TrayIcon/ActionEventTest/ActionEventTest.java Reviewed-by: serb, rchamyal
jdk/test/java/awt/TrayIcon/ActionEventTest/ActionEventTest.java
--- a/jdk/test/java/awt/TrayIcon/ActionEventTest/ActionEventTest.java	Thu May 05 16:08:34 2016 +0300
+++ b/jdk/test/java/awt/TrayIcon/ActionEventTest/ActionEventTest.java	Fri May 06 17:43:36 2016 +0300
@@ -23,10 +23,13 @@
 
 /*
  * @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;
@@ -46,6 +49,7 @@
     Image image;
     TrayIcon icon;
     Robot robot;
+    boolean actionPerformed;
 
     public static void main(String[] args) throws Exception {
         if (!SystemTray.isSupported()) {
@@ -82,6 +86,7 @@
         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;
@@ -102,6 +107,9 @@
     }
 
     public void clear() {
+        robot.keyRelease(KeyEvent.VK_ALT);
+        robot.keyRelease(KeyEvent.VK_SHIFT);
+        robot.keyRelease(KeyEvent.VK_CONTROL);
         SystemTray.getSystemTray().remove(icon);
     }
 
@@ -123,10 +131,9 @@
         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);
+        }
     }
 }