Skip to content
Permalink
Browse files
8197825: [Test] Intermittent timeout with javax/swing JColorChooser Test
Reviewed-by: trebari, aivanov
  • Loading branch information
prsadhuk committed Feb 3, 2021
1 parent b9d4211 commit c0084100bc335676a277881f99e138a4abfc5362
Showing with 38 additions and 29 deletions.
  1. +0 −1 test/jdk/ProblemList.txt
  2. +38 −28 test/jdk/javax/swing/JColorChooser/Test6827032.java
@@ -734,7 +734,6 @@ javax/swing/JWindow/ShapedAndTranslucentWindows/SetShapeAndClickSwing.java 80134
javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentJComboBox.java 8024627 macosx-all
# The next test below is an intermittent failure
javax/swing/JComboBox/8033069/bug8033069ScrollBar.java 8163367 generic-all
javax/swing/JColorChooser/Test6827032.java 8197825 windows-all
javax/swing/JTree/DnD/LastNodeLowerHalfDrop.java 8159131 linux-all
javax/swing/JTree/4633594/JTreeFocusTest.java 8173125 macosx-all
javax/swing/AbstractButton/6711682/bug6711682.java 8060765 windows-all,macosx-all
@@ -24,7 +24,7 @@
/*
* @test
* @key headful
* @bug 6827032
* @bug 6827032 8197825
* @summary Color chooser with drag enabled shouldn't throw NPE
* @author Peter Zhelezniakov
* @library ../regtesthelpers
@@ -38,47 +38,57 @@


public class Test6827032 {

private static volatile Point point;
private static JFrame frame;
private static JColorChooser cc;

public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new NimbusLookAndFeel());

Robot robot = new Robot();
robot.setAutoDelay(50);


SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
try {
UIManager.setLookAndFeel(new NimbusLookAndFeel());

Robot robot = new Robot();
robot.setAutoDelay(100);

SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
}
});

robot.waitForIdle();
robot.delay(1000);

SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
Component previewPanel = Util.findSubComponent(cc, "javax.swing.colorchooser.DefaultPreviewPanel");
point = previewPanel.getLocationOnScreen();
}
});

point.translate(5, 5);

robot.mouseMove(point.x, point.y);
robot.waitForIdle();
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
robot.waitForIdle();
robot.delay(1000);
} finally {
if (frame != null) {
SwingUtilities.invokeAndWait(() -> frame.dispose());
}
});

robot.waitForIdle();

SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
Component previewPanel = Util.findSubComponent(cc, "javax.swing.colorchooser.DefaultPreviewPanel");
point = previewPanel.getLocationOnScreen();
}
});

point.translate(5, 5);

robot.mouseMove(point.x, point.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
}


private static void createAndShowGUI() {
JFrame frame = new JFrame(Test6827032.class.getName());
frame = new JFrame(Test6827032.class.getName());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
cc = new JColorChooser();
cc.setDragEnabled(true);
frame.add(cc);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}

0 comments on commit c008410

Please sign in to comment.