Skip to content

Commit

Permalink
8280392: java/awt/Focus/NonFocusableWindowTest/NonfocusableOwnerTest.…
Browse files Browse the repository at this point in the history
…java failed with "RuntimeException: Test failed."

Reviewed-by: tr, aivanov, prr
  • Loading branch information
Alisen Chung committed Mar 18, 2024
1 parent c901da4 commit 3f2e849
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
1 change: 0 additions & 1 deletion test/jdk/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand All @@ -55,7 +64,7 @@ public void eventDispatched(AWTEvent e) {
}
}, 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");
Expand Down Expand Up @@ -92,9 +101,11 @@ void test1(Window owner, Window child) {

owner.setFocusableWindowState(false);
owner.setVisible(true);
robot.waitForIdle();

child.add(button);
child.setVisible(true);
robot.waitForIdle();

Util.waitTillShown(child);

Expand All @@ -111,12 +122,15 @@ void test2(Window owner, Window child1, Window child2) {

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

Expand All @@ -134,13 +148,16 @@ void test3(Window owner, Window child1, Window child2) {

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

Expand Down

1 comment on commit 3f2e849

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.