42
43 boolean actionPerformed = false;
44 Object actionLock = new Object();
45 String actionCommand = null;
46 static boolean isMacOS = false;
47
48 public static void main(String[] args) throws Exception {
49 if (! SystemTray.isSupported()) {
50 System.out.println("SystemTray not supported on the platform under test. " +
51 "Marking the test passed");
52 } else {
53 if (System.getProperty("os.name").toLowerCase().startsWith("win")) {
54 System.err.println("Test can fail if the icon hides to a tray icons pool " +
55 "in Windows 7, which is behavior by default.\n" +
56 "Set \"Right mouse click\" -> \"Customize notification icons\" -> " +
57 "\"Always show all icons and notifications on the taskbar\" true to " +
58 "avoid this problem. Or change behavior only for Java SE tray icon " +
59 "and rerun test.");
60 } else if (System.getProperty("os.name").toLowerCase().startsWith("mac")){
61 isMacOS = true;
62 }
63
64 new ActionCommand().doTest();
65 }
66 }
67
68 void doTest() throws Exception {
69 robot = new ExtendedRobot();
70
71 EventQueue.invokeAndWait(() -> {
72 SystemTray tray = SystemTray.getSystemTray();
73 icon = new TrayIcon(new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB), "Sample Icon");
74 icon.addActionListener((event) -> {
75 actionPerformed = true;
76 actionCommand = event.getActionCommand();
77 synchronized (actionLock) {
78 try {
79 actionLock.notifyAll();
80 } catch (Exception e) {
81 }
82 }
83 });
|
42
43 boolean actionPerformed = false;
44 Object actionLock = new Object();
45 String actionCommand = null;
46 static boolean isMacOS = false;
47
48 public static void main(String[] args) throws Exception {
49 if (! SystemTray.isSupported()) {
50 System.out.println("SystemTray not supported on the platform under test. " +
51 "Marking the test passed");
52 } else {
53 if (System.getProperty("os.name").toLowerCase().startsWith("win")) {
54 System.err.println("Test can fail if the icon hides to a tray icons pool " +
55 "in Windows 7, which is behavior by default.\n" +
56 "Set \"Right mouse click\" -> \"Customize notification icons\" -> " +
57 "\"Always show all icons and notifications on the taskbar\" true to " +
58 "avoid this problem. Or change behavior only for Java SE tray icon " +
59 "and rerun test.");
60 } else if (System.getProperty("os.name").toLowerCase().startsWith("mac")){
61 isMacOS = true;
62 } else if (SystemTrayIconHelper.isOel7()) {
63 System.out.println("OEL 7 doesn't support double click in " +
64 "systray. Skipped");
65 return;
66 }
67 new ActionCommand().doTest();
68 }
69 }
70
71 void doTest() throws Exception {
72 robot = new ExtendedRobot();
73
74 EventQueue.invokeAndWait(() -> {
75 SystemTray tray = SystemTray.getSystemTray();
76 icon = new TrayIcon(new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB), "Sample Icon");
77 icon.addActionListener((event) -> {
78 actionPerformed = true;
79 actionCommand = event.getActionCommand();
80 synchronized (actionLock) {
81 try {
82 actionLock.notifyAll();
83 } catch (Exception e) {
84 }
85 }
86 });
|