From 9435d5b89ca08595f0f2f8d029c00bc6d1f30104 Mon Sep 17 00:00:00 2001 From: Alexander Zvegintsev Date: Mon, 22 Dec 2025 02:36:13 +0000 Subject: [PATCH] 8346154: [XWayland] Some tests fail intermittently in the CI, but not locally Reviewed-by: serb, prr --- .../awt/Choice/PopupPosTest/PopupPosTest.java | 4 +- .../ClearLwQueueBreakTest.java | 5 +- .../awt/Frame/FrameSetMinimumSizeTest.java | 77 +++++++++++-------- .../ButtonActionKeyTest.java | 19 +++-- .../LightWeightTabFocus.java | 3 +- .../ToFront/DialogToFrontModeless1Test.java | 17 +++- 6 files changed, 81 insertions(+), 44 deletions(-) diff --git a/test/jdk/java/awt/Choice/PopupPosTest/PopupPosTest.java b/test/jdk/java/awt/Choice/PopupPosTest/PopupPosTest.java index b7a5cdea072..220ddbd930c 100644 --- a/test/jdk/java/awt/Choice/PopupPosTest/PopupPosTest.java +++ b/test/jdk/java/awt/Choice/PopupPosTest/PopupPosTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -95,6 +95,8 @@ class TestFrame extends Frame implements ItemListener { pt.y + choice.getHeight()*3/4); // testing that ItemEvent doesn't generated on a simple // mouse click when the dropdown appears under mouse : 6425067 + robot.waitForIdle(); + robot.delay(250); stateChanged = false; openChoice(); closeChoice(); diff --git a/test/jdk/java/awt/Focus/ClearLwQueueBreakTest/ClearLwQueueBreakTest.java b/test/jdk/java/awt/Focus/ClearLwQueueBreakTest/ClearLwQueueBreakTest.java index 5d1012bd22b..13b8a1de511 100644 --- a/test/jdk/java/awt/Focus/ClearLwQueueBreakTest/ClearLwQueueBreakTest.java +++ b/test/jdk/java/awt/Focus/ClearLwQueueBreakTest/ClearLwQueueBreakTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, 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 @@ -44,7 +44,7 @@ public class ClearLwQueueBreakTest { JTextField tf1 = new JTextField(" "); JTextField tf2 = new JTextField(" "); JTextField tf3 = new JTextField(" "); - AtomicBoolean typed = new AtomicBoolean(false); + final AtomicBoolean typed = new AtomicBoolean(false); FocusListener listener1; FocusListener listener2; @@ -114,6 +114,7 @@ public class ClearLwQueueBreakTest { f1.setLocationRelativeTo(null); f1.setVisible(true); Util.waitForIdle(robot); + robot.delay(1000); /* * Break the sequence of LW requests in the middle. diff --git a/test/jdk/java/awt/Frame/FrameSetMinimumSizeTest.java b/test/jdk/java/awt/Frame/FrameSetMinimumSizeTest.java index 929a36e773e..ff95fd51401 100644 --- a/test/jdk/java/awt/Frame/FrameSetMinimumSizeTest.java +++ b/test/jdk/java/awt/Frame/FrameSetMinimumSizeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -24,6 +24,7 @@ import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Frame; +import java.awt.Robot; /* * @test @@ -35,57 +36,65 @@ import java.awt.Frame; public class FrameSetMinimumSizeTest { private static Frame f; - private static volatile boolean passed; - + private static Robot robot; public static void main(String[] args) throws Exception { - EventQueue.invokeAndWait(() -> { - try { - createAndShowUI(); + robot = new Robot(); + try { + EventQueue.invokeAndWait(FrameSetMinimumSizeTest::createAndShowUI); + robot.waitForIdle(); + robot.delay(500); - f.setSize(200, 200); - passed = verifyFrameSize(new Dimension(300, 300)); - isFrameSizeOk(passed); + test( + new Dimension(200, 200), + new Dimension(300, 300) + ); - f.setSize(200, 400); - passed = verifyFrameSize(new Dimension(300, 400)); - isFrameSizeOk(passed); + test( + new Dimension(200, 400), + new Dimension(300, 400) + ); - f.setSize(400, 200); - passed = verifyFrameSize(new Dimension(400, 300)); - isFrameSizeOk(passed); + test( + new Dimension(400, 200), + new Dimension(400, 300) + ); - f.setMinimumSize(null); - - f.setSize(200, 200); - passed = verifyFrameSize(new Dimension(200, 200)); - isFrameSizeOk(passed); - } finally { + EventQueue.invokeAndWait(() -> f.setMinimumSize(null)); + test( + new Dimension(200, 200), + new Dimension(200, 200) + ); + } finally { + EventQueue.invokeAndWait(() -> { if (f != null) { f.dispose(); } - } - }); + }); + } + } + + private static void test(Dimension size, Dimension expected) throws Exception { + robot.waitForIdle(); + robot.delay(250); + EventQueue.invokeAndWait(() -> f.setSize(size)); + robot.waitForIdle(); + EventQueue.invokeAndWait(() -> verifyFrameSize(expected)); } private static void createAndShowUI() { f = new Frame("Minimum Size Test"); f.setSize(300, 300); f.setMinimumSize(new Dimension(300, 300)); + f.setLocationRelativeTo(null); f.setVisible(true); } - private static boolean verifyFrameSize(Dimension expected) { - + private static void verifyFrameSize(Dimension expected) { if (f.getSize().width != expected.width || f.getSize().height != expected.height) { - return false; - } - return true; - } - - private static void isFrameSizeOk(boolean passed) { - if (!passed) { - throw new RuntimeException("Frame's setMinimumSize not honoured for the" + - " frame size: " + f.getSize()); + String message = + "Frame's setMinimumSize not honoured for the frame size: %s. Expected %s" + .formatted(f.getSize(), expected); + throw new RuntimeException(message); } } } diff --git a/test/jdk/java/awt/KeyboardFocusmanager/TypeAhead/ButtonActionKeyTest/ButtonActionKeyTest.java b/test/jdk/java/awt/KeyboardFocusmanager/TypeAhead/ButtonActionKeyTest/ButtonActionKeyTest.java index 7f9a07878f1..52b7eeccd12 100644 --- a/test/jdk/java/awt/KeyboardFocusmanager/TypeAhead/ButtonActionKeyTest/ButtonActionKeyTest.java +++ b/test/jdk/java/awt/KeyboardFocusmanager/TypeAhead/ButtonActionKeyTest/ButtonActionKeyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -31,9 +31,16 @@ @run main ButtonActionKeyTest */ -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; +import java.awt.FlowLayout; +import java.awt.Robot; +import javax.swing.AbstractAction; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JTextField; +import javax.swing.KeyStroke; +import java.awt.event.ActionEvent; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; import java.util.concurrent.atomic.AtomicBoolean; import test.java.awt.regtesthelpers.Util; @@ -42,7 +49,7 @@ public class ButtonActionKeyTest { JFrame frame = new JFrame("Frame"); JButton button = new JButton("button"); JTextField text = new JTextField("text"); - AtomicBoolean gotEvent = new AtomicBoolean(false); + final AtomicBoolean gotEvent = new AtomicBoolean(false); public static void main(String[] args) { ButtonActionKeyTest app = new ButtonActionKeyTest(); @@ -82,9 +89,11 @@ public class ButtonActionKeyTest { frame.setLocationRelativeTo(null); frame.setVisible(true); Util.waitForIdle(robot); + robot.delay(1000); Util.clickOnComp(button, robot); Util.waitForIdle(robot); + robot.delay(500); if (!button.isFocusOwner()) { throw new Error("Test error: a button didn't gain focus."); diff --git a/test/jdk/java/awt/LightweightComponent/LightWeightTabFocus/LightWeightTabFocus.java b/test/jdk/java/awt/LightweightComponent/LightWeightTabFocus/LightWeightTabFocus.java index 05889580fd4..2d0b742c319 100644 --- a/test/jdk/java/awt/LightweightComponent/LightWeightTabFocus/LightWeightTabFocus.java +++ b/test/jdk/java/awt/LightweightComponent/LightWeightTabFocus/LightWeightTabFocus.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -97,6 +97,7 @@ public class LightWeightTabFocus { } catch (Exception e) { e.printStackTrace(); } finally { + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); EventQueue.invokeAndWait(() -> { if (f != null) { f.dispose(); diff --git a/test/jdk/java/awt/Modal/ToFront/DialogToFrontModeless1Test.java b/test/jdk/java/awt/Modal/ToFront/DialogToFrontModeless1Test.java index 4faea19db2f..928bfd027ea 100644 --- a/test/jdk/java/awt/Modal/ToFront/DialogToFrontModeless1Test.java +++ b/test/jdk/java/awt/Modal/ToFront/DialogToFrontModeless1Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, 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 @@ -34,12 +34,27 @@ * @build Flag * @build TestDialog * @build TestFrame + * @build jdk.test.lib.Platform * @run main DialogToFrontModeless1Test */ +import jdk.test.lib.Platform; +import jtreg.SkippedException; + public class DialogToFrontModeless1Test { public static void main(String[] args) throws Exception { + if (Platform.isOnWayland()) { + // Some tested systems are still use XTEST(X11 protocol) + // for key and mouse press emulation, but this will not work + // outside of X11. + // An emulated input event will reach X11 clients, but not the + // Wayland compositor, which is responsible for window restacking. + // + // This skip can be removed later once all systems switch to + // the default remote desktop XDG portal. + throw new SkippedException("SKIPPED: robot functionality is limited on the current platform."); + } (new DialogToFrontModelessTest()).doTest(); } }