8194944: Regression automated test 'open/test/jdk/javax/swing/JInternalFrame/8145896/TestJInternalFrameMaximize.java' fails
Reviewed-by: jdv, arapte
--- a/test/jdk/ProblemList.txt Thu Aug 29 16:11:22 2019 +0530
+++ b/test/jdk/ProblemList.txt Wed Sep 04 22:18:48 2019 +0530
@@ -768,7 +768,6 @@
javax/swing/JFileChooser/8021253/bug8021253.java 8169954 windows-all,linux-all,macosx-all
javax/swing/JFileChooser/8062561/bug8062561.java 8196466 linux-all,macosx-all
javax/swing/JInternalFrame/Test6325652.java 8224977 macosx-all
-javax/swing/JInternalFrame/8145896/TestJInternalFrameMaximize.java 8194944 macosx-all
javax/swing/JLabel/6596966/bug6596966.java 8040914 macosx-all
javax/swing/JPopupMenu/4870644/bug4870644.java 8194130 macosx-all,linux-all
javax/swing/JPopupMenu/4966112/bug4966112.java 8064915 macosx-all
--- a/test/jdk/javax/swing/JInternalFrame/8145896/TestJInternalFrameMaximize.java Thu Aug 29 16:11:22 2019 +0530
+++ b/test/jdk/javax/swing/JInternalFrame/8145896/TestJInternalFrameMaximize.java Wed Sep 04 22:18:48 2019 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2019, 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
@@ -24,12 +24,13 @@
/*
* @test
* @key headful
- * @bug 8145896
+ * @bug 8145896 8194944
* @summary JInternalFrame setMaximum before adding to desktop throws null pointer exception
* @library ../../regtesthelpers
* @build Util
* @run main TestJInternalFrameMaximize
*/
+
import java.awt.Point;
import java.awt.Robot;
import java.awt.event.ActionEvent;
@@ -55,18 +56,27 @@
private static JMenuItem menuItem;
private static Robot robot;
private static volatile String errorMessage = "";
+ private static volatile boolean isFrameShowing;
public static void main(String[] args) throws Exception {
robot = new Robot();
+ robot.setAutoDelay(100);
UIManager.LookAndFeelInfo[] lookAndFeelArray
= UIManager.getInstalledLookAndFeels();
for (UIManager.LookAndFeelInfo lookAndFeelItem : lookAndFeelArray) {
- String lookAndFeelString = lookAndFeelItem.getClassName();
- if (tryLookAndFeel(lookAndFeelString)) {
- createUI();
+ try {
+ String lookAndFeelString = lookAndFeelItem.getClassName();
+ if (tryLookAndFeel(lookAndFeelString)) {
+ createUI();
+ robot.waitForIdle();
+ blockTillDisplayed(frame);
+ executeTest();
+ robot.delay(1000);
+ }
+ } finally {
+ frame.dispose();
+ isFrameShowing = false;
robot.waitForIdle();
- executeTest();
- robot.delay(1000);
}
}
if (!"".equals(errorMessage)) {
@@ -113,8 +123,6 @@
} catch (PropertyVetoException ex) {
} catch (RuntimeException ex) {
errorMessage = "Test Failed";
- } finally {
- frame.dispose();
}
});
menu.add(menuItem);
@@ -124,8 +132,21 @@
});
}
+ private static void blockTillDisplayed(JFrame frame) throws Exception {
+ while (!isFrameShowing) {
+ try {
+ SwingUtilities.invokeAndWait(()-> isFrameShowing = frame.isShowing());
+ if (!isFrameShowing) {
+ Thread.sleep(1000);
+ }
+ } catch (InterruptedException ex) {
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ }
+
private static void executeTest() throws Exception {
-
Point point = Util.getCenterPoint(menu);
performMouseOperations(point);
point = Util.getCenterPoint(menuItem);