Skip to content
Snippets Groups Projects
Commit 68193818 authored by Andrew Lu's avatar Andrew Lu
Browse files

8280988: [XWayland] Click on title to request focus test failures

Backport-of: f6cdcc6f65f2a436906541bb8266e69ded17e2e3
parent 15c5caa2
No related branches found
No related tags found
No related merge requests found
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 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
......@@ -27,8 +27,8 @@
* @bug 6981400
* @summary Tabbing between textfiled do not work properly when ALT+TAB
* @author anton.tarasov
* @library ../../regtesthelpers
* @build Util
* @library /java/awt/regtesthelpers /test/lib
* @build Util jdk.test.lib.Platform
* @run main Test1
*/
......@@ -41,12 +41,28 @@
// The FOCUS_LOST/FOCUS_GAINED events order in the original frame is tracked and should be:
// b0 -> b1 -> b2 -> b3.
import java.awt.*;
import java.awt.event.*;
import java.awt.AWTEvent;
import java.awt.AWTException;
import java.awt.Button;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.event.AWTEventListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.awt.event.WindowEvent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.swing.*;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import jdk.test.lib.Platform;
import test.java.awt.regtesthelpers.Util;
public class Test1 {
......@@ -72,7 +88,7 @@ public class Test1 {
static boolean tracking;
public static void main(String[] args) {
public static void main(String[] args) throws Exception {
Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
public void eventDispatched(AWTEvent e) {
System.out.println(e);
......@@ -81,6 +97,7 @@ public class Test1 {
try {
robot = new Robot();
robot.setAutoDelay(50);
} catch (AWTException ex) {
throw new RuntimeException("Error: can't create Robot");
}
......@@ -90,13 +107,13 @@ public class Test1 {
f0.add(f0b2);
f0.add(f0b3);
f0.setLayout(new FlowLayout());
f0.setBounds(0, 100, 400, 200);
f0.setBounds(100, 100, 400, 200);
f1.add(f1b0);
f1.setBounds(0, 400, 400, 200);
f1.setBounds(100, 400, 400, 200);
f2.add(f2b0);
f2.setBounds(0, 400, 400, 200);
f2.setBounds(100, 400, 400, 200);
f0b0.addFocusListener(new FocusAdapter() {
@Override
......@@ -115,6 +132,7 @@ public class Test1 {
f0.setVisible(true);
Util.waitForIdle(robot);
robot.delay(500);
if (!f0b0.isFocusOwner()) {
Util.clickOnComp(f0b0, robot);
......@@ -152,28 +170,29 @@ public class Test1 {
System.out.println("\nTest passed.");
}
public static void test(Component compToClick) {
public static void test(Component compToClick) throws Exception {
tracking = true;
robot.keyPress(KeyEvent.VK_TAB);
robot.delay(50);
robot.keyRelease(KeyEvent.VK_TAB);
robot.delay(50);
robot.waitForIdle();
robot.keyPress(KeyEvent.VK_TAB);
robot.delay(50);
robot.keyRelease(KeyEvent.VK_TAB);
robot.delay(50);
robot.waitForIdle();
robot.keyPress(KeyEvent.VK_TAB);
robot.delay(50);
robot.keyRelease(KeyEvent.VK_TAB);
robot.waitForIdle();
robot.delay(50);
Util.clickOnComp(compToClick, robot);
robot.delay(50);
robot.waitForIdle();
SwingUtilities.invokeAndWait(f0::toFront);
if (!Platform.isOnWayland()) {
Util.clickOnTitle(f0, robot);
}
Util.waitForIdle(robot);
......
/*
* Copyright (c) 2008, 2022, 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
......@@ -26,13 +26,27 @@
@key headful
@bug 6314575
@summary Tests that previosly focused owned window doesn't steal focus when an owner's component requests focus.
@library ../../regtesthelpers
@build Util
@library /java/awt/regtesthelpers /test/lib
@build Util jdk.test.lib.Platform
@run main ActualFocusedWindowBlockingTest
*/
import java.awt.*;
import java.awt.event.*;
import java.awt.AWTEvent;
import java.awt.Button;
import java.awt.Color;
import java.awt.Component;
import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.KeyboardFocusManager;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.AWTEventListener;
import java.awt.event.FocusEvent;
import java.awt.event.WindowEvent;
import jdk.test.lib.Platform;
import test.java.awt.regtesthelpers.Util;
public class ActualFocusedWindowBlockingTest {
......@@ -44,7 +58,7 @@ public class ActualFocusedWindowBlockingTest {
Button wButton = new Button("window button") {public String toString() {return "Window_Button";}};
Button aButton = new Button("auxiliary button") {public String toString() {return "Auxiliary_Button";}};
public static void main(String[] args) {
public static void main(String[] args) throws Exception {
ActualFocusedWindowBlockingTest app = new ActualFocusedWindowBlockingTest();
app.init();
app.start();
......@@ -68,7 +82,7 @@ public class ActualFocusedWindowBlockingTest {
tuneAndShowWindows(new Window[] {owner, win, frame});
}
public void start() {
public void start() throws Exception {
System.out.println("\nTest started:\n");
// Test 1.
......@@ -99,7 +113,12 @@ public class ActualFocusedWindowBlockingTest {
clickOnCheckFocus(fButton);
clickOnCheckFocus(aButton);
EventQueue.invokeAndWait(owner::toFront);
if (!Platform.isOnWayland()) {
Util.clickOnTitle(owner, robot);
}
if (!testFocused(fButton)) {
throw new TestFailedException("The owner's component [" + fButton + "] couldn't be focused as the most recent focus owner");
}
......@@ -117,11 +136,15 @@ public class ActualFocusedWindowBlockingTest {
y += 200;
Util.waitForIdle(robot);
}
robot.delay(500);
}
void clickOnCheckFocus(Component c) {
void clickOnCheckFocus(Component c) throws Exception {
if (c instanceof Frame) {
EventQueue.invokeAndWait(() -> ((Frame) c).toFront());
if (!Platform.isOnWayland()) {
Util.clickOnTitle((Frame) c, robot);
}
} else {
Util.clickOnComp(c, robot);
}
......
/*
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 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
......@@ -22,11 +22,11 @@
*/
/*
test
@test
@key headful
@bug 4531693 4636269 4681908 4688142 4691646 4721470
@summary Showing modal dialog during dispatching SequencedEvent
@key headful
@run main AutomaticAppletTest
@run main ModalDialogInFocusEventTest
*/
import java.awt.AWTEvent;
......@@ -68,6 +68,8 @@ public class ModalDialogInFocusEventTest
static final int MAX_STAGE_NUM = stages.length;
static final Object stageMonitor = new Object();
static boolean isOnWayland;
Robot robot = null;
Frame frame;
Frame oppositeFrame;
......@@ -209,6 +211,8 @@ public class ModalDialogInFocusEventTest
void clickOnFrameTitle(Frame frame) throws InterruptedException,
InvocationTargetException {
EventQueue.invokeAndWait(frame::toFront);
if (!isOnWayland) {
System.out.println("click on title of " + frame.getName());
int[] point = new int[2];
EventQueue.invokeAndWait(() -> {
......@@ -221,6 +225,7 @@ public class ModalDialogInFocusEventTest
robot.mouseMove(point[0], point[1]);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
}
EventQueue.invokeAndWait(frame::requestFocusInWindow);
}
......@@ -344,6 +349,7 @@ public class ModalDialogInFocusEventTest
public static void main(String[] args) throws InterruptedException,
InvocationTargetException {
isOnWayland = System.getenv("WAYLAND_DISPLAY") != null;
ModalDialogInFocusEventTest test = new ModalDialogInFocusEventTest();
test.start();
}
......
/*
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 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
......@@ -21,12 +21,33 @@
* questions.
*/
import java.awt.*;
import java.awt.event.*;
import java.awt.Button;
import java.awt.Checkbox;
import java.awt.Choice;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Label;
import java.awt.List;
import java.awt.Panel;
import java.awt.Robot;
import java.awt.Scrollbar;
import java.awt.TextArea;
import java.awt.TextField;
import java.awt.event.HierarchyBoundsListener;
import java.awt.event.HierarchyEvent;
import java.awt.event.InputEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException;
import javax.swing.SwingUtilities;
import java.io.*;
import jdk.test.lib.Platform;
/**
* AWT Mixing test for HierarchyBoundsListener ancestors.
......@@ -37,7 +58,8 @@ import java.io.*;
* @key headful
* @bug 6768230 8221823
* @summary Mixing test for HierarchyBoundsListener ancestors
* @build FrameBorderCounter
* @library /test/lib
* @build FrameBorderCounter jdk.test.lib.Platform
* @run main HierarchyBoundsListenerMixingTest
*/
public class HierarchyBoundsListenerMixingTest {
......@@ -137,9 +159,9 @@ public class HierarchyBoundsListenerMixingTest {
robot.mouseMove((int) components[0].getLocationOnScreen().x + components[0].getSize().width / 2,
(int) components[0].getLocationOnScreen().y + components[0].getSize().height / 2);
robot.delay(delay);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.delay(delay);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
robot.delay(delay);
resetValues();
......@@ -177,21 +199,28 @@ public class HierarchyBoundsListenerMixingTest {
robot.delay(delay * 5);
resetValues();
int x = (int) frame.getLocationOnScreen().x;
int y = (int) frame.getLocationOnScreen().y;
int w = frame.getSize().width;
int h = frame.getSize().height;
int x;
int y;
int w;
int h;
if (!Platform.isOnWayland()) {
x = frame.getLocationOnScreen().x;
y = frame.getLocationOnScreen().y;
w = frame.getSize().width;
h = frame.getSize().height;
robot.mouseMove(x + w + BORDER_SHIFT, y + h / 2);
robot.delay(delay);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.delay(delay);
for (int i = 0; i < 20; i++) {
robot.mouseMove(x + w + i + BORDER_SHIFT, y + h / 2);
robot.delay(50);
}
robot.delay(delay);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
if (!resizeTriggered) {
synchronized (resizeLock) {
......@@ -211,11 +240,13 @@ public class HierarchyBoundsListenerMixingTest {
}
}
if (moveCount > 0) {
System.err.println("FAIL: Ancestor moved event occured when Frame resized using mouse");
System.err.println("FAIL: Ancestor moved event occurred when Frame resized using mouse");
passed = false;
}
resetValues();
}
try {
EventQueue.invokeAndWait(new Runnable() {
public void run() {
......@@ -250,8 +281,10 @@ public class HierarchyBoundsListenerMixingTest {
robot.delay(delay * 10);
resetValues();
x = (int) frame.getLocationOnScreen().x;
y = (int) frame.getLocationOnScreen().y;
if (!Platform.isOnWayland()) {
x = frame.getLocationOnScreen().x;
y = frame.getLocationOnScreen().y;
w = frame.getSize().width;
h = frame.getSize().height;
......@@ -260,21 +293,21 @@ public class HierarchyBoundsListenerMixingTest {
robot.mouseMove((int) dummy.getLocationOnScreen().x + dummy.getSize().width / 2,
(int) dummy.getLocationOnScreen().y + dummy.getSize().height / 2);
robot.delay(delay);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.delay(delay);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
robot.delay(delay);
robot.mouseMove(x + w / 2, y + 10);
robot.delay(delay);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.delay(delay);
for (int i = 1; i <= 20; i++) {
robot.mouseMove(x + w / 2 + i, y + 10);
robot.delay(50);
}
robot.delay(delay);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
if (! moveTriggered) {
synchronized (moveLock) {
......@@ -296,6 +329,7 @@ public class HierarchyBoundsListenerMixingTest {
System.err.println("FAIL: Ancestor resized event occured when Frame moved using mouse");
passed = false;
}
}
return passed;
}
......@@ -450,7 +484,7 @@ public class HierarchyBoundsListenerMixingTest {
// instantiated in the same VM. Being static (and using
// static vars), it aint gonna work. Not worrying about
// it for now.
public static void main(String args[]) throws InterruptedException {
public static void main(String[] args) throws InterruptedException {
mainThread = Thread.currentThread();
try {
init();
......
/*
* Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 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
......@@ -451,4 +451,13 @@ public class Platform {
public static boolean areCustomLoadersSupportedForCDS() {
return (is64bit() && (isLinux() || isOSX()));
}
/**
* Checks if the current system is running on Wayland display server on Linux.
*
* @return {@code true} if the system is running on Wayland display server
*/
public static boolean isOnWayland() {
return System.getenv("WAYLAND_DISPLAY") != null;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment