--- old/src/java.desktop/unix/classes/sun/awt/X11/XTrayIconPeer.java 2015-11-25 11:12:20.048452500 +0300 +++ new/src/java.desktop/unix/classes/sun/awt/X11/XTrayIconPeer.java 2015-11-25 11:12:19.073355000 +0300 @@ -413,6 +413,7 @@ void addListeners() { canvas.addMouseListener(eventProxy); canvas.addMouseMotionListener(eventProxy); + eframe.addMouseListener(eventProxy); } long getWindow() { --- old/test/java/awt/TrayIcon/SecurityCheck/FunctionalityCheck/tray.policy 2015-11-25 11:12:23.515799200 +0300 +++ new/test/java/awt/TrayIcon/SecurityCheck/FunctionalityCheck/tray.policy 2015-11-25 11:12:22.857733400 +0300 @@ -5,6 +5,7 @@ permission java.util.PropertyPermission "resultsDir", "read"; permission java.util.PropertyPermission "user.home", "read"; permission java.util.PropertyPermission "os.name", "read"; + permission java.util.PropertyPermission "os.version", "read"; permission java.awt.AWTPermission "accessEventQueue"; permission java.lang.RuntimePermission "setIO"; permission java.lang.RuntimePermission "accessDeclaredMembers"; @@ -17,5 +18,6 @@ permission java.util.PropertyPermission "java.class.path", "read"; permission java.awt.AWTPermission "readDisplayPixels"; permission java.awt.AWTPermission "watchMousePointer"; + }; --- old/test/java/awt/TrayIcon/MouseMovedTest/MouseMovedTest.java 2015-11-25 11:12:27.063153900 +0300 +++ new/test/java/awt/TrayIcon/MouseMovedTest/MouseMovedTest.java 2015-11-25 11:12:26.367084300 +0300 @@ -31,7 +31,7 @@ * @summary Check for mouseMoved event for java.awt.TrayIcon * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com) * @library ../../../../lib/testlibrary - * @build ExtendedRobot + * @build ExtendedRobot SystemTrayIconHelper * @run main MouseMovedTest */ @@ -39,6 +39,14 @@ static volatile boolean moved; public static void main(String[] args) throws Exception { + if (!SystemTray.isSupported()) { + return; + } + + if (SystemTrayIconHelper.isOel7()) { + return; + } + moved = false; TrayIcon icon = new TrayIcon(new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB), "Test icon"); --- old/test/java/awt/TrayIcon/MouseEventMask/MouseEventMaskTest.java 2015-11-25 11:12:32.095657100 +0300 +++ new/test/java/awt/TrayIcon/MouseEventMask/MouseEventMaskTest.java 2015-11-25 11:12:30.981545700 +0300 @@ -71,6 +71,8 @@ "\"Always show all icons and notifications on the taskbar\" true " + "to avoid this problem. Or change behavior only for Java SE tray " + "icon and rerun test."); + } else if (SystemTrayIconHelper.isOel7()) { + return; } new MouseEventMaskTest().doTest(); } --- old/test/java/awt/TrayIcon/ActionCommand/ActionCommand.java 2015-11-25 11:12:35.871034600 +0300 +++ new/test/java/awt/TrayIcon/ActionCommand/ActionCommand.java 2015-11-25 11:12:35.199967500 +0300 @@ -59,8 +59,11 @@ "and rerun test."); } else if (System.getProperty("os.name").toLowerCase().startsWith("mac")){ isMacOS = true; + } else if (SystemTrayIconHelper.isOel7()) { + System.out.println("OEL 7 doesn't support double click in " + + "systray. Skipped"); + return; } - new ActionCommand().doTest(); } } --- old/test/java/awt/TrayIcon/ActionEventMask/ActionEventMask.java 2015-11-25 11:12:39.515399000 +0300 +++ new/test/java/awt/TrayIcon/ActionEventMask/ActionEventMask.java 2015-11-25 11:12:38.724319900 +0300 @@ -66,6 +66,10 @@ } else { if (System.getProperty("os.name").toLowerCase().startsWith("mac")) { isMacOS = true; + } else if (SystemTrayIconHelper.isOel7()) { + System.out.println("OEL 7 doesn't support double click in " + + "systray. Skipped"); + return; } new ActionEventMask().doTest(); } --- old/test/java/awt/TrayIcon/ModalityTest/ModalityTest.java 2015-11-25 11:12:43.009748400 +0300 +++ new/test/java/awt/TrayIcon/ModalityTest/ModalityTest.java 2015-11-25 11:12:42.310678500 +0300 @@ -35,6 +35,7 @@ */ public class ModalityTest { + private static boolean isOEL7; TrayIcon icon; ExtendedRobot robot; Dialog d; @@ -80,7 +81,7 @@ "\"Always show all icons and notifications on the taskbar\" true " + "to avoid this problem. Or change behavior only for Java SE tray " + "icon and rerun test."); - + isOEL7 = SystemTrayIconHelper.isOel7(); new ModalityTest().doTest(); } } @@ -225,6 +226,12 @@ Point iconPosition = SystemTrayIconHelper.getTrayIconLocation(icon); if (iconPosition == null) throw new RuntimeException("Unable to find the icon location!"); + if (isOEL7) { + // close tray + robot.mouseMove(100,100); + robot.click(InputEvent.BUTTON1_MASK); + robot.waitForIdle(2000); + } if (! d.isVisible()) throw new RuntimeException("FAIL: The modal dialog is not yet visible"); @@ -232,27 +239,35 @@ robot.mouseMove(iconPosition.x, iconPosition.y); robot.waitForIdle(2000); - SystemTrayIconHelper.doubleClick(robot); + if(!isOEL7) { + SystemTrayIconHelper.doubleClick(robot); - if (! actionPerformed) { - synchronized (actionLock) { - try { - actionLock.wait(3000); - } catch (Exception e) { + if (!actionPerformed) { + synchronized (actionLock) { + try { + actionLock.wait(3000); + } catch (Exception e) { + } } } + if (!actionPerformed) + throw new RuntimeException("FAIL: ActionEvent not triggered when TrayIcon is double clicked"); } - if (! actionPerformed) - throw new RuntimeException("FAIL: ActionEvent not triggered when TrayIcon is double clicked"); for (int i = 0; i < buttonTypes.length; i++) { mousePressed = false; - robot.mousePress(buttonTypes[i]); + if(isOEL7) { + SystemTrayIconHelper.openTrayIfNeeded(robot); + robot.mouseMove(iconPosition.x, iconPosition.y); + robot.click(buttonTypes[i]); + } else { + robot.mousePress(buttonTypes[i]); + } if (! mousePressed) { synchronized (pressLock) { try { - pressLock.wait(3000); + pressLock.wait(6000); } catch (Exception e) { } } @@ -264,12 +279,18 @@ mouseReleased = false; mouseClicked = false; - robot.mouseRelease(buttonTypes[i]); + if(isOEL7) { + SystemTrayIconHelper.openTrayIfNeeded(robot); + robot.mouseMove(iconPosition.x, iconPosition.y); + robot.click(buttonTypes[i]); + } else { + robot.mouseRelease(buttonTypes[i]); + } if (! mouseReleased) { synchronized (releaseLock) { try { - releaseLock.wait(3000); + releaseLock.wait(6000); } catch (Exception e) { } } @@ -281,7 +302,7 @@ if (! mouseClicked) { synchronized (clickLock) { try { - clickLock.wait(3000); + clickLock.wait(6000); } catch (Exception e) { } } @@ -290,13 +311,14 @@ throw new RuntimeException("FAIL: mouseClicked not triggered when " + buttonNames[i] + " pressed & released"); } - - mouseMoved = false; - robot.mouseMove(iconPosition.x, iconPosition.y); - robot.glide(iconPosition.x + 100, iconPosition.y); - - if (! mouseMoved) - if (! SystemTrayIconHelper.skip(0) ) - throw new RuntimeException("FAIL: mouseMoved not triggered even when mouse moved over the icon"); + if (!isOEL7) { + mouseMoved = false; + robot.mouseMove(iconPosition.x, iconPosition.y); + robot.glide(iconPosition.x + 100, iconPosition.y); + + if (!mouseMoved) + if (!SystemTrayIconHelper.skip(0)) + throw new RuntimeException("FAIL: mouseMoved not triggered even when mouse moved over the icon"); + } } } --- old/test/java/awt/TrayIcon/SecurityCheck/FunctionalityCheck/FunctionalityCheck.java 2015-11-25 11:12:47.500197400 +0300 +++ new/test/java/awt/TrayIcon/SecurityCheck/FunctionalityCheck/FunctionalityCheck.java 2015-11-25 11:12:46.839131300 +0300 @@ -51,6 +51,7 @@ boolean mouseReleased = false; boolean mouseClicked = false; boolean mouseMoved = false; + static boolean isOEL7; static final int[] buttonTypes = { InputEvent.BUTTON1_MASK, @@ -69,6 +70,7 @@ System.out.println("SystemTray not supported on the platform under test. " + "Marking the test passed"); } else { + isOEL7 = SystemTrayIconHelper.isOel7(); new FunctionalityCheck().doTest(); } } @@ -188,31 +190,44 @@ Point iconPosition = SystemTrayIconHelper.getTrayIconLocation(icon); if (iconPosition == null) throw new RuntimeException("Unable to find the icon location!"); + if (isOEL7) { + // close tray + robot.mouseMove(100,100); + robot.click(InputEvent.BUTTON1_MASK); + robot.waitForIdle(2000); + } robot.mouseMove(iconPosition.x, iconPosition.y); - robot.waitForIdle(2000); - - SystemTrayIconHelper.doubleClick(robot); + robot.waitForIdle(); + if(!isOEL7) { + SystemTrayIconHelper.doubleClick(robot); - if (! actionPerformed) { - synchronized (actionLock) { - try { - actionLock.wait(3000); - } catch (Exception e) { + if (!actionPerformed) { + synchronized (actionLock) { + try { + actionLock.wait(3000); + } catch (Exception e) { + } } } + if (!actionPerformed) + throw new RuntimeException("FAIL: ActionEvent not triggered when TrayIcon is double clicked"); } - if (! actionPerformed) - throw new RuntimeException("FAIL: ActionEvent not triggered when TrayIcon is double clicked"); for (int i = 0; i < buttonTypes.length; i++) { mousePressed = false; - robot.mousePress(buttonTypes[i]); + if(isOEL7) { + SystemTrayIconHelper.openTrayIfNeeded(robot); + robot.mouseMove(iconPosition.x, iconPosition.y); + robot.click(buttonTypes[i]); + } else { + robot.mousePress(buttonTypes[i]); + } if (! mousePressed) { synchronized (pressLock) { try { - pressLock.wait(3000); + pressLock.wait(6000); } catch (Exception e) { } } @@ -224,12 +239,17 @@ mouseReleased = false; mouseClicked = false; - robot.mouseRelease(buttonTypes[i]); - + if(isOEL7) { + SystemTrayIconHelper.openTrayIfNeeded(robot); + robot.mouseMove(iconPosition.x, iconPosition.y); + robot.click(buttonTypes[i]); + } else { + robot.mouseRelease(buttonTypes[i]); + } if (! mouseReleased) { synchronized (releaseLock) { try { - releaseLock.wait(3000); + releaseLock.wait(6000); } catch (Exception e) { } } @@ -242,7 +262,7 @@ if (! mouseClicked) { synchronized (clickLock) { try { - clickLock.wait(3000); + clickLock.wait(6000); } catch (Exception e) { } } @@ -251,13 +271,14 @@ throw new RuntimeException("FAIL: mouseClicked not triggered when " + buttonNames[i] + " pressed & released"); } - - mouseMoved = false; - robot.mouseMove(iconPosition.x + 100, iconPosition.y); - robot.glide(iconPosition.x, iconPosition.y); - - if (! mouseMoved) - if (! SystemTrayIconHelper.skip(0) ) - throw new RuntimeException("FAIL: mouseMoved not triggered even when mouse moved over the icon"); + if(!isOEL7) { + mouseMoved = false; + robot.mouseMove(iconPosition.x + 100, iconPosition.y); + robot.glide(iconPosition.x, iconPosition.y); + + if (!mouseMoved) + if (!SystemTrayIconHelper.skip(0)) + throw new RuntimeException("FAIL: mouseMoved not triggered even when mouse moved over the icon"); + } } } --- old/test/java/awt/TrayIcon/TrayIconEventModifiers/TrayIconEventModifiersTest.java 2015-11-25 11:12:50.893536700 +0300 +++ new/test/java/awt/TrayIcon/TrayIconEventModifiers/TrayIconEventModifiersTest.java 2015-11-25 11:12:50.260473400 +0300 @@ -121,6 +121,12 @@ }; } + if (SystemTrayIconHelper.isOel7()) { + System.out.println("OEL 7 doesn't support click modifiers in " + + "systray. Skipped"); + return; + } + new TrayIconEventModifiersTest().doTest(); } } --- old/test/java/awt/TrayIcon/TrayIconEvents/TrayIconEventsTest.java 2015-11-25 11:12:54.249872300 +0300 +++ new/test/java/awt/TrayIcon/TrayIconEvents/TrayIconEventsTest.java 2015-11-25 11:12:53.604807800 +0300 @@ -37,6 +37,7 @@ public class TrayIconEventsTest { + private static boolean isOEL7; TrayIcon icon; ExtendedRobot robot; @@ -77,6 +78,7 @@ "\"Always show all icons and notifications on the taskbar\" true " + "to avoid this problem. Or change behavior only for Java SE " + "tray icon."); + isOEL7 = SystemTrayIconHelper.isOel7(); new TrayIconEventsTest().doTest(); } } @@ -195,31 +197,44 @@ Point iconPosition = SystemTrayIconHelper.getTrayIconLocation(icon); if (iconPosition == null) throw new RuntimeException("Unable to find the icon location!"); + if (isOEL7) { + // close tray + robot.mouseMove(100,100); + robot.click(InputEvent.BUTTON1_MASK); + robot.waitForIdle(2000); + } robot.mouseMove(iconPosition.x, iconPosition.y); - robot.waitForIdle(2000); - - SystemTrayIconHelper.doubleClick(robot); + robot.waitForIdle(); + if(!isOEL7) { + SystemTrayIconHelper.doubleClick(robot); - if (! actionPerformed) { - synchronized (actionLock) { - try { - actionLock.wait(10000); - } catch (Exception e) { + if (!actionPerformed) { + synchronized (actionLock) { + try { + actionLock.wait(10000); + } catch (Exception e) { + } } } + if (!actionPerformed) + throw new RuntimeException("FAIL: ActionEvent not triggered when TrayIcon is double clicked"); } - if (! actionPerformed) - throw new RuntimeException("FAIL: ActionEvent not triggered when TrayIcon is double clicked"); for (int i = 0; i < buttonTypes.length; i++) { mousePressed = false; - robot.mousePress(buttonTypes[i]); + if(isOEL7) { + SystemTrayIconHelper.openTrayIfNeeded(robot); + robot.mouseMove(iconPosition.x, iconPosition.y); + robot.click(buttonTypes[i]); + } else { + robot.mousePress(buttonTypes[i]); + } if (! mousePressed) { synchronized (pressLock) { try { - pressLock.wait(3000); + pressLock.wait(6000); } catch (Exception e) { } } @@ -231,12 +246,18 @@ mouseReleased = false; mouseClicked = false; - robot.mouseRelease(buttonTypes[i]); + if(isOEL7) { + SystemTrayIconHelper.openTrayIfNeeded(robot); + robot.mouseMove(iconPosition.x, iconPosition.y); + robot.click(buttonTypes[i]); + } else { + robot.mouseRelease(buttonTypes[i]); + } if (! mouseReleased) { synchronized (releaseLock) { try { - releaseLock.wait(3000); + releaseLock.wait(6000); } catch (Exception e) { } } @@ -248,7 +269,7 @@ if (! mouseClicked) { synchronized (clickLock) { try { - clickLock.wait(3000); + clickLock.wait(6000); } catch (Exception e) { } } @@ -258,12 +279,14 @@ buttonNames[i] + " pressed & released"); } - mouseMoved = false; - robot.mouseMove(iconPosition.x + 100, iconPosition.y); - robot.glide(iconPosition.x, iconPosition.y); - - if (! mouseMoved) - if (! SystemTrayIconHelper.skip(0) ) - throw new RuntimeException("FAIL: mouseMoved not triggered even when mouse moved over the icon"); + if (!isOEL7) { + mouseMoved = false; + robot.mouseMove(iconPosition.x + 100, iconPosition.y); + robot.glide(iconPosition.x, iconPosition.y); + + if (!mouseMoved) + if (!SystemTrayIconHelper.skip(0)) + throw new RuntimeException("FAIL: mouseMoved not triggered even when mouse moved over the icon"); + } } } --- old/test/java/awt/TrayIcon/TrayIconMouseTest/TrayIconMouseTest.java 2015-11-25 11:12:57.774224700 +0300 +++ new/test/java/awt/TrayIcon/TrayIconMouseTest/TrayIconMouseTest.java 2015-11-25 11:12:57.016148900 +0300 @@ -66,6 +66,10 @@ } else { if (System.getProperty("os.name").toLowerCase().startsWith("mac")) { isMacOS = true; + } else if (SystemTrayIconHelper.isOel7()) { + System.out.println("OEL 7 doesn't support double click in " + + "systray. Skipped"); + return; } new TrayIconMouseTest().doTest(); } @@ -108,7 +112,7 @@ for (int i = 0; i < buttonTypes.length; i++) { actionPerformed = false; robot.click(buttonTypes[i]); - robot.waitForIdle(2000); + robot.waitForIdle(6000); if (isMacOS && actionPerformed && i == 2) { @@ -155,7 +159,7 @@ if (! actionPerformed) { synchronized (actionLock) { try { - actionLock.wait(3000); + actionLock.wait(6000); } catch (Exception e) { } } --- old/test/java/awt/TrayIcon/TrayIconPopup/TrayIconPopupTest.java 2015-11-25 11:13:01.227570000 +0300 +++ new/test/java/awt/TrayIcon/TrayIconPopup/TrayIconPopupTest.java 2015-11-25 11:13:00.573504600 +0300 @@ -127,7 +127,7 @@ robot.mousePress(InputEvent.BUTTON3_MASK); robot.delay(50); robot.mouseRelease(InputEvent.BUTTON3_MASK); - robot.delay(1000); + robot.delay(6000); robot.mouseMove(window.getLocation().x + 10, window.getLocation().y + 10); robot.mousePress(InputEvent.BUTTON3_MASK); --- old/test/java/awt/TrayIcon/SystemTrayIconHelper.java 2015-11-25 11:13:04.682915500 +0300 +++ new/test/java/awt/TrayIcon/SystemTrayIconHelper.java 2015-11-25 11:13:04.005847800 +0300 @@ -66,7 +66,9 @@ for (int x = (int) (screenSize.getWidth()-width); x > 0; x--) { for (int y = (int) (screenSize.getHeight()-height); y > (screenSize.getHeight()-50); y--) { if (imagesEquals(((BufferedImage)icon.getImage()).getSubimage(0, 0, width, height), screen.getSubimage(x, y, width, height))) { - return new Point(x+5, y+5); + Point point = new Point(x + 5, y + 5); + System.out.println("Icon location " + point); + return point; } } } @@ -91,6 +93,7 @@ point2d = (Point2D)m_getLocation.invoke(peer, new Object[]{model}); Point po = new Point((int)(point2d.getX()), (int)(point2d.getY())); po.translate(10, -5); + System.out.println("Icon location " + po); return po; }catch(Exception e) { e.printStackTrace(); @@ -101,12 +104,15 @@ // sun.awt.X11.XTrayIconPeer Field f_peer = getField(java.awt.TrayIcon.class, "peer"); + SystemTrayIconHelper.openTrayIfNeeded(robot); + Object peer = f_peer.get(icon); Method m_getLOS = peer.getClass().getDeclaredMethod( "getLocationOnScreen", new Class[]{}); m_getLOS.setAccessible(true); Point point = (Point)m_getLOS.invoke(peer, new Object[]{}); point.translate(5, 5); + System.out.println("Icon location " + point); return point; } catch (Exception e) { e.printStackTrace(); @@ -169,4 +175,38 @@ } return false; } + + public static boolean openTrayIfNeeded(Robot robot) { + String sysv = System.getProperty("os.version"); + System.out.println("System version is " + sysv); + //Additional step to raise the system try in Gnome 3 in OEL 7 + if(isOel7()) { + System.out.println("OEL 7 detected"); + GraphicsConfiguration gc = GraphicsEnvironment. + getLocalGraphicsEnvironment().getDefaultScreenDevice(). + getDefaultConfiguration(); + Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc); + if(insets.bottom > 0) { + Dimension screenSize = Toolkit.getDefaultToolkit() + .getScreenSize(); + robot.mouseMove(screenSize.width - insets.bottom / 2, + screenSize.height - insets.bottom / 2); + robot.delay(50); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.delay(50); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + robot.waitForIdle(); + robot.delay(1000); + System.out.println("Tray is opened"); + return true; + } + } + return false; + } + + public static boolean isOel7() { + return System.getProperty("os.name").toLowerCase() + .contains("linux") && System.getProperty("os.version") + .toLowerCase().contains("el7"); + } }