Skip to content

Commit 603689f

Browse files
committed
8194944: Regression automated test 'open/test/jdk/javax/swing/JInternalFrame/8145896/TestJInternalFrameMaximize.java' fails
Reviewed-by: jdv, arapte
1 parent 4af2b01 commit 603689f

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

test/jdk/ProblemList.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,6 @@ javax/swing/JFileChooser/6738668/bug6738668.java 8194946 generic-all
768768
javax/swing/JFileChooser/8021253/bug8021253.java 8169954 windows-all,linux-all,macosx-all
769769
javax/swing/JFileChooser/8062561/bug8062561.java 8196466 linux-all,macosx-all
770770
javax/swing/JInternalFrame/Test6325652.java 8224977 macosx-all
771-
javax/swing/JInternalFrame/8145896/TestJInternalFrameMaximize.java 8194944 macosx-all
772771
javax/swing/JLabel/6596966/bug6596966.java 8040914 macosx-all
773772
javax/swing/JPopupMenu/4870644/bug4870644.java 8194130 macosx-all,linux-all
774773
javax/swing/JPopupMenu/4966112/bug4966112.java 8064915 macosx-all

test/jdk/javax/swing/JInternalFrame/8145896/TestJInternalFrameMaximize.java

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -24,12 +24,13 @@
2424
/*
2525
* @test
2626
* @key headful
27-
* @bug 8145896
27+
* @bug 8145896 8194944
2828
* @summary JInternalFrame setMaximum before adding to desktop throws null pointer exception
2929
* @library ../../regtesthelpers
3030
* @build Util
3131
* @run main TestJInternalFrameMaximize
3232
*/
33+
3334
import java.awt.Point;
3435
import java.awt.Robot;
3536
import java.awt.event.ActionEvent;
@@ -55,18 +56,27 @@ public class TestJInternalFrameMaximize {
5556
private static JMenuItem menuItem;
5657
private static Robot robot;
5758
private static volatile String errorMessage = "";
59+
private static volatile boolean isFrameShowing;
5860

5961
public static void main(String[] args) throws Exception {
6062
robot = new Robot();
63+
robot.setAutoDelay(100);
6164
UIManager.LookAndFeelInfo[] lookAndFeelArray
6265
= UIManager.getInstalledLookAndFeels();
6366
for (UIManager.LookAndFeelInfo lookAndFeelItem : lookAndFeelArray) {
64-
String lookAndFeelString = lookAndFeelItem.getClassName();
65-
if (tryLookAndFeel(lookAndFeelString)) {
66-
createUI();
67+
try {
68+
String lookAndFeelString = lookAndFeelItem.getClassName();
69+
if (tryLookAndFeel(lookAndFeelString)) {
70+
createUI();
71+
robot.waitForIdle();
72+
blockTillDisplayed(frame);
73+
executeTest();
74+
robot.delay(1000);
75+
}
76+
} finally {
77+
frame.dispose();
78+
isFrameShowing = false;
6779
robot.waitForIdle();
68-
executeTest();
69-
robot.delay(1000);
7080
}
7181
}
7282
if (!"".equals(errorMessage)) {
@@ -113,8 +123,6 @@ private static void createUI() throws Exception {
113123
} catch (PropertyVetoException ex) {
114124
} catch (RuntimeException ex) {
115125
errorMessage = "Test Failed";
116-
} finally {
117-
frame.dispose();
118126
}
119127
});
120128
menu.add(menuItem);
@@ -124,8 +132,21 @@ private static void createUI() throws Exception {
124132
});
125133
}
126134

127-
private static void executeTest() throws Exception {
135+
private static void blockTillDisplayed(JFrame frame) throws Exception {
136+
while (!isFrameShowing) {
137+
try {
138+
SwingUtilities.invokeAndWait(()-> isFrameShowing = frame.isShowing());
139+
if (!isFrameShowing) {
140+
Thread.sleep(1000);
141+
}
142+
} catch (InterruptedException ex) {
143+
} catch (Exception ex) {
144+
throw new RuntimeException(ex);
145+
}
146+
}
147+
}
128148

149+
private static void executeTest() throws Exception {
129150
Point point = Util.getCenterPoint(menu);
130151
performMouseOperations(point);
131152
point = Util.getCenterPoint(menuItem);

0 commit comments

Comments
 (0)