Skip to content

Commit c008410

Browse files
committedFeb 3, 2021
8197825: [Test] Intermittent timeout with javax/swing JColorChooser Test
Reviewed-by: trebari, aivanov
1 parent b9d4211 commit c008410

File tree

2 files changed

+38
-29
lines changed

2 files changed

+38
-29
lines changed
 

‎test/jdk/ProblemList.txt

-1
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,6 @@ javax/swing/JWindow/ShapedAndTranslucentWindows/SetShapeAndClickSwing.java 80134
734734
javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentJComboBox.java 8024627 macosx-all
735735
# The next test below is an intermittent failure
736736
javax/swing/JComboBox/8033069/bug8033069ScrollBar.java 8163367 generic-all
737-
javax/swing/JColorChooser/Test6827032.java 8197825 windows-all
738737
javax/swing/JTree/DnD/LastNodeLowerHalfDrop.java 8159131 linux-all
739738
javax/swing/JTree/4633594/JTreeFocusTest.java 8173125 macosx-all
740739
javax/swing/AbstractButton/6711682/bug6711682.java 8060765 windows-all,macosx-all

‎test/jdk/javax/swing/JColorChooser/Test6827032.java

+38-28
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
/*
2525
* @test
2626
* @key headful
27-
* @bug 6827032
27+
* @bug 6827032 8197825
2828
* @summary Color chooser with drag enabled shouldn't throw NPE
2929
* @author Peter Zhelezniakov
3030
* @library ../regtesthelpers
@@ -38,47 +38,57 @@
3838

3939

4040
public class Test6827032 {
41-
4241
private static volatile Point point;
42+
private static JFrame frame;
4343
private static JColorChooser cc;
4444

4545
public static void main(String[] args) throws Exception {
46-
UIManager.setLookAndFeel(new NimbusLookAndFeel());
47-
48-
Robot robot = new Robot();
49-
robot.setAutoDelay(50);
50-
51-
52-
SwingUtilities.invokeAndWait(new Runnable() {
53-
public void run() {
54-
createAndShowGUI();
46+
try {
47+
UIManager.setLookAndFeel(new NimbusLookAndFeel());
48+
49+
Robot robot = new Robot();
50+
robot.setAutoDelay(100);
51+
52+
SwingUtilities.invokeAndWait(new Runnable() {
53+
public void run() {
54+
createAndShowGUI();
55+
}
56+
});
57+
58+
robot.waitForIdle();
59+
robot.delay(1000);
60+
61+
SwingUtilities.invokeAndWait(new Runnable() {
62+
public void run() {
63+
Component previewPanel = Util.findSubComponent(cc, "javax.swing.colorchooser.DefaultPreviewPanel");
64+
point = previewPanel.getLocationOnScreen();
65+
}
66+
});
67+
68+
point.translate(5, 5);
69+
70+
robot.mouseMove(point.x, point.y);
71+
robot.waitForIdle();
72+
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
73+
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
74+
robot.waitForIdle();
75+
robot.delay(1000);
76+
} finally {
77+
if (frame != null) {
78+
SwingUtilities.invokeAndWait(() -> frame.dispose());
5579
}
56-
});
57-
58-
robot.waitForIdle();
59-
60-
SwingUtilities.invokeAndWait(new Runnable() {
61-
public void run() {
62-
Component previewPanel = Util.findSubComponent(cc, "javax.swing.colorchooser.DefaultPreviewPanel");
63-
point = previewPanel.getLocationOnScreen();
64-
}
65-
});
66-
67-
point.translate(5, 5);
68-
69-
robot.mouseMove(point.x, point.y);
70-
robot.mousePress(InputEvent.BUTTON1_MASK);
71-
robot.mouseRelease(InputEvent.BUTTON1_MASK);
80+
}
7281
}
7382

7483

7584
private static void createAndShowGUI() {
76-
JFrame frame = new JFrame(Test6827032.class.getName());
85+
frame = new JFrame(Test6827032.class.getName());
7786
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
7887
cc = new JColorChooser();
7988
cc.setDragEnabled(true);
8089
frame.add(cc);
8190
frame.pack();
91+
frame.setLocationRelativeTo(null);
8292
frame.setVisible(true);
8393
}
8494
}

0 commit comments

Comments
 (0)
Failed to load comments.