Skip to content
Permalink
Browse files
8163367: Test javax/swing/JComboBox/8033069/bug8033069NoScrollBar.jav…
…a javax/swing/JComboBox/8033069/bug8033069ScrollBar.java fails intermittently

Reviewed-by: aivanov
  • Loading branch information
Pankaj Bansal committed Apr 27, 2021
1 parent 9adbf15 commit 9481fad42f7cc9d531a436fb3f1495360d643b28
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
@@ -738,7 +738,6 @@ javax/swing/JWindow/ShapedAndTranslucentWindows/PerPixelTranslucentSwing.java 81
javax/swing/JWindow/ShapedAndTranslucentWindows/SetShapeAndClickSwing.java 8013450 macosx-all
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/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
@@ -45,9 +45,8 @@
* @library ../../regtesthelpers
* @build Util
* @run main bug8033069NoScrollBar
* @author Alexey Ivanov
*/
public class bug8033069NoScrollBar implements Runnable {
public class bug8033069NoScrollBar {

private static final String[] NO_SCROLL_ITEMS = new String[] {
"A", "B", "C", "D", "E", "F"
@@ -61,6 +60,9 @@ public class bug8033069NoScrollBar implements Runnable {
private JComboBox cb1;
private JComboBox cb2;

private volatile Point p;
private volatile Dimension d;

public static void main(String[] args) throws Exception {
iterateLookAndFeels(new bug8033069NoScrollBar(NO_SCROLL_ITEMS));
}
@@ -98,24 +100,34 @@ private void setupUI() {
frame.add(panel);

frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}

private void disposeUI() {
if (frame != null) {
frame.dispose();
}
}

public void runTest() throws Exception {
try {
SwingUtilities.invokeAndWait(this);
SwingUtilities.invokeAndWait(this::setupUI);

robot.waitForIdle();
assertFalse("cb1 popup is visible",
Util.invokeOnEDT(cb1::isPopupVisible));

// Move mouse pointer to the center of the fist combo box
Point p = cb1.getLocationOnScreen();
Dimension d = cb1.getSize();
SwingUtilities.invokeAndWait(() -> {
p = cb1.getLocationOnScreen();
d = cb1.getSize();
});

robot.mouseMove(p.x + d.width / 2, p.y + d.height / 2);
// Click it to open popup
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);

robot.waitForIdle();
assertTrue("cb1 popup is not visible",
@@ -146,28 +158,24 @@ public void runTest() throws Exception {


// Move mouse pointer to the center of the second combo box
p = cb2.getLocationOnScreen();
d = cb2.getSize();
SwingUtilities.invokeAndWait(() -> {
p = cb2.getLocationOnScreen();
d = cb2.getSize();
});

robot.mouseMove(p.x + d.width / 2, p.y + d.height / 2);

robot.mouseWheel(1);
robot.waitForIdle();
assertFalse("cb1 popup is visible after mouse wheel up on cb2",
Util.invokeOnEDT(cb1::isPopupVisible));
} finally {
if (frame != null) {
frame.dispose();
}
SwingUtilities.invokeAndWait(this::disposeUI);
}

System.out.println("Test passed");
}

@Override
public void run() {
setupUI();
}

private static void assertTrue(String message, boolean value) {
assertEquals(message, true, value);
}

1 comment on commit 9481fad

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 9481fad Apr 27, 2021

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.