Skip to content

Commit a0b7c4f

Browse files
committed
8346324: javax/swing/JScrollBar/4865918/bug4865918.java fails in CI
Reviewed-by: aivanov, abhiscxk
1 parent 8efc558 commit a0b7c4f

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

test/jdk/javax/swing/JScrollBar/4865918/bug4865918.java

+13-1
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,21 @@
3131

3232
import java.awt.Dimension;
3333
import java.awt.Robot;
34+
import java.awt.event.MouseAdapter;
35+
import java.awt.event.MouseEvent;
3436
import javax.swing.JFrame;
3537
import javax.swing.JScrollBar;
3638
import javax.swing.SwingUtilities;
37-
import java.awt.event.MouseEvent;
39+
import java.util.concurrent.CountDownLatch;
40+
import java.util.concurrent.TimeUnit;
3841

3942
import java.util.Date;
4043

4144
public class bug4865918 {
4245

4346
private static TestScrollBar sbar;
4447
private static JFrame frame;
48+
private static final CountDownLatch mousePressLatch = new CountDownLatch(1);
4549

4650
public static void main(String[] argv) throws Exception {
4751
try {
@@ -52,6 +56,9 @@ public static void main(String[] argv) throws Exception {
5256
robot.delay(1000);
5357

5458
SwingUtilities.invokeAndWait(() -> sbar.pressMouse());
59+
if (!mousePressLatch.await(2, TimeUnit.SECONDS)) {
60+
throw new RuntimeException("Timed out waiting for mouse press");
61+
}
5562

5663
robot.waitForIdle();
5764
robot.delay(200);
@@ -81,6 +88,11 @@ private static void createAndShowGUI() {
8188
sbar = new TestScrollBar(JScrollBar.HORIZONTAL, -1, 10, -100, 100);
8289
sbar.setPreferredSize(new Dimension(200, 20));
8390
sbar.setBlockIncrement(10);
91+
sbar.addMouseListener(new MouseAdapter() {
92+
public void mousePressed(MouseEvent e) {
93+
mousePressLatch.countDown();
94+
}
95+
});
8496

8597
frame.getContentPane().add(sbar);
8698
frame.pack();

0 commit comments

Comments
 (0)