From 73d6539e660ec35f54359a17f08a3131a65bc9b2 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 20 Nov 2024 10:06:39 +0000 Subject: [PATCH] 8328697: SubMenuShowTest and SwallowKeyEvents tests stabilization Backport-of: 638708cad8228f62caf633015973403164675560 --- .../SubMenuShowTest/SubMenuShowTest.java | 28 ++++++++-------- .../SwallowKeyEvents/SwallowKeyEvents.java | 32 ++++++++++--------- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/test/jdk/java/awt/KeyboardFocusmanager/TypeAhead/SubMenuShowTest/SubMenuShowTest.java b/test/jdk/java/awt/KeyboardFocusmanager/TypeAhead/SubMenuShowTest/SubMenuShowTest.java index b1429d92e9e..baf70c16e6e 100644 --- a/test/jdk/java/awt/KeyboardFocusmanager/TypeAhead/SubMenuShowTest/SubMenuShowTest.java +++ b/test/jdk/java/awt/KeyboardFocusmanager/TypeAhead/SubMenuShowTest/SubMenuShowTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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,19 +21,6 @@ * questions. */ -/* - @test - @key headful - @bug 6380743 8158380 8198624 - @summary Submenu should be shown by mnemonic key press. - @author anton.tarasov@...: area=awt.focus - @library ../../../regtesthelpers - @library /test/lib - @build Util - @build jdk.test.lib.Platform - @run main SubMenuShowTest -*/ - import java.awt.Robot; import java.awt.BorderLayout; import java.awt.event.KeyEvent; @@ -48,6 +35,17 @@ import jdk.test.lib.Platform; import test.java.awt.regtesthelpers.Util; +/* + @test + @key headful + @bug 6380743 8158380 8198624 + @summary Submenu should be shown by mnemonic key press. + @library /java/awt/regtesthelpers + @library /test/lib + @build Util + @build jdk.test.lib.Platform + @run main SubMenuShowTest +*/ public class SubMenuShowTest { private static Robot robot; private static JFrame frame; @@ -116,6 +114,8 @@ public void actionPerformed(ActionEvent e) { } public static void doTest() { + robot.waitForIdle(); + robot.delay(1000); boolean isMacOSX = Platform.isOSX(); if (isMacOSX) { robot.keyPress(KeyEvent.VK_CONTROL); diff --git a/test/jdk/java/awt/event/KeyEvent/SwallowKeyEvents/SwallowKeyEvents.java b/test/jdk/java/awt/event/KeyEvent/SwallowKeyEvents/SwallowKeyEvents.java index 421d8fe2faf..58a72aa8767 100644 --- a/test/jdk/java/awt/event/KeyEvent/SwallowKeyEvents/SwallowKeyEvents.java +++ b/test/jdk/java/awt/event/KeyEvent/SwallowKeyEvents/SwallowKeyEvents.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018, 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 @@ -21,20 +21,6 @@ * questions. */ -/* - @test - @key headful - @bug 7154072 7161320 - @summary Tests that key events with modifiers are not swallowed. - @author anton.tarasov: area=awt.focus - @library ../../../regtesthelpers - @library /test/lib - @modules java.desktop/sun.awt - @build jdk.test.lib.Platform - @build Util - @run main SwallowKeyEvents -*/ - import jdk.test.lib.Platform; import java.awt.AWTException; import java.awt.Frame; @@ -44,6 +30,20 @@ import java.awt.event.KeyEvent; import test.java.awt.regtesthelpers.Util; +/* + @test + @key headful + @bug 7154072 7161320 + @summary Tests that key events with modifiers are not swallowed. + @requires (os.family != "windows") + @library /java/awt/regtesthelpers + @library /test/lib + @modules java.desktop/sun.awt + @build jdk.test.lib.Platform + @build Util + @run main SwallowKeyEvents +*/ + public class SwallowKeyEvents { static final int PRESS_COUNT = 10; @@ -83,6 +83,8 @@ public void keyPressed(KeyEvent ke) { }); test(); + r.waitForIdle(); + r.delay(500); System.out.println("key_pressed count: " + keyPressedCount);