Skip to content

Commit 9435d5b

Browse files
author
Alexander Zvegintsev
committed
8346154: [XWayland] Some tests fail intermittently in the CI, but not locally
Reviewed-by: serb, prr
1 parent 25e8714 commit 9435d5b

File tree

6 files changed

+81
-44
lines changed

6 files changed

+81
-44
lines changed

test/jdk/java/awt/Choice/PopupPosTest/PopupPosTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2004, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -95,6 +95,8 @@ public TestFrame() {
9595
pt.y + choice.getHeight()*3/4);
9696
// testing that ItemEvent doesn't generated on a simple
9797
// mouse click when the dropdown appears under mouse : 6425067
98+
robot.waitForIdle();
99+
robot.delay(250);
98100
stateChanged = false;
99101
openChoice();
100102
closeChoice();

test/jdk/java/awt/Focus/ClearLwQueueBreakTest/ClearLwQueueBreakTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2007, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -44,7 +44,7 @@ public class ClearLwQueueBreakTest {
4444
JTextField tf1 = new JTextField(" ");
4545
JTextField tf2 = new JTextField(" ");
4646
JTextField tf3 = new JTextField(" ");
47-
AtomicBoolean typed = new AtomicBoolean(false);
47+
final AtomicBoolean typed = new AtomicBoolean(false);
4848
FocusListener listener1;
4949
FocusListener listener2;
5050

@@ -114,6 +114,7 @@ public void focusGained(FocusEvent e) {
114114
f1.setLocationRelativeTo(null);
115115
f1.setVisible(true);
116116
Util.waitForIdle(robot);
117+
robot.delay(1000);
117118

118119
/*
119120
* Break the sequence of LW requests in the middle.
Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
2424
import java.awt.Dimension;
2525
import java.awt.EventQueue;
2626
import java.awt.Frame;
27+
import java.awt.Robot;
2728

2829
/*
2930
* @test
@@ -35,57 +36,65 @@
3536

3637
public class FrameSetMinimumSizeTest {
3738
private static Frame f;
38-
private static volatile boolean passed;
39-
39+
private static Robot robot;
4040
public static void main(String[] args) throws Exception {
41-
EventQueue.invokeAndWait(() -> {
42-
try {
43-
createAndShowUI();
44-
45-
f.setSize(200, 200);
46-
passed = verifyFrameSize(new Dimension(300, 300));
47-
isFrameSizeOk(passed);
41+
robot = new Robot();
42+
try {
43+
EventQueue.invokeAndWait(FrameSetMinimumSizeTest::createAndShowUI);
44+
robot.waitForIdle();
45+
robot.delay(500);
4846

49-
f.setSize(200, 400);
50-
passed = verifyFrameSize(new Dimension(300, 400));
51-
isFrameSizeOk(passed);
47+
test(
48+
new Dimension(200, 200),
49+
new Dimension(300, 300)
50+
);
5251

53-
f.setSize(400, 200);
54-
passed = verifyFrameSize(new Dimension(400, 300));
55-
isFrameSizeOk(passed);
52+
test(
53+
new Dimension(200, 400),
54+
new Dimension(300, 400)
55+
);
5656

57-
f.setMinimumSize(null);
57+
test(
58+
new Dimension(400, 200),
59+
new Dimension(400, 300)
60+
);
5861

59-
f.setSize(200, 200);
60-
passed = verifyFrameSize(new Dimension(200, 200));
61-
isFrameSizeOk(passed);
62-
} finally {
62+
EventQueue.invokeAndWait(() -> f.setMinimumSize(null));
63+
test(
64+
new Dimension(200, 200),
65+
new Dimension(200, 200)
66+
);
67+
} finally {
68+
EventQueue.invokeAndWait(() -> {
6369
if (f != null) {
6470
f.dispose();
6571
}
66-
}
67-
});
72+
});
73+
}
74+
}
75+
76+
private static void test(Dimension size, Dimension expected) throws Exception {
77+
robot.waitForIdle();
78+
robot.delay(250);
79+
EventQueue.invokeAndWait(() -> f.setSize(size));
80+
robot.waitForIdle();
81+
EventQueue.invokeAndWait(() -> verifyFrameSize(expected));
6882
}
6983

7084
private static void createAndShowUI() {
7185
f = new Frame("Minimum Size Test");
7286
f.setSize(300, 300);
7387
f.setMinimumSize(new Dimension(300, 300));
88+
f.setLocationRelativeTo(null);
7489
f.setVisible(true);
7590
}
7691

77-
private static boolean verifyFrameSize(Dimension expected) {
78-
92+
private static void verifyFrameSize(Dimension expected) {
7993
if (f.getSize().width != expected.width || f.getSize().height != expected.height) {
80-
return false;
81-
}
82-
return true;
83-
}
84-
85-
private static void isFrameSizeOk(boolean passed) {
86-
if (!passed) {
87-
throw new RuntimeException("Frame's setMinimumSize not honoured for the" +
88-
" frame size: " + f.getSize());
94+
String message =
95+
"Frame's setMinimumSize not honoured for the frame size: %s. Expected %s"
96+
.formatted(f.getSize(), expected);
97+
throw new RuntimeException(message);
8998
}
9099
}
91100
}

test/jdk/java/awt/KeyboardFocusmanager/TypeAhead/ButtonActionKeyTest/ButtonActionKeyTest.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2006, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -31,9 +31,16 @@
3131
@run main ButtonActionKeyTest
3232
*/
3333

34-
import java.awt.*;
35-
import java.awt.event.*;
36-
import javax.swing.*;
34+
import java.awt.FlowLayout;
35+
import java.awt.Robot;
36+
import javax.swing.AbstractAction;
37+
import javax.swing.JButton;
38+
import javax.swing.JFrame;
39+
import javax.swing.JTextField;
40+
import javax.swing.KeyStroke;
41+
import java.awt.event.ActionEvent;
42+
import java.awt.event.KeyAdapter;
43+
import java.awt.event.KeyEvent;
3744
import java.util.concurrent.atomic.AtomicBoolean;
3845
import test.java.awt.regtesthelpers.Util;
3946

@@ -42,7 +49,7 @@ public class ButtonActionKeyTest {
4249
JFrame frame = new JFrame("Frame");
4350
JButton button = new JButton("button");
4451
JTextField text = new JTextField("text");
45-
AtomicBoolean gotEvent = new AtomicBoolean(false);
52+
final AtomicBoolean gotEvent = new AtomicBoolean(false);
4653

4754
public static void main(String[] args) {
4855
ButtonActionKeyTest app = new ButtonActionKeyTest();
@@ -82,9 +89,11 @@ public void keyTyped(KeyEvent e) {
8289
frame.setLocationRelativeTo(null);
8390
frame.setVisible(true);
8491
Util.waitForIdle(robot);
92+
robot.delay(1000);
8593

8694
Util.clickOnComp(button, robot);
8795
Util.waitForIdle(robot);
96+
robot.delay(500);
8897

8998
if (!button.isFocusOwner()) {
9099
throw new Error("Test error: a button didn't gain focus.");

test/jdk/java/awt/LightweightComponent/LightWeightTabFocus/LightWeightTabFocus.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -97,6 +97,7 @@ public static void main(String[] args) throws Exception {
9797
} catch (Exception e) {
9898
e.printStackTrace();
9999
} finally {
100+
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
100101
EventQueue.invokeAndWait(() -> {
101102
if (f != null) {
102103
f.dispose();

test/jdk/java/awt/Modal/ToFront/DialogToFrontModeless1Test.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2007, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -34,12 +34,27 @@
3434
* @build Flag
3535
* @build TestDialog
3636
* @build TestFrame
37+
* @build jdk.test.lib.Platform
3738
* @run main DialogToFrontModeless1Test
3839
*/
3940

41+
import jdk.test.lib.Platform;
42+
import jtreg.SkippedException;
43+
4044
public class DialogToFrontModeless1Test {
4145

4246
public static void main(String[] args) throws Exception {
47+
if (Platform.isOnWayland()) {
48+
// Some tested systems are still use XTEST(X11 protocol)
49+
// for key and mouse press emulation, but this will not work
50+
// outside of X11.
51+
// An emulated input event will reach X11 clients, but not the
52+
// Wayland compositor, which is responsible for window restacking.
53+
//
54+
// This skip can be removed later once all systems switch to
55+
// the default remote desktop XDG portal.
56+
throw new SkippedException("SKIPPED: robot functionality is limited on the current platform.");
57+
}
4358
(new DialogToFrontModelessTest()).doTest();
4459
}
4560
}

0 commit comments

Comments
 (0)