8015886: java/awt/Focus/DeiconifiedFrameLoosesFocus/DeiconifiedFrameLoosesFocus.java sometimes failed on ubuntu

Reviewed-by: kizune, serb
This commit is contained in:
Alexander Zvegintsev 2021-07-24 08:14:05 +00:00
parent 8adf008b15
commit 049b2ad4df

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -31,7 +31,9 @@
@run main DeiconifiedFrameLoosesFocus @run main DeiconifiedFrameLoosesFocus
*/ */
import java.awt.*; import java.awt.Frame;
import java.awt.Robot;
import java.awt.Toolkit;
import test.java.awt.regtesthelpers.Util; import test.java.awt.regtesthelpers.Util;
public class DeiconifiedFrameLoosesFocus { public class DeiconifiedFrameLoosesFocus {
@ -41,7 +43,11 @@ public class DeiconifiedFrameLoosesFocus {
public static void main(String[] args) { public static void main(String[] args) {
DeiconifiedFrameLoosesFocus app = new DeiconifiedFrameLoosesFocus(); DeiconifiedFrameLoosesFocus app = new DeiconifiedFrameLoosesFocus();
app.init(); app.init();
try {
app.start(); app.start();
} finally {
frame.dispose();
}
} }
public void init() { public void init() {
@ -61,6 +67,7 @@ public class DeiconifiedFrameLoosesFocus {
frame.setVisible(true); frame.setVisible(true);
Util.waitForIdle(robot); Util.waitForIdle(robot);
robot.delay(1000);
if (!frame.isFocused()) { if (!frame.isFocused()) {
Util.clickOnTitle(frame, robot); Util.clickOnTitle(frame, robot);
@ -79,10 +86,12 @@ public class DeiconifiedFrameLoosesFocus {
frame.setExtendedState(Frame.ICONIFIED); frame.setExtendedState(Frame.ICONIFIED);
Util.waitForIdle(robot); Util.waitForIdle(robot);
robot.delay(500);
frame.setExtendedState(Frame.NORMAL); frame.setExtendedState(Frame.NORMAL);
Util.waitForIdle(robot); Util.waitForIdle(robot);
robot.delay(500);
if (!frame.isFocused()) { if (!frame.isFocused()) {
throw new TestFailedException("the Frame didn't regain focus after restoring!"); throw new TestFailedException("the Frame didn't regain focus after restoring!");