diff --git a/test/jdk/java/awt/Modal/ToFront/FrameToFrontModelessTest.java b/test/jdk/java/awt/Modal/ToFront/FrameToFrontModelessTest.java index 03ceb6e022d..00c67cc1fc6 100644 --- a/test/jdk/java/awt/Modal/ToFront/FrameToFrontModelessTest.java +++ b/test/jdk/java/awt/Modal/ToFront/FrameToFrontModelessTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -35,6 +35,9 @@ public class FrameToFrontModelessTest { private boolean isModeless; + private static final boolean IS_ON_WAYLAND = + System.getenv("WAYLAND_DISPLAY") != null; + public FrameToFrontModelessTest(boolean modeless) throws Exception { isModeless = modeless; robot = new ExtendedRobot(); @@ -76,6 +79,9 @@ public class FrameToFrontModelessTest { robot.waitForIdle(delay); // show the right frame appear on top of the dialog + if (IS_ON_WAYLAND) { + rightFrame.toFront(); + } rightFrame.clickDummyButton(robot); robot.waitForIdle(delay); diff --git a/test/jdk/java/awt/Modal/helpers/TestDialog.java b/test/jdk/java/awt/Modal/helpers/TestDialog.java index 6252fe46b7a..2ae93f835b9 100644 --- a/test/jdk/java/awt/Modal/helpers/TestDialog.java +++ b/test/jdk/java/awt/Modal/helpers/TestDialog.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -45,6 +45,9 @@ public class TestDialog extends Dialog implements ActionListener, public static int delay = 500; public static int keyDelay = 100; + private static final boolean IS_ON_WAYLAND = + System.getenv("WAYLAND_DISPLAY") != null; + public TestDialog(Frame frame) { super(frame); initializeGUI(); @@ -287,6 +290,9 @@ public class TestDialog extends Dialog implements ActionListener, String message, Button b) throws Exception { focusGained.reset(); + if (IS_ON_WAYLAND) { + toFront(); + } clickInside(robot); focusGained.waitForFlagTriggered(); assertTrue(focusGained.flag(), @@ -303,6 +309,9 @@ public class TestDialog extends Dialog implements ActionListener, String message, Button b) throws Exception { focusGained.reset(); + if (IS_ON_WAYLAND) { + toFront(); + } clickInside(robot); robot.waitForIdle(delay); diff --git a/test/jdk/java/awt/Modal/helpers/TestFrame.java b/test/jdk/java/awt/Modal/helpers/TestFrame.java index 925b216b963..dd8ed1530ef 100644 --- a/test/jdk/java/awt/Modal/helpers/TestFrame.java +++ b/test/jdk/java/awt/Modal/helpers/TestFrame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -43,6 +43,8 @@ public class TestFrame extends Frame implements ActionListener, public static int delay = 500; public static int keyDelay = 100; + private static final boolean IS_ON_WAYLAND = + System.getenv("WAYLAND_DISPLAY") != null; public TestFrame() { super(); @@ -251,7 +253,7 @@ public class TestFrame extends Frame implements ActionListener, String message) throws Exception { dummyClicked.reset(); clickButton(dummyButton, robot); - dummyClicked.waitForFlagTriggered(); + dummyClicked.waitForFlagTriggered(attempts); String msg = "Clicking the frame Dummy button " + (refState ? "did not trigger an action." : @@ -277,6 +279,9 @@ public class TestFrame extends Frame implements ActionListener, String message, Button b) throws Exception { focusGained.reset(); + if (IS_ON_WAYLAND) { + toFront(); + } clickInside(robot); focusGained.waitForFlagTriggered(); @@ -293,6 +298,9 @@ public class TestFrame extends Frame implements ActionListener, String message, Button b) throws Exception { focusGained.reset(); + if (IS_ON_WAYLAND) { + toFront(); + } clickInside(robot); robot.waitForIdle(delay);