Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8163367: Test javax/swing/JComboBox/8033069/bug8033069NoScrollBar.java javax/swing/JComboBox/8033069/bug8033069ScrollBar.java fails intermittently #3678

Closed
wants to merge 4 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -734,7 +734,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 Point p;
private Dimension d;
Copy link
Member

@aivanov-jdk aivanov-jdk Apr 26, 2021

Choose a reason for hiding this comment

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

Both should be volatile as they're accessed from two different threads.


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

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

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.waitForIdle();
Copy link
Member

@aivanov-jdk aivanov-jdk Apr 26, 2021

Choose a reason for hiding this comment

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

Is it needed here?
The block above does not modify the state of the UI.


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

@aivanov-jdk aivanov-jdk Apr 26, 2021

Choose a reason for hiding this comment

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

I believe the delay between mouseMove and mousePress/Release is unneeded, does it really make a difference?


// 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",
@@ -133,6 +142,7 @@ public void runTest() throws Exception {

// Move mouse down on the popup
robot.mouseMove(p.x + d.width / 2, p.y + d.height * 3);
robot.waitForIdle();

robot.mouseWheel(1);
robot.waitForIdle();
@@ -146,28 +156,28 @@ 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.waitForIdle();

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

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(frame::dispose);
}
Copy link
Member

@aivanov-jdk aivanov-jdk Apr 26, 2021

Choose a reason for hiding this comment

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

The frame is still accessed from two different threads.

}

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

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

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