< prev index next >

test/java/awt/TrayIcon/MouseEventMask/MouseEventMaskTest.java

Print this page




  54     };
  55 
  56     boolean mouseEventTriggered = false;
  57     boolean mouseMotionEventTriggered = false;
  58     Object mouseEventLock = new Object();
  59     Object mouseMotionEventLock = new Object();
  60     boolean mouseMotionTest, mouseTest;
  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("win")) {
  68                 System.err.println("Test can fail if the icon hides to a tray icons pool " +
  69                         "in Windows 7, which is behavior by default.\n" +
  70                         "Set \"Right mouse click\" -> \"Customize notification icons\" -> " +
  71                         "\"Always show all icons and notifications on the taskbar\" true " +
  72                         "to avoid this problem. Or change behavior only for Java SE tray " +
  73                         "icon and rerun test.");




  74             }
  75             new MouseEventMaskTest().doTest();
  76         }
  77     }
  78 
  79     public MouseEventMaskTest() throws Exception{
  80         EventQueue.invokeAndWait(this::initializeGUI);
  81     }
  82 
  83     void initializeGUI() {
  84 
  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 (mouseTest) {
  90                 if (! event.getSource().getClass().getName().contains("Canvas")) {
  91                     if (!icon.equals(event.getSource()))
  92                         throw new RuntimeException("FAIL: MouseEvent not triggered for icon " + event);
  93 




  54     };
  55 
  56     boolean mouseEventTriggered = false;
  57     boolean mouseMotionEventTriggered = false;
  58     Object mouseEventLock = new Object();
  59     Object mouseMotionEventLock = new Object();
  60     boolean mouseMotionTest, mouseTest;
  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("win")) {
  68                 System.err.println("Test can fail if the icon hides to a tray icons pool " +
  69                         "in Windows 7, which is behavior by default.\n" +
  70                         "Set \"Right mouse click\" -> \"Customize notification icons\" -> " +
  71                         "\"Always show all icons and notifications on the taskbar\" true " +
  72                         "to avoid this problem. Or change behavior only for Java SE tray " +
  73                         "icon and rerun test.");
  74             } else if (System.getProperty("os.name").toLowerCase()
  75                     .contains("linux") && System.getProperty("os.version")
  76                     .toLowerCase().contains("el7")) {
  77                 return;
  78             }
  79             new MouseEventMaskTest().doTest();
  80         }
  81     }
  82 
  83     public MouseEventMaskTest() throws Exception{
  84         EventQueue.invokeAndWait(this::initializeGUI);
  85     }
  86 
  87     void initializeGUI() {
  88 
  89         SystemTray tray = SystemTray.getSystemTray();
  90         icon = new TrayIcon(new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB), "Sample Icon");
  91 
  92         Toolkit.getDefaultToolkit().addAWTEventListener(event -> {
  93             if (mouseTest) {
  94                 if (! event.getSource().getClass().getName().contains("Canvas")) {
  95                     if (!icon.equals(event.getSource()))
  96                         throw new RuntimeException("FAIL: MouseEvent not triggered for icon " + event);
  97 


< prev index next >