Skip to content

Commit

Permalink
8197825: [Test] Intermittent timeout with javax/swing JColorChooser Test
Browse files Browse the repository at this point in the history
Reviewed-by: trebari, aivanov
  • Loading branch information
prsadhuk committed Feb 3, 2021
1 parent b9d4211 commit c008410
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 29 deletions.
1 change: 0 additions & 1 deletion test/jdk/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
66 changes: 38 additions & 28 deletions test/jdk/javax/swing/JColorChooser/Test6827032.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
}

1 comment on commit c008410

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.