Skip to content

Commit 2c2cd9b

Browse files
author
Andrew Lu
committed
8327401: Some jtreg tests fail on Wayland without any tracking bug
8312111: open/test/jdk/java/awt/Robot/ModifierRobotKey/ModifierRobotKeyTest.java fails on ubuntu 23.04 Backport-of: 286cc163fd4f8361a633dcb6494965020d02b506
1 parent 3e638bf commit 2c2cd9b

File tree

24 files changed

+522
-435
lines changed

24 files changed

+522
-435
lines changed

test/jdk/java/awt/Choice/ChoicePopupLocation/ChoicePopupLocation.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2024, 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
@@ -113,6 +113,8 @@ private static void openPopup(final Choice choice) throws Exception {
113113
robot.setAutoDelay(100);
114114
robot.setAutoWaitForIdle(true);
115115
robot.waitForIdle();
116+
robot.delay(500);
117+
116118
Point pt = choice.getLocationOnScreen();
117119
robot.mouseMove(pt.x + choice.getWidth() / 2,
118120
pt.y + choice.getHeight() / 2);

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

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2004, 2024, 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
@@ -30,8 +30,18 @@
3030
@run main PopupPosTest
3131
*/
3232

33-
import java.awt.*;
34-
import java.awt.event.*;
33+
import java.awt.BorderLayout;
34+
import java.awt.Choice;
35+
import java.awt.Dimension;
36+
import java.awt.Font;
37+
import java.awt.Frame;
38+
import java.awt.Point;
39+
import java.awt.Robot;
40+
import java.awt.Toolkit;
41+
import java.awt.event.InputEvent;
42+
import java.awt.event.ItemEvent;
43+
import java.awt.event.ItemListener;
44+
import java.awt.event.KeyEvent;
3545

3646
public class PopupPosTest {
3747

@@ -66,6 +76,7 @@ public TestFrame() {
6676
robot = new Robot();
6777
robot.setAutoDelay(50);
6878
robot.waitForIdle();
79+
robot.delay(500);
6980
// fix for 6175418. When we take "choice.getHeight()/2"
7081
// divider 2 is not sufficiently big to hit into the
7182
// small box Choice. We should use bigger divider to get
@@ -108,9 +119,9 @@ public void itemStateChanged(ItemEvent ie) {
108119
public void mouseMoveAndPressOnChoice(int x, int y){
109120
openChoice();
110121
robot.mouseMove(x, y);
111-
robot.mousePress(InputEvent.BUTTON1_MASK);
122+
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
112123
robot.delay(30);
113-
robot.mouseRelease(InputEvent.BUTTON1_MASK);
124+
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
114125
robot.waitForIdle();
115126
//should close choice after each test stage
116127
closeChoice();
@@ -121,9 +132,9 @@ public void openChoice(){
121132
Point pt = choice.getLocationOnScreen();
122133
robot.mouseMove(pt.x + choice.getWidth() - choice.getHeight()/4,
123134
pt.y + choice.getHeight()/2);
124-
robot.mousePress(InputEvent.BUTTON1_MASK);
135+
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
125136
robot.delay(30);
126-
robot.mouseRelease(InputEvent.BUTTON1_MASK);
137+
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
127138
robot.waitForIdle();
128139
}
129140
public void closeChoice(){

test/jdk/java/awt/Focus/NonFocusableBlockedOwnerTest/NonFocusableBlockedOwnerTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2024, 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
@@ -79,6 +79,7 @@ public void run() {
7979
}
8080

8181
waitTillShown(dialog);
82+
robot.delay(500);
8283
clickOn(button);
8384
if (frame == KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow()) {
8485
throw new RuntimeException("Test failed!");

test/jdk/java/awt/Focus/RowToleranceTransitivityTest.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2024, 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
@@ -28,15 +28,14 @@
2828
@summary Tests for a transitivity problem with ROW_TOLERANCE in SortingFTP.
2929
@run main RowToleranceTransitivityTest
3030
*/
31-
import java.awt.BorderLayout;
31+
3232
import java.awt.Component;
3333
import java.awt.Dimension;
3434
import java.awt.EventQueue;
3535
import java.awt.Frame;
3636
import java.awt.GridBagConstraints;
3737
import java.awt.GridBagLayout;
3838
import java.awt.KeyboardFocusManager;
39-
import java.awt.Panel;
4039
import java.awt.Point;
4140
import java.awt.Robot;
4241
import java.awt.event.FocusAdapter;
@@ -49,8 +48,6 @@
4948
import javax.swing.JLabel;
5049
import javax.swing.JPanel;
5150
import java.util.concurrent.atomic.AtomicBoolean;
52-
import java.lang.reflect.InvocationTargetException;
53-
import java.util.concurrent.atomic.AtomicBoolean;
5451

5552
public class RowToleranceTransitivityTest {
5653
static JFrame frame;
@@ -60,7 +57,7 @@ public class RowToleranceTransitivityTest {
6057
static GridBagConstraints gc;
6158
static Robot robot;
6259

63-
static AtomicBoolean focusGained = new AtomicBoolean(false);
60+
static final AtomicBoolean focusGained = new AtomicBoolean(false);
6461

6562
public static void main(String[] args) throws Exception {
6663
robot = new Robot();
@@ -121,6 +118,7 @@ public void focusGained(FocusEvent e) {
121118
robot.delay(1000);
122119
test();
123120
} finally {
121+
robot.keyRelease(KeyEvent.VK_TAB);
124122
if (frame != null) {
125123
frame.dispose();
126124
}

test/jdk/java/awt/Focus/WrongKeyTypedConsumedTest/WrongKeyTypedConsumedTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 2024, 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
@@ -75,6 +75,7 @@ public void start ()
7575
frame.setLocationRelativeTo(null);
7676
frame.setVisible(true);
7777
Util.waitForIdle(robot);
78+
robot.delay(500);
7879

7980
if (!frame.isActive()) {
8081
throw new RuntimeException("Test Fialed: frame isn't active");

test/jdk/java/awt/Frame/MiscUndecorated/ActiveAWTWindowTest.java

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2024, 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
@@ -40,17 +40,27 @@ public class ActiveAWTWindowTest {
4040
private Frame frame, frame2;
4141
private Button button, button2;
4242
private TextField textField, textField2;
43-
private int eventType, eventType1;
44-
private ExtendedRobot robot;
45-
private Object lock1 = new Object();
46-
private Object lock2 = new Object();
47-
private Object lock3 = new Object();
43+
private volatile int eventType;
44+
private final Object lock1 = new Object();
45+
private final Object lock2 = new Object();
46+
private final Object lock3 = new Object();
4847
private boolean passed = true;
49-
private int delay = 150;
48+
private final int delay = 150;
5049

5150
public static void main(String[] args) {
5251
ActiveAWTWindowTest test = new ActiveAWTWindowTest();
53-
test.doTest();
52+
try {
53+
test.doTest();
54+
} finally {
55+
EventQueue.invokeLater(() -> {
56+
if (test.frame != null) {
57+
test.frame.dispose();
58+
}
59+
if (test.frame2 != null) {
60+
test.frame2.dispose();
61+
}
62+
});
63+
}
5464
}
5565

5666
public ActiveAWTWindowTest() {
@@ -105,7 +115,7 @@ public void windowDeactivated(WindowEvent e) {
105115
System.out.println("Undecorated Frame got Deactivated\n");
106116
synchronized (lock2) {
107117
try {
108-
lock2.notifyAll();
118+
lock2.notifyAll();
109119
} catch (Exception ex) {
110120
ex.printStackTrace();
111121
}
@@ -146,20 +156,22 @@ public void actionPerformed(ActionEvent e) {
146156
}
147157

148158
public void doTest() {
159+
ExtendedRobot robot;
149160
try {
150161
robot = new ExtendedRobot();
151162
} catch (Exception e) {
152163
e.printStackTrace();
153164
throw new RuntimeException("Cannot create robot");
154165
}
155166

167+
robot.setAutoDelay(delay);
168+
robot.setAutoWaitForIdle(true);
169+
156170
robot.waitForIdle(5*delay);
157171
robot.mouseMove(button.getLocationOnScreen().x + button.getSize().width / 2,
158172
button.getLocationOnScreen().y + button.getSize().height / 2);
159-
robot.waitForIdle(delay);
160-
robot.mousePress(InputEvent.BUTTON1_MASK);
161-
robot.waitForIdle(delay);
162-
robot.mouseRelease(InputEvent.BUTTON1_MASK);
173+
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
174+
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
163175

164176
if (eventType != WindowEvent.WINDOW_ACTIVATED) {
165177
synchronized (lock1) {
@@ -176,15 +188,12 @@ public void doTest() {
176188
"undecorated frame is activated!");
177189
}
178190

179-
eventType1 = -1;
180191
eventType = -1;
181192

182193
robot.mouseMove(button2.getLocationOnScreen().x + button2.getSize().width / 2,
183194
button2.getLocationOnScreen().y + button2.getSize().height / 2);
184-
robot.waitForIdle(delay);
185-
robot.mousePress(InputEvent.BUTTON1_MASK);
186-
robot.waitForIdle(delay);
187-
robot.mouseRelease(InputEvent.BUTTON1_MASK);
195+
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
196+
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
188197

189198
if (eventType != WindowEvent.WINDOW_DEACTIVATED) {
190199
synchronized (lock2) {

0 commit comments

Comments
 (0)