Skip to content

Commit 7597cba

Browse files
committed
8143021: [TEST_BUG] Test javax/swing/JColorChooser/Test6541987.java fails
Reviewed-by: serb
1 parent 80380d5 commit 7597cba

File tree

2 files changed

+28
-19
lines changed

2 files changed

+28
-19
lines changed

test/jdk/ProblemList.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,6 @@ javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentJComboBox.java 802462
741741
# The next test below is an intermittent failure
742742
javax/swing/JComboBox/8033069/bug8033069ScrollBar.java 8163367 generic-all
743743
javax/swing/JColorChooser/Test6827032.java 8197825 windows-all
744-
javax/swing/JColorChooser/Test6541987.java 8143021 windows-all,linux-all,macosx-all
745744
javax/swing/JTable/4235420/bug4235420.java 8079127 generic-all
746745
javax/swing/JSplitPane/4201995/bug4201995.java 8079127 generic-all
747746
javax/swing/JTree/DnD/LastNodeLowerHalfDrop.java 8159131 linux-all

test/jdk/javax/swing/JColorChooser/Test6541987.java

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,33 @@
4242

4343
public class Test6541987 implements Runnable {
4444
private static Robot robot;
45+
private static JFrame frame;
4546

46-
public static void main(String[] args) throws AWTException {
47-
robot = new Robot();
48-
// test escape after selection
49-
start();
50-
click(KeyEvent.VK_ESCAPE);
51-
robot.waitForIdle();
52-
// test double escape after editing
53-
start();
54-
click(KeyEvent.VK_1);
55-
click(KeyEvent.VK_0);
56-
click(KeyEvent.VK_ESCAPE);
57-
click(KeyEvent.VK_ESCAPE);
58-
robot.waitForIdle();
59-
// all windows should be closed
60-
for (Window window : Window.getWindows()) {
61-
if (window.isVisible()) {
62-
throw new Error("found visible window: " + window.getName());
47+
public static void main(String[] args) throws Exception {
48+
try {
49+
robot = new Robot();
50+
robot.setAutoDelay(100);
51+
// test escape after selection
52+
start();
53+
click(KeyEvent.VK_ESCAPE);
54+
robot.waitForIdle();
55+
// test double escape after editing
56+
start();
57+
click(KeyEvent.VK_1);
58+
click(KeyEvent.VK_0);
59+
click(KeyEvent.VK_ESCAPE);
60+
click(KeyEvent.VK_ESCAPE);
61+
robot.waitForIdle();
62+
robot.delay(500);
63+
// all windows should be closed
64+
for (Window window : Window.getWindows()) {
65+
if (window.isVisible()) {
66+
throw new Error("found visible window: " + window.getName());
67+
}
68+
}
69+
} finally {
70+
if (frame != null) {
71+
SwingUtilities.invokeAndWait(frame::dispose);
6372
}
6473
}
6574
}
@@ -85,7 +94,8 @@ private static void click(int...keys) {
8594

8695
public void run() {
8796
String title = getClass().getName();
88-
JFrame frame = new JFrame(title);
97+
frame = new JFrame(title);
98+
frame.setLocationRelativeTo(null);
8999
frame.setVisible(true);
90100

91101
Color color = JColorChooser.showDialog(frame, title, Color.BLACK);

0 commit comments

Comments
 (0)