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
Changes from 2 commits
f6804d5
b726d76
5cb0661
0fb3589
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
@@ -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; | ||
|
||
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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it needed here? |
||
|
||
robot.mouseMove(p.x + d.width / 2, p.y + d.height / 2); | ||
robot.waitForIdle(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
} | ||
There was a problem hiding this comment.
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.