test/jdk/java/awt/TrayIcon/ActionCommand/ActionCommand.java
author serb
Wed, 21 Feb 2018 12:49:00 -0800
changeset 49096 eaef201ec301
parent 47216 71c04702a3d5
child 52739 7199c4da1a6f
permissions -rw-r--r--
8198333: ProblemList should be updated for headless mode Reviewed-by: psadhukhan, prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25137
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
     1
/*
34788
176e7a6529d4 8081457: TrayIcon tests fail in OEL 7 only
ssadetsky
parents: 25137
diff changeset
     2
 * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
25137
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
     4
 *
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
     7
 * published by the Free Software Foundation.
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
     8
 *
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    13
 * accompanied this code).
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    14
 *
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    18
 *
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    21
 * questions.
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    22
 */
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    23
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    24
import java.awt.*;
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    25
import java.awt.image.BufferedImage;
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    26
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    27
/*
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    28
 * @test
49096
eaef201ec301 8198333: ProblemList should be updated for headless mode
serb
parents: 47216
diff changeset
    29
 * @key headful
25137
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    30
 * @summary Check the return value of the getActionCommand method
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    31
 *          of the ActionEvent triggered when TrayIcon is double clicked
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    32
 *          (single clicked, on Mac)
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    33
 * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 36511
diff changeset
    34
 * @modules java.desktop/java.awt:open
25137
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    35
 * @library ../../../../lib/testlibrary ../
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 34788
diff changeset
    36
 * @library /java/awt/patchlib
9d0388c6b336 8142968: Module System implementation
alanb
parents: 34788
diff changeset
    37
 * @build java.desktop/java.awt.Helper
25137
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    38
 * @build ExtendedRobot SystemTrayIconHelper
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    39
 * @run main ActionCommand
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    40
 */
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    41
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    42
public class ActionCommand {
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    43
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    44
    TrayIcon icon;
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    45
    ExtendedRobot robot;
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    46
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    47
    boolean actionPerformed = false;
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    48
    Object actionLock = new Object();
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    49
    String actionCommand = null;
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    50
    static boolean isMacOS = false;
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    51
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    52
    public static void main(String[] args) throws Exception {
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    53
        if (! SystemTray.isSupported()) {
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    54
            System.out.println("SystemTray not supported on the platform under test. " +
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    55
                    "Marking the test passed");
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    56
        } else {
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    57
            if (System.getProperty("os.name").toLowerCase().startsWith("win")) {
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    58
                System.err.println("Test can fail if the icon hides to a tray icons pool " +
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    59
                        "in Windows 7, which is behavior by default.\n" +
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    60
                        "Set \"Right mouse click\" -> \"Customize notification icons\" -> " +
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    61
                        "\"Always show all icons and notifications on the taskbar\" true to " +
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    62
                        "avoid this problem. Or change behavior only for Java SE tray icon " +
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    63
                        "and rerun test.");
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    64
            } else  if (System.getProperty("os.name").toLowerCase().startsWith("mac")){
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    65
                isMacOS = true;
34788
176e7a6529d4 8081457: TrayIcon tests fail in OEL 7 only
ssadetsky
parents: 25137
diff changeset
    66
            } else if (SystemTrayIconHelper.isOel7()) {
176e7a6529d4 8081457: TrayIcon tests fail in OEL 7 only
ssadetsky
parents: 25137
diff changeset
    67
                System.out.println("OEL 7 doesn't support double click in " +
176e7a6529d4 8081457: TrayIcon tests fail in OEL 7 only
ssadetsky
parents: 25137
diff changeset
    68
                        "systray. Skipped");
176e7a6529d4 8081457: TrayIcon tests fail in OEL 7 only
ssadetsky
parents: 25137
diff changeset
    69
                return;
25137
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    70
            }
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    71
            new ActionCommand().doTest();
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    72
        }
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    73
    }
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    74
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    75
    void doTest() throws Exception {
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    76
        robot = new ExtendedRobot();
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    77
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    78
        EventQueue.invokeAndWait(() -> {
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    79
            SystemTray tray = SystemTray.getSystemTray();
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    80
            icon = new TrayIcon(new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB), "Sample Icon");
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    81
            icon.addActionListener((event) -> {
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    82
                actionPerformed = true;
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    83
                actionCommand = event.getActionCommand();
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    84
                synchronized (actionLock) {
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    85
                    try {
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    86
                        actionLock.notifyAll();
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    87
                    } catch (Exception e) {
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    88
                    }
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    89
                }
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    90
            });
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    91
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    92
            if (icon.getActionCommand() != null)
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    93
                throw new RuntimeException("FAIL: getActionCommand did not return null " +
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    94
                        "when no action command set " + icon.getActionCommand());
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    95
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    96
            icon.setActionCommand("Sample Command");
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    97
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    98
            if (! "Sample Command".equals(icon.getActionCommand()))
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
    99
                throw new RuntimeException("FAIL: getActionCommand did not return the correct value. " +
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   100
                        icon.getActionCommand() + " Expected: Sample Command");
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   101
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   102
            try {
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   103
                tray.add(icon);
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   104
            } catch (AWTException e) {
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   105
                throw new RuntimeException(e);
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   106
            }
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   107
        });
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   108
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   109
        robot.waitForIdle();
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   110
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   111
        Point iconPosition = SystemTrayIconHelper.getTrayIconLocation(icon);
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   112
        if (iconPosition == null)
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   113
            throw new RuntimeException("Unable to find the icon location!");
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   114
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   115
        robot.mouseMove(iconPosition.x, iconPosition.y);
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   116
        robot.waitForIdle(2000);
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   117
        actionPerformed = false;
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   118
        SystemTrayIconHelper.doubleClick(robot);
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   119
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   120
        if (! actionPerformed) {
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   121
            synchronized (actionLock) {
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   122
                try {
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   123
                    actionLock.wait(3000);
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   124
                } catch (Exception e) {
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   125
                }
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   126
            }
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   127
        }
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   128
        if (! actionPerformed) {
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   129
            throw new RuntimeException("FAIL: ActionEvent not triggered when TrayIcon is "+(isMacOS? "" : "double ")+"clicked");
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   130
        } else if (! "Sample Command".equals(actionCommand)) {
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   131
            throw new RuntimeException("FAIL: ActionEvent.getActionCommand did not return the correct " +
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   132
                    "value. Returned: " + actionCommand + " ; Expected: Sample Command");
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   133
        }
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   134
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   135
        EventQueue.invokeAndWait(() -> {
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   136
            icon.setActionCommand(null);
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   137
            if (icon.getActionCommand() != null) {
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   138
                throw new RuntimeException("FAIL: ActionCommand set to null. getActionCommand did " +
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   139
                        "not return null " + icon.getActionCommand());
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   140
            }
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   141
        });
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   142
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   143
        robot.mouseMove(0, 0);
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   144
        robot.waitForIdle();
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   145
        robot.mouseMove(iconPosition.x, iconPosition.y);
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   146
        robot.waitForIdle();
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   147
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   148
        actionPerformed = false;
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   149
        actionCommand = null;
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   150
        SystemTrayIconHelper.doubleClick(robot);
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   151
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   152
        if (! actionPerformed) {
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   153
            synchronized (actionLock) {
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   154
                try {
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   155
                    actionLock.wait(3000);
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   156
                } catch (Exception e) {
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   157
                }
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   158
            }
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   159
        }
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   160
        if (! actionPerformed) {
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   161
            throw new RuntimeException("FAIL: ActionEvent not triggered when ActionCommand set to " +
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   162
                    "null and then TrayIcon is "+(isMacOS? "" : "double ")+ "clicked");
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   163
        } else if (actionCommand != null) {
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   164
            throw new RuntimeException("FAIL: ActionEvent.getActionCommand did not return null " +
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   165
                    "when ActionCommand is set to null " + actionCommand);
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   166
        }
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   167
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   168
    }
43055e2deee9 8044765: Move functional tests AWT_SystemTray/Automated to openjdk repository
yan
parents:
diff changeset
   169
}