From 638708cad8228f62caf633015973403164675560 Mon Sep 17 00:00:00 2001 From: Alexander Zvegintsev Date: Fri, 22 Mar 2024 13:13:13 +0000 Subject: [PATCH] 8328697: SubMenuShowTest and SwallowKeyEvents tests stabilization Reviewed-by: kizune --- .../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 java.util.concurrent.atomic.AtomicBoolean; 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 class SubMenuShowTest { } 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.KeyAdapter; 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 class SwallowKeyEvents { }); test(); + r.waitForIdle(); + r.delay(500); System.out.println("key_pressed count: " + keyPressedCount);