# HG changeset patch # User rupashka # Date 1293117935 -10800 # Node ID 1db9d857af81b0d458fca6bf476c8b7b6fb265d4 # Parent 23c1995f9bf7b08439a45e2a3210de8ffcb9e6d0 7007708: TEST: javax/swing/JScrollBar/6542335/bug6542335.java failes agaisnt jdk7 on solaris/linux Reviewed-by: alexp diff -r 23c1995f9bf7 -r 1db9d857af81 jdk/test/javax/swing/JScrollBar/6542335/bug6542335.java --- a/jdk/test/javax/swing/JScrollBar/6542335/bug6542335.java Thu Dec 23 17:39:18 2010 +0300 +++ b/jdk/test/javax/swing/JScrollBar/6542335/bug6542335.java Thu Dec 23 18:25:35 2010 +0300 @@ -40,11 +40,13 @@ private static MyScrollBarUI ui; public static void main(String[] args) throws Exception { - Robot robot = new Robot(); + final Robot robot = new Robot(); robot.setAutoDelay(10); SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + final Rectangle[] thumbBounds = new Rectangle[1]; + SwingUtilities.invokeAndWait(new Runnable() { public void run() { final JFrame frame = new JFrame("bug6542335"); @@ -63,25 +65,39 @@ rangeModel.setValue(50); sb.setModel(rangeModel); - frame.add(sb); + frame.add(sb, BorderLayout.NORTH); frame.setSize(200, 100); frame.setVisible(true); + + thumbBounds[0] = new Rectangle(ui.getThumbBounds()); } }); - Rectangle thumbBounds = new Rectangle(ui.getThumbBounds()); + toolkit.realSync(); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + Point l = sb.getLocationOnScreen(); + + robot.mouseMove(l.x + (int) (0.75 * sb.getWidth()), l.y + sb.getHeight() / 2); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + } + }); toolkit.realSync(); - Point l = sb.getLocationOnScreen(); - robot.mouseMove(l.x + (int) (0.75 * sb.getWidth()), l.y + sb.getHeight()/2); - robot.mousePress(InputEvent.BUTTON1_MASK); - robot.mouseRelease(InputEvent.BUTTON1_MASK); - toolkit.realSync(); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + Rectangle newThumbBounds = ui.getThumbBounds(); - if (!thumbBounds.equals(ui.getThumbBounds())) { - throw new RuntimeException("Test failed"); - } + if (!thumbBounds[0].equals(newThumbBounds)) { + throw new RuntimeException("Test failed.\nOld bounds: " + thumbBounds[0] + + "\nNew bounds: " + newThumbBounds); + } + } + }); } static class MyScrollBarUI extends BasicScrollBarUI {