mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-06 09:29:38 +01:00
8348675: TrayIcon tests fail in Ubuntu 24.10 Wayland
Reviewed-by: aivanov, dnguyen
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -21,7 +21,14 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.*;
|
||||
import jdk.test.lib.Platform;
|
||||
import jtreg.SkippedException;
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Point;
|
||||
import java.awt.SystemTray;
|
||||
import java.awt.TrayIcon;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
/*
|
||||
@@ -30,12 +37,18 @@ import java.awt.image.BufferedImage;
|
||||
* @summary Check the return value of the getActionCommand method
|
||||
* of the ActionEvent triggered when TrayIcon is double clicked
|
||||
* (single clicked, on Mac)
|
||||
* @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
|
||||
* @modules java.desktop/java.awt:open
|
||||
* @library /lib/client ../
|
||||
* @library /java/awt/patchlib
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build ExtendedRobot SystemTrayIconHelper
|
||||
* @library
|
||||
* /java/awt/patchlib
|
||||
* /java/awt/TrayIcon
|
||||
* /lib/client
|
||||
* /test/lib
|
||||
* @build
|
||||
* java.desktop/java.awt.Helper
|
||||
* jdk.test.lib.Platform
|
||||
* jtreg.SkippedException
|
||||
* ExtendedRobot
|
||||
* SystemTrayIconHelper
|
||||
* @run main ActionCommand
|
||||
*/
|
||||
|
||||
@@ -44,32 +57,38 @@ public class ActionCommand {
|
||||
TrayIcon icon;
|
||||
ExtendedRobot robot;
|
||||
|
||||
boolean actionPerformed = false;
|
||||
Object actionLock = new Object();
|
||||
String actionCommand = null;
|
||||
volatile boolean actionPerformed = false;
|
||||
volatile String actionCommand = null;
|
||||
final Object actionLock = new Object();
|
||||
|
||||
static boolean isMacOS = false;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (! SystemTray.isSupported()) {
|
||||
System.out.println("SystemTray not supported on the platform under test. " +
|
||||
"Marking the test passed");
|
||||
} else {
|
||||
if (System.getProperty("os.name").toLowerCase().startsWith("win")) {
|
||||
System.err.println("Test can fail if the icon hides to a tray icons pool " +
|
||||
"in Windows 7, which is behavior by default.\n" +
|
||||
"Set \"Right mouse click\" -> \"Customize notification icons\" -> " +
|
||||
"\"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 (System.getProperty("os.name").toLowerCase().startsWith("mac")){
|
||||
isMacOS = true;
|
||||
} else if (SystemTrayIconHelper.isOel7orLater()) {
|
||||
System.out.println("OEL 7 doesn't support double click in " +
|
||||
"systray. Skipped");
|
||||
return;
|
||||
}
|
||||
new ActionCommand().doTest();
|
||||
if (Platform.isOnWayland()) {
|
||||
// The current robot implementation does not support
|
||||
// clicking in the system tray area.
|
||||
throw new SkippedException("Skipped on Wayland");
|
||||
}
|
||||
|
||||
if (!SystemTray.isSupported()) {
|
||||
throw new SkippedException("SystemTray is not supported on this platform.");
|
||||
}
|
||||
|
||||
if (Platform.isWindows()) {
|
||||
System.err.println("Test can fail if the icon hides to a tray icons pool " +
|
||||
"in Windows 7, which is behavior by default.\n" +
|
||||
"Set \"Right mouse click\" -> \"Customize notification icons\" -> " +
|
||||
"\"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 (Platform.isOSX()){
|
||||
isMacOS = true;
|
||||
} else if (SystemTrayIconHelper.isOel7orLater()) {
|
||||
System.out.println("OEL 7 doesn't support double click in " +
|
||||
"systray. Skipped");
|
||||
throw new SkippedException("Skipped on OEL 7+");
|
||||
}
|
||||
new ActionCommand().doTest();
|
||||
}
|
||||
|
||||
void doTest() throws Exception {
|
||||
@@ -95,7 +114,7 @@ public class ActionCommand {
|
||||
|
||||
icon.setActionCommand("Sample Command");
|
||||
|
||||
if (! "Sample Command".equals(icon.getActionCommand()))
|
||||
if (!"Sample Command".equals(icon.getActionCommand()))
|
||||
throw new RuntimeException("FAIL: getActionCommand did not return the correct value. " +
|
||||
icon.getActionCommand() + " Expected: Sample Command");
|
||||
|
||||
@@ -117,7 +136,7 @@ public class ActionCommand {
|
||||
actionPerformed = false;
|
||||
SystemTrayIconHelper.doubleClick(robot);
|
||||
|
||||
if (! actionPerformed) {
|
||||
if (!actionPerformed) {
|
||||
synchronized (actionLock) {
|
||||
try {
|
||||
actionLock.wait(3000);
|
||||
@@ -125,7 +144,7 @@ public class ActionCommand {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (! actionPerformed) {
|
||||
if (!actionPerformed) {
|
||||
throw new RuntimeException("FAIL: ActionEvent not triggered when TrayIcon is "+(isMacOS? "" : "double ")+"clicked");
|
||||
} else if (! "Sample Command".equals(actionCommand)) {
|
||||
throw new RuntimeException("FAIL: ActionEvent.getActionCommand did not return the correct " +
|
||||
@@ -140,7 +159,7 @@ public class ActionCommand {
|
||||
}
|
||||
});
|
||||
|
||||
robot.mouseMove(0, 0);
|
||||
robot.mouseMove(100, 0);
|
||||
robot.waitForIdle();
|
||||
robot.mouseMove(iconPosition.x, iconPosition.y);
|
||||
robot.waitForIdle();
|
||||
@@ -149,7 +168,7 @@ public class ActionCommand {
|
||||
actionCommand = null;
|
||||
SystemTrayIconHelper.doubleClick(robot);
|
||||
|
||||
if (! actionPerformed) {
|
||||
if (!actionPerformed) {
|
||||
synchronized (actionLock) {
|
||||
try {
|
||||
actionLock.wait(3000);
|
||||
@@ -157,7 +176,7 @@ public class ActionCommand {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (! actionPerformed) {
|
||||
if (!actionPerformed) {
|
||||
throw new RuntimeException("FAIL: ActionEvent not triggered when ActionCommand set to " +
|
||||
"null and then TrayIcon is "+(isMacOS? "" : "double ")+ "clicked");
|
||||
} else if (actionCommand != null) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -21,6 +21,9 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import jdk.test.lib.Platform;
|
||||
import jtreg.SkippedException;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Point;
|
||||
import java.awt.SystemTray;
|
||||
@@ -37,10 +40,17 @@ import java.awt.image.BufferedImage;
|
||||
* or single clicked with button 3 on Mac OS X
|
||||
* or single clicked with button 1 on rest.
|
||||
* @modules java.desktop/java.awt:open
|
||||
* @library /java/awt/patchlib
|
||||
* @library /lib/client ../
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build ExtendedRobot SystemTrayIconHelper
|
||||
* @library
|
||||
* /java/awt/patchlib
|
||||
* /java/awt/TrayIcon
|
||||
* /lib/client
|
||||
* /test/lib
|
||||
* @build
|
||||
* java.desktop/java.awt.Helper
|
||||
* jdk.test.lib.Platform
|
||||
* jtreg.SkippedException
|
||||
* ExtendedRobot
|
||||
* SystemTrayIconHelper
|
||||
* @run main TrayIconMouseTest
|
||||
*/
|
||||
|
||||
@@ -48,16 +58,18 @@ public class TrayIconMouseTest {
|
||||
|
||||
TrayIcon icon;
|
||||
ExtendedRobot robot;
|
||||
boolean actionPerformed = false;
|
||||
Object actionLock = new Object();
|
||||
|
||||
volatile boolean actionPerformed = false;
|
||||
final Object actionLock = new Object();
|
||||
|
||||
static boolean isMacOS = false;
|
||||
static boolean isWinOS = false;
|
||||
static boolean isOelOS = false;
|
||||
String caption = "Sample Icon";
|
||||
int[] buttonTypes = {
|
||||
InputEvent.BUTTON1_MASK,
|
||||
InputEvent.BUTTON2_MASK,
|
||||
InputEvent.BUTTON3_MASK
|
||||
InputEvent.BUTTON1_DOWN_MASK,
|
||||
InputEvent.BUTTON2_DOWN_MASK,
|
||||
InputEvent.BUTTON3_DOWN_MASK
|
||||
};
|
||||
String[] buttonNames = {
|
||||
"BUTTON1",
|
||||
@@ -66,20 +78,24 @@ public class TrayIconMouseTest {
|
||||
};
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (!SystemTray.isSupported()) {
|
||||
System.out.println("SystemTray not supported on the platform "
|
||||
+ "under test. Marking the test passed");
|
||||
} else {
|
||||
String osName = System.getProperty("os.name").toLowerCase();
|
||||
if (osName.startsWith("mac")) {
|
||||
isMacOS = true;
|
||||
} else if (osName.startsWith("win")) {
|
||||
isWinOS = true;
|
||||
} else {
|
||||
isOelOS = SystemTrayIconHelper.isOel7orLater();
|
||||
}
|
||||
new TrayIconMouseTest().doTest();
|
||||
if (Platform.isOnWayland()) {
|
||||
// The current robot implementation does not support
|
||||
// clicking in the system tray area.
|
||||
throw new SkippedException("Skipped on Wayland");
|
||||
}
|
||||
|
||||
if (!SystemTray.isSupported()) {
|
||||
throw new SkippedException("SystemTray is not supported on this platform.");
|
||||
}
|
||||
|
||||
if (Platform.isOSX()) {
|
||||
isMacOS = true;
|
||||
} else if (Platform.isWindows()) {
|
||||
isWinOS = true;
|
||||
} else {
|
||||
isOelOS = SystemTrayIconHelper.isOel7orLater();
|
||||
}
|
||||
new TrayIconMouseTest().doTest();
|
||||
}
|
||||
|
||||
TrayIconMouseTest() throws Exception {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -20,14 +20,15 @@
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
import jdk.test.lib.Platform;
|
||||
import jtreg.SkippedException;
|
||||
|
||||
import java.awt.TrayIcon;
|
||||
import java.awt.SystemTray;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Point;
|
||||
import java.awt.AWTException;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.image.BufferedImage;
|
||||
@@ -37,12 +38,18 @@ import java.awt.image.BufferedImage;
|
||||
* @key headful
|
||||
* @summary Check if a action performed event is received when TrayIcon display
|
||||
* message is clicked on.
|
||||
* @author Shashidhara Veerabhadraiah (shashidhara.veerabhadraiah@oracle.com)
|
||||
* @modules java.desktop/java.awt:open
|
||||
* @library /java/awt/patchlib
|
||||
* @library /lib/client ../
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build ExtendedRobot SystemTrayIconHelper
|
||||
* @library
|
||||
* /java/awt/patchlib
|
||||
* /java/awt/TrayIcon
|
||||
* /lib/client
|
||||
* /test/lib
|
||||
* @build
|
||||
* java.desktop/java.awt.Helper
|
||||
* jdk.test.lib.Platform
|
||||
* jtreg.SkippedException
|
||||
* ExtendedRobot
|
||||
* SystemTrayIconHelper
|
||||
* @run main TrayIconPopupClickTest
|
||||
*/
|
||||
|
||||
@@ -50,22 +57,29 @@ public class TrayIconPopupClickTest {
|
||||
|
||||
TrayIcon icon;
|
||||
ExtendedRobot robot;
|
||||
boolean actionPerformed = false;
|
||||
volatile boolean actionPerformed = false;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (!SystemTray.isSupported()) {
|
||||
System.out.println("SystemTray not supported on the platform under test. " +
|
||||
"Marking the test passed");
|
||||
} else {
|
||||
if (System.getProperty("os.name").toLowerCase().startsWith("win"))
|
||||
System.err.println("Test can fail if the icon hides to a tray icons pool " +
|
||||
"in Windows 7/10, which is behavior by default.\n" +
|
||||
"Set \"Right mouse click\" -> \"Customize notification icons\" -> " +
|
||||
"\"Always show all icons and notifications on the taskbar\" true " +
|
||||
"to avoid this problem. Or change behavior only for Java SE " +
|
||||
"tray icon.");
|
||||
new TrayIconPopupClickTest().doTest();
|
||||
if (Platform.isOnWayland()) {
|
||||
// The current robot implementation does not support
|
||||
// clicking in the system tray area.
|
||||
throw new SkippedException("Skipped on Wayland");
|
||||
}
|
||||
|
||||
if (!SystemTray.isSupported()) {
|
||||
throw new SkippedException("SystemTray is not supported on this platform.");
|
||||
}
|
||||
|
||||
if (Platform.isWindows()) {
|
||||
System.err.println("Test can fail if the icon hides to a tray icons pool " +
|
||||
"in Windows 7/10, which is behavior by default.\n" +
|
||||
"Set \"Right mouse click\" -> \"Customize notification icons\" -> " +
|
||||
"\"Always show all icons and notifications on the taskbar\" true " +
|
||||
"to avoid this problem. Or change behavior only for Java SE " +
|
||||
"tray icon.");
|
||||
}
|
||||
|
||||
new TrayIconPopupClickTest().doTest();
|
||||
}
|
||||
|
||||
TrayIconPopupClickTest() throws Exception {
|
||||
@@ -89,33 +103,26 @@ public class TrayIconPopupClickTest {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
icon.getActionCommand();
|
||||
icon.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
actionPerformed = true;
|
||||
}
|
||||
});
|
||||
icon.addActionListener(e -> actionPerformed = true);
|
||||
}
|
||||
|
||||
void doTest() throws Exception {
|
||||
|
||||
Point iconPosition = SystemTrayIconHelper.getTrayIconLocation(icon);
|
||||
if (iconPosition == null)
|
||||
throw new RuntimeException("Unable to find the icon location!");
|
||||
|
||||
robot.mouseMove(iconPosition.x, iconPosition.y);
|
||||
robot.waitForIdle();
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.delay(50);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.delay(50);
|
||||
|
||||
robot.mouseMove(iconPosition.x, iconPosition.y + 10);
|
||||
robot.waitForIdle();
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.delay(50);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.delay(50);
|
||||
|
||||
if (!actionPerformed)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -20,8 +20,22 @@
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
import jdk.test.lib.Platform;
|
||||
import jtreg.SkippedException;
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.Dialog;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Frame;
|
||||
import java.awt.MenuItem;
|
||||
import java.awt.Point;
|
||||
import java.awt.PopupMenu;
|
||||
import java.awt.SystemTray;
|
||||
import java.awt.TrayIcon;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
/*
|
||||
@@ -29,12 +43,18 @@ import java.awt.image.BufferedImage;
|
||||
* @key headful
|
||||
* @summary Check if a JPopupMenu can be displayed when TrayIcon is
|
||||
* right clicked. It uses a JWindow as the parent of the JPopupMenu
|
||||
* @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
|
||||
* @modules java.desktop/java.awt:open
|
||||
* @library /java/awt/patchlib
|
||||
* @library /lib/client ../
|
||||
* @build java.desktop/java.awt.Helper
|
||||
* @build ExtendedRobot SystemTrayIconHelper
|
||||
* @library
|
||||
* /java/awt/patchlib
|
||||
* /java/awt/TrayIcon
|
||||
* /lib/client
|
||||
* /test/lib
|
||||
* @build
|
||||
* java.desktop/java.awt.Helper
|
||||
* jdk.test.lib.Platform
|
||||
* jtreg.SkippedException
|
||||
* ExtendedRobot
|
||||
* SystemTrayIconHelper
|
||||
* @run main TrayIconPopupTest
|
||||
*/
|
||||
|
||||
@@ -43,27 +63,34 @@ public class TrayIconPopupTest {
|
||||
TrayIcon icon;
|
||||
ExtendedRobot robot;
|
||||
|
||||
boolean actionPerformed = false;
|
||||
Object actionLock = new Object();
|
||||
volatile boolean actionPerformed = false;
|
||||
final Object actionLock = new Object();
|
||||
|
||||
static final int ATTEMPTS = 10;
|
||||
|
||||
PopupMenu popup;
|
||||
Dialog window;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (!SystemTray.isSupported()) {
|
||||
System.out.println("SystemTray not supported on the platform under test. " +
|
||||
"Marking the test passed");
|
||||
} else {
|
||||
if (System.getProperty("os.name").toLowerCase().startsWith("win"))
|
||||
System.err.println("Test can fail if the icon hides to a tray icons pool " +
|
||||
"in Windows 7, which is behavior by default.\n" +
|
||||
"Set \"Right mouse click\" -> \"Customize notification icons\" -> " +
|
||||
"\"Always show all icons and notifications on the taskbar\" true " +
|
||||
"to avoid this problem. Or change behavior only for Java SE " +
|
||||
"tray icon.");
|
||||
new TrayIconPopupTest().doTest();
|
||||
if (Platform.isOnWayland()) {
|
||||
// The current robot implementation does not support
|
||||
// clicking in the system tray area.
|
||||
throw new SkippedException("Skipped on Wayland");
|
||||
}
|
||||
|
||||
if (!SystemTray.isSupported()) {
|
||||
throw new SkippedException("SystemTray is not supported on this platform.");
|
||||
}
|
||||
|
||||
if (Platform.isWindows()) {
|
||||
System.err.println("Test can fail if the icon hides to a tray icons pool " +
|
||||
"in Windows 7, which is behavior by default.\n" +
|
||||
"Set \"Right mouse click\" -> \"Customize notification icons\" -> " +
|
||||
"\"Always show all icons and notifications on the taskbar\" true " +
|
||||
"to avoid this problem. Or change behavior only for Java SE " +
|
||||
"tray icon.");
|
||||
}
|
||||
new TrayIconPopupTest().doTest();
|
||||
}
|
||||
|
||||
TrayIconPopupTest() throws Exception {
|
||||
@@ -128,15 +155,15 @@ public class TrayIconPopupTest {
|
||||
|
||||
robot.mouseMove(iconPosition.x, iconPosition.y);
|
||||
robot.waitForIdle();
|
||||
robot.mousePress(InputEvent.BUTTON3_MASK);
|
||||
robot.mousePress(InputEvent.BUTTON3_DOWN_MASK);
|
||||
robot.delay(50);
|
||||
robot.mouseRelease(InputEvent.BUTTON3_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON3_DOWN_MASK);
|
||||
robot.delay(6000);
|
||||
|
||||
robot.mouseMove(window.getLocation().x + 10, window.getLocation().y + 10);
|
||||
robot.mousePress(InputEvent.BUTTON3_MASK);
|
||||
robot.mousePress(InputEvent.BUTTON3_DOWN_MASK);
|
||||
robot.delay(50);
|
||||
robot.mouseRelease(InputEvent.BUTTON3_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON3_DOWN_MASK);
|
||||
|
||||
int attempts = 0;
|
||||
while (!actionPerformed && attempts++ < ATTEMPTS) {
|
||||
|
||||
Reference in New Issue
Block a user