< 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 (SystemTrayIconHelper.isOel7()) {
  75                 return;
  76             }
  77             new MouseEventMaskTest().doTest();
  78         }
  79     }
  80 
  81     public MouseEventMaskTest() throws Exception{
  82         EventQueue.invokeAndWait(this::initializeGUI);
  83     }
  84 
  85     void initializeGUI() {
  86 
  87         SystemTray tray = SystemTray.getSystemTray();
  88         icon = new TrayIcon(new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB), "Sample Icon");
  89 
  90         Toolkit.getDefaultToolkit().addAWTEventListener(event -> {
  91             if (mouseTest) {
  92                 if (! event.getSource().getClass().getName().contains("Canvas")) {
  93                     if (!icon.equals(event.getSource()))
  94                         throw new RuntimeException("FAIL: MouseEvent not triggered for icon " + event);
  95 


< prev index next >