Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion 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, 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
Expand Down Expand Up @@ -95,6 +95,8 @@ public TestFrame() {
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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -114,6 +114,7 @@ public void focusGained(FocusEvent e) {
f1.setLocationRelativeTo(null);
f1.setVisible(true);
Util.waitForIdle(robot);
robot.delay(1000);

/*
* Break the sequence of LW requests in the middle.
Expand Down
77 changes: 43 additions & 34 deletions test/jdk/java/awt/Frame/FrameSetMinimumSizeTest.java
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -24,6 +24,7 @@
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Frame;
import java.awt.Robot;

/*
* @test
Expand All @@ -35,57 +36,65 @@

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

f.setSize(200, 200);
passed = verifyFrameSize(new Dimension(300, 300));
isFrameSizeOk(passed);
robot = new Robot();
try {
EventQueue.invokeAndWait(FrameSetMinimumSizeTest::createAndShowUI);
robot.waitForIdle();
robot.delay(500);

f.setSize(200, 400);
passed = verifyFrameSize(new Dimension(300, 400));
isFrameSizeOk(passed);
test(
new Dimension(200, 200),
new Dimension(300, 300)
);

f.setSize(400, 200);
passed = verifyFrameSize(new Dimension(400, 300));
isFrameSizeOk(passed);
test(
new Dimension(200, 400),
new Dimension(300, 400)
);

f.setMinimumSize(null);
test(
new Dimension(400, 200),
new Dimension(400, 300)
);

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);
}
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;

Expand All @@ -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();
Expand Down Expand Up @@ -82,9 +89,11 @@ public void keyTyped(KeyEvent e) {
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.");
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -97,6 +97,7 @@ public static void main(String[] args) throws Exception {
} catch (Exception e) {
e.printStackTrace();
} finally {
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
EventQueue.invokeAndWait(() -> {
if (f != null) {
f.dispose();
Expand Down
17 changes: 16 additions & 1 deletion test/jdk/java/awt/Modal/ToFront/DialogToFrontModeless1Test.java
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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();
}
}