8280392: java/awt/Focus/NonFocusableWindowTest/NonfocusableOwnerTest.java failed with "RuntimeException: Test failed."

Reviewed-by: tr, aivanov, prr
This commit is contained in:
Alisen Chung 2024-03-18 19:57:24 +00:00
parent c901da48e3
commit 3f2e849c54
2 changed files with 31 additions and 15 deletions
test/jdk
ProblemList.txt
java/awt/Focus/NonFocusableWindowTest

@ -131,7 +131,6 @@ java/awt/Focus/ClearLwQueueBreakTest/ClearLwQueueBreakTest.java 8198618 macosx-a
java/awt/Focus/ConsumeNextKeyTypedOnModalShowTest/ConsumeNextKeyTypedOnModalShowTest.java 6986252 macosx-all
java/awt/Focus/MouseClickRequestFocusRaceTest/MouseClickRequestFocusRaceTest.java 8194753 linux-all,macosx-all
java/awt/Focus/NoAutotransferToDisabledCompTest/NoAutotransferToDisabledCompTest.java 7152980 macosx-all
java/awt/Focus/NonFocusableWindowTest/NonfocusableOwnerTest.java 8280392 windows-x64
java/awt/Focus/ToFrontFocusTest/ToFrontFocus.java 7156130 linux-all
java/awt/Focus/WrongKeyTypedConsumedTest/WrongKeyTypedConsumedTest.java 8169096 macosx-all
java/awt/EventQueue/6980209/bug6980209.java 8198615 macosx-all

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2018, 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
@ -21,20 +21,29 @@
* questions.
*/
/*
@test
@key headful
@bug 6182359
@summary Tests that Window having non-focusable owner can't be a focus owner.
@library ../../regtesthelpers
@build Util
@run main NonfocusableOwnerTest
*/
import java.awt.*;
import java.awt.event.*;
import test.java.awt.regtesthelpers.Util;
import java.awt.AWTEvent;
import java.awt.Button;
import java.awt.Dialog;
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;
/*
( @test
* @key headful
* @bug 6182359
* @summary Tests that Window having non-focusable owner can't be a focus owner.
* @library ../../regtesthelpers
* @build Util
* @run main NonfocusableOwnerTest
*/
public class NonfocusableOwnerTest {
Robot robot = Util.createRobot();
Frame frame;
@ -55,7 +64,7 @@ public class NonfocusableOwnerTest {
}
}, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_FOCUS_EVENT_MASK | WindowEvent.WINDOW_EVENT_MASK);
frame = new Frame("Frame");
frame = new Frame("NonfocusableOwnerTest");
frame.setName("Frame-owner");
frame.setBounds(100, 0, 100, 100);
dialog = new Dialog(frame, "Dialog");
@ -92,9 +101,11 @@ public class NonfocusableOwnerTest {
owner.setFocusableWindowState(false);
owner.setVisible(true);
robot.waitForIdle();
child.add(button);
child.setVisible(true);
robot.waitForIdle();
Util.waitTillShown(child);
@ -111,12 +122,15 @@ public class NonfocusableOwnerTest {
owner.setFocusableWindowState(false);
owner.setVisible(true);
robot.waitForIdle();
child1.setFocusableWindowState(true);
child1.setVisible(true);
robot.waitForIdle();
child2.add(button);
child2.setVisible(true);
robot.waitForIdle();
Util.waitTillShown(child2);
@ -134,13 +148,16 @@ public class NonfocusableOwnerTest {
owner.setFocusableWindowState(true);
owner.setVisible(true);
robot.waitForIdle();
child1.setFocusableWindowState(false);
child1.setVisible(true);
robot.waitForIdle();
child2.setFocusableWindowState(true);
child2.add(button);
child2.setVisible(true);
robot.waitForIdle();
Util.waitTillShown(child2);