On Wed, 22 May 2024 02:25:14 GMT, Alexander Zvegintsev <azveg...@openjdk.org> wrote:
> These changes are intended to stabilize testing on Wayland in X11 > compatibility mode. > > <hr> > > Many tests may fail if there is no `robot.delay()` call after > `robot.waitForIdle()` (right after displaying a window). > <hr> > > Some tests do not release previously pressed mouse button/key, this leads to > other test failures later, but it is not a problem for X11 session. > I haven't checked this, but it looks like the XWayland server does not > release the key/button emulated by XTEST when the client application > disconnects, while the regular X11 server does. > > <hr> > > For some tests it is critical to call AWT code on EDT(it prevents NPE): > java/awt/List/KeyEventsTest/KeyEventsTest.java > java/awt/Paint/ListRepaint.java > > <hr> > > Some other explanations can be found inline in the comments for a specific > test. > <hr> > > Testing is green on all platforms. test/jdk/java/awt/Focus/RowToleranceTransitivityTest.java line 121: > 119: test(); > 120: } finally { > 121: robot.keyRelease(KeyEvent.VK_TAB); Failure to release this key will result in other test failures later. test/jdk/java/awt/Frame/MiscUndecorated/RepaintTest.java line 192: > 190: // returns to normal undepressed > 191: passed = paintAndRepaint(button, (swingControl? "J": > "")+"Button"); > 192: if( !paintAndRepaint(button, (swingControl? "J": > "")+"TextField") ) { The second call to `paintAndRepaint` had the wrong component passed as a parameter, it also discards the result of the first call. test/jdk/java/awt/List/ActionEventTest/ActionEventTest.java line 74: > 72: if ((md & expectedMask) != expectedMask) { > 73: > 74: robot.keyRelease(KeyEvent.VK_CONTROL); Note that the robot has `setAutoWaitForIdle` set to `true`, so in case of failure `keyRelease` will try to call `waitForIdle` on EDT, resulting in an exception and other keys will not be released. test/jdk/java/awt/List/KeyEventsTest/KeyEventsTest.java line 53: > 51: import jdk.test.lib.Platform; > 52: > 53: public class KeyEventsTest { It is critical to call AWT code on EDT in this, otherwise it may fail with: > java.lang.NullPointerException: Cannot read field "x" because > "this.prevFocusRect" is null at java.desktop/sun.awt.X11.XListPeer$ListPainter.paintFocus(XListPeer.java:1976) at java.desktop/sun.awt.X11.XListPeer$ListPainter.paint(XListPeer.java:1799) at java.desktop/sun.awt.X11.XListPeer.repaint(XListPeer.java:389) at java.desktop/sun.awt.X11.XListPeer.scrollVertical(XListPeer.java:1469) at java.desktop/sun.awt.X11.XListPeer.makeVisible(XListPeer.java:1311) at java.desktop/java.awt.List.makeVisible(List.java:784) at KeyEventsTest.test(KeyEventsTest.java:235) at KeyEventsTest.doTest(KeyEventsTest.java:292) at KeyEventsTest.start(KeyEventsTest.java:107) at KeyEventsTest.main(KeyEventsTest.java:56) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at com.sun.javatest.regtest.agent.MainWrapper$MainTask.run(MainWrapper.java:138) at java.base/java.lang.Thread.run(Thread.java:1575) test/jdk/java/awt/Paint/ListRepaint.java line 40: > 38: static Frame frame; > 39: > 40: public static void main(final String[] args) throws Exception { It is critical to call AWT code on EDT in this, otherwise it may fail with: > java.lang.NullPointerException: Cannot read field "x" because > "this.prevFocusRect" is null at java.desktop/sun.awt.X11.XListPeer$ListPainter.paintFocus(XListPeer.java:1976) at java.desktop/sun.awt.X11.XListPeer$ListPainter.paint(XListPeer.java:1830) at java.desktop/sun.awt.X11.XListPeer.repaint(XListPeer.java:389) at java.desktop/sun.awt.X11.XListPeer.repaint(XListPeer.java:364) at java.desktop/sun.awt.X11.XListPeer.repaint(XListPeer.java:360) at java.desktop/sun.awt.X11.XListPeer.select(XListPeer.java:1214) at java.desktop/java.awt.List.select(List.java:598) at ListRepaint.test(ListRepaint.java:73) at ListRepaint.main(ListRepaint.java:51) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at com.sun.javatest.regtest.agent.MainWrapper$MainTask.run(MainWrapper.java:138) at java.base/java.lang.Thread.run(Thread.java:1575) test/jdk/java/awt/Robot/ModifierRobotKey/ModifierRobotKeyTest.java line 74: > 72: public ModifierRobotKeyTest() throws Exception { > 73: String os = System.getProperty("os.name").toLowerCase(); > 74: if (os.contains("os x") || os.contains("linux")) { Linux does not set the `Alt Graph` modifier when you press a physical `Alt Gr` key on a keyboard, and starting with Ubuntu 23.04+ it doesn't set it when that key is generated by XTEST. So remove the `ALT_GRAPH` check from the test for Linux. test/jdk/java/awt/Toolkit/DesktopProperties/rfe4758438.sh line 31: > 29: case "$OS" in > 30: Linux* ) > 31: GNOMESID=`pgrep gnome-session | head -n1` This was a hacky way to get environment variables, it may not work, depending on a system configuration. It was was implemented before the https://github.com/openjdk/jtreg/pull/152, and is no longer needed, so removed. test/jdk/java/awt/TrayIcon/TrayIconPopup/TrayIconPopupTest.java line 48: > 46: boolean actionPerformed = false; > 47: Object actionLock = new Object(); > 48: static final int ATTEMPTS = 10; Each attempt sleeps for 3 seconds, so 50 attempts is way too many and exceeds the default test timeout. test/jdk/javax/swing/JButton/bug4490179.java line 57: > 55: frame.getContentPane().add(button); > 56: button.addActionListener(e -> { > 57: if ((e.getModifiers() & InputEvent.BUTTON1_MASK) This check was lost for some reason during the open sourcing of the original test, so restored. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/19339#discussion_r1609180014 PR Review Comment: https://git.openjdk.org/jdk/pull/19339#discussion_r1609185652 PR Review Comment: https://git.openjdk.org/jdk/pull/19339#discussion_r1609188091 PR Review Comment: https://git.openjdk.org/jdk/pull/19339#discussion_r1609189736 PR Review Comment: https://git.openjdk.org/jdk/pull/19339#discussion_r1609190355 PR Review Comment: https://git.openjdk.org/jdk/pull/19339#discussion_r1609193677 PR Review Comment: https://git.openjdk.org/jdk/pull/19339#discussion_r1609196108 PR Review Comment: https://git.openjdk.org/jdk/pull/19339#discussion_r1609199982 PR Review Comment: https://git.openjdk.org/jdk/pull/19339#discussion_r1609201116