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."

Backport-of: 3f2e849c54c2a9c55e3b5c9f5a6d3478b83144e3
  • Loading branch information
Andrew Lu committed Jun 12, 2024
1 parent 8cfc0ef commit 150e228
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 @@ -673,7 +673,6 @@ java/awt/image/multiresolution/MultiResolutionJOptionPaneIconTest.java 8274106 m
javax/swing/JFrame/8175301/ScaledFrameBackgroundTest.java 8274106 macosx-aarch64

java/awt/Mouse/EnterExitEvents/DragWindowTest.java 8298823 macosx-all
java/awt/Focus/NonFocusableWindowTest/NonfocusableOwnerTest.java 8280392 windows-x64
java/awt/Mixing/AWT_Mixing/OpaqueOverlapping.java 8294264 windows-x64
java/awt/Mixing/AWT_Mixing/ViewportOverlapping.java 8253184,8295813 windows-x64

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 150e228

@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.