8346154: [XWayland] Some tests fail intermittently in the CI, but not locally

Reviewed-by: serb, prr
This commit is contained in:
Alexander Zvegintsev 2025-12-22 02:36:13 +00:00
parent 25e87144c2
commit 9435d5b89c
6 changed files with 81 additions and 44 deletions

View File

@ -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();

View File

@ -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.

View File

@ -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);
}
}
}

View File

@ -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.");

View File

@ -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();

View File

@ -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();
}
}