49 boolean listenersInvoked = false; 50 Object actionLock = new Object(); 51 Object listenersLock = new Object(); 52 static boolean isMacOS = false; 53 static final int clickDelay = 50; 54 55 ActionListener[] listeners; 56 boolean[] listenerStatus; 57 58 Object lLock = new Object(); 59 boolean doTest, listenerAdded; 60 Button b1; 61 62 public static void main(String[] args) throws Exception { 63 if (! SystemTray.isSupported()) { 64 System.out.println("SystemTray not supported on the platform under test. " + 65 "Marking the test passed"); 66 } else { 67 if (System.getProperty("os.name").toLowerCase().startsWith("mac")) { 68 isMacOS = true; 69 } 70 new ActionEventMask().doTest(); 71 } 72 } 73 74 public ActionEventMask() throws Exception { 75 EventQueue.invokeAndWait(this::initializeGUI); 76 } 77 78 void initializeGUI() { 79 SystemTray tray = SystemTray.getSystemTray(); 80 icon = new TrayIcon(new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB), "Sample Icon"); 81 82 Toolkit.getDefaultToolkit().addAWTEventListener(event -> { 83 if (doTest) { 84 System.out.println("ActionListener AWTEventListener"); 85 if (! icon.equals(event.getSource())) { 86 throw new RuntimeException("FAIL: ActionEvent not triggered for icon"); 87 } 88 actionPerformed = true; | 49 boolean listenersInvoked = false; 50 Object actionLock = new Object(); 51 Object listenersLock = new Object(); 52 static boolean isMacOS = false; 53 static final int clickDelay = 50; 54 55 ActionListener[] listeners; 56 boolean[] listenerStatus; 57 58 Object lLock = new Object(); 59 boolean doTest, listenerAdded; 60 Button b1; 61 62 public static void main(String[] args) throws Exception { 63 if (! SystemTray.isSupported()) { 64 System.out.println("SystemTray not supported on the platform under test. " + 65 "Marking the test passed"); 66 } else { 67 if (System.getProperty("os.name").toLowerCase().startsWith("mac")) { 68 isMacOS = true; 69 } else if( System.getProperty("os.name").toLowerCase() 70 .contains("linux") && System.getProperty("os.version") 71 .toLowerCase().contains("el7")) { 72 System.out.println("OEL 7 doesn't support double click in " + 73 "systray. Skipped"); 74 return; 75 } 76 new ActionEventMask().doTest(); 77 } 78 } 79 80 public ActionEventMask() throws Exception { 81 EventQueue.invokeAndWait(this::initializeGUI); 82 } 83 84 void initializeGUI() { 85 SystemTray tray = SystemTray.getSystemTray(); 86 icon = new TrayIcon(new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB), "Sample Icon"); 87 88 Toolkit.getDefaultToolkit().addAWTEventListener(event -> { 89 if (doTest) { 90 System.out.println("ActionListener AWTEventListener"); 91 if (! icon.equals(event.getSource())) { 92 throw new RuntimeException("FAIL: ActionEvent not triggered for icon"); 93 } 94 actionPerformed = true; |