Skip to content

Commit

Permalink
8327401: Some jtreg tests fail on Wayland without any tracking bug
Browse files Browse the repository at this point in the history
8312111: open/test/jdk/java/awt/Robot/ModifierRobotKey/ModifierRobotKeyTest.java fails on ubuntu 23.04

Reviewed-by: prr
  • Loading branch information
Alexander Zvegintsev committed May 30, 2024
1 parent 579cf70 commit 286cc16
Show file tree
Hide file tree
Showing 24 changed files with 522 additions and 435 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2024, 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
Expand Down Expand Up @@ -113,6 +113,8 @@ private static void openPopup(final Choice choice) throws Exception {
robot.setAutoDelay(100);
robot.setAutoWaitForIdle(true);
robot.waitForIdle();
robot.delay(500);

Point pt = choice.getLocationOnScreen();
robot.mouseMove(pt.x + choice.getWidth() / 2,
pt.y + choice.getHeight() / 2);
Expand Down
25 changes: 18 additions & 7 deletions test/jdk/java/awt/Choice/PopupPosTest/PopupPosTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2024, 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
Expand Down Expand Up @@ -30,8 +30,18 @@
@run main PopupPosTest
*/

import java.awt.*;
import java.awt.event.*;
import java.awt.BorderLayout;
import java.awt.Choice;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Point;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.event.InputEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;

public class PopupPosTest {

Expand Down Expand Up @@ -66,6 +76,7 @@ public TestFrame() {
robot = new Robot();
robot.setAutoDelay(50);
robot.waitForIdle();
robot.delay(500);
// fix for 6175418. When we take "choice.getHeight()/2"
// divider 2 is not sufficiently big to hit into the
// small box Choice. We should use bigger divider to get
Expand Down Expand Up @@ -108,9 +119,9 @@ public void itemStateChanged(ItemEvent ie) {
public void mouseMoveAndPressOnChoice(int x, int y){
openChoice();
robot.mouseMove(x, y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.delay(30);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
robot.waitForIdle();
//should close choice after each test stage
closeChoice();
Expand All @@ -121,9 +132,9 @@ public void openChoice(){
Point pt = choice.getLocationOnScreen();
robot.mouseMove(pt.x + choice.getWidth() - choice.getHeight()/4,
pt.y + choice.getHeight()/2);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.delay(30);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
robot.waitForIdle();
}
public void closeChoice(){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2024, 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
Expand Down Expand Up @@ -79,6 +79,7 @@ public void run() {
}

waitTillShown(dialog);
robot.delay(500);
clickOn(button);
if (frame == KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow()) {
throw new RuntimeException("Test failed!");
Expand Down
10 changes: 4 additions & 6 deletions test/jdk/java/awt/Focus/RowToleranceTransitivityTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2024, 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
Expand Down Expand Up @@ -28,15 +28,14 @@
@summary Tests for a transitivity problem with ROW_TOLERANCE in SortingFTP.
@run main RowToleranceTransitivityTest
*/
import java.awt.BorderLayout;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.KeyboardFocusManager;
import java.awt.Panel;
import java.awt.Point;
import java.awt.Robot;
import java.awt.event.FocusAdapter;
Expand All @@ -49,8 +48,6 @@
import javax.swing.JLabel;
import javax.swing.JPanel;
import java.util.concurrent.atomic.AtomicBoolean;
import java.lang.reflect.InvocationTargetException;
import java.util.concurrent.atomic.AtomicBoolean;

public class RowToleranceTransitivityTest {
static JFrame frame;
Expand All @@ -60,7 +57,7 @@ public class RowToleranceTransitivityTest {
static GridBagConstraints gc;
static Robot robot;

static AtomicBoolean focusGained = new AtomicBoolean(false);
static final AtomicBoolean focusGained = new AtomicBoolean(false);

public static void main(String[] args) throws Exception {
robot = new Robot();
Expand Down Expand Up @@ -121,6 +118,7 @@ public void focusGained(FocusEvent e) {
robot.delay(1000);
test();
} finally {
robot.keyRelease(KeyEvent.VK_TAB);
if (frame != null) {
frame.dispose();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2024, 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
Expand Down Expand Up @@ -75,6 +75,7 @@ public void start ()
frame.setLocationRelativeTo(null);
frame.setVisible(true);
Util.waitForIdle(robot);
robot.delay(500);

if (!frame.isActive()) {
throw new RuntimeException("Test Fialed: frame isn't active");
Expand Down
45 changes: 27 additions & 18 deletions test/jdk/java/awt/Frame/MiscUndecorated/ActiveAWTWindowTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2024, 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
Expand Down Expand Up @@ -40,17 +40,27 @@ public class ActiveAWTWindowTest {
private Frame frame, frame2;
private Button button, button2;
private TextField textField, textField2;
private int eventType, eventType1;
private ExtendedRobot robot;
private Object lock1 = new Object();
private Object lock2 = new Object();
private Object lock3 = new Object();
private volatile int eventType;
private final Object lock1 = new Object();
private final Object lock2 = new Object();
private final Object lock3 = new Object();
private boolean passed = true;
private int delay = 150;
private final int delay = 150;

public static void main(String[] args) {
ActiveAWTWindowTest test = new ActiveAWTWindowTest();
test.doTest();
try {
test.doTest();
} finally {
EventQueue.invokeLater(() -> {
if (test.frame != null) {
test.frame.dispose();
}
if (test.frame2 != null) {
test.frame2.dispose();
}
});
}
}

public ActiveAWTWindowTest() {
Expand Down Expand Up @@ -105,7 +115,7 @@ public void windowDeactivated(WindowEvent e) {
System.out.println("Undecorated Frame got Deactivated\n");
synchronized (lock2) {
try {
lock2.notifyAll();
lock2.notifyAll();
} catch (Exception ex) {
ex.printStackTrace();
}
Expand Down Expand Up @@ -146,20 +156,22 @@ public void actionPerformed(ActionEvent e) {
}

public void doTest() {
ExtendedRobot robot;
try {
robot = new ExtendedRobot();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("Cannot create robot");
}

robot.setAutoDelay(delay);
robot.setAutoWaitForIdle(true);

robot.waitForIdle(5*delay);
robot.mouseMove(button.getLocationOnScreen().x + button.getSize().width / 2,
button.getLocationOnScreen().y + button.getSize().height / 2);
robot.waitForIdle(delay);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.waitForIdle(delay);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);

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

eventType1 = -1;
eventType = -1;

robot.mouseMove(button2.getLocationOnScreen().x + button2.getSize().width / 2,
button2.getLocationOnScreen().y + button2.getSize().height / 2);
robot.waitForIdle(delay);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.waitForIdle(delay);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);

if (eventType != WindowEvent.WINDOW_DEACTIVATED) {
synchronized (lock2) {
Expand Down
Loading

1 comment on commit 286cc16

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.