test/java/awt/Mouse/EnterExitEvents/DragWindowTest.java

Print this page

        

*** 36,46 **** import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.concurrent.*; - import sun.awt.SunToolkit; import test.java.awt.regtesthelpers.Util; public class DragWindowTest { --- 36,45 ----
*** 52,62 **** private static JLabel label; private static JButton button; public static void main(String[] args) throws Exception { - SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); Robot robot = new Robot(); robot.setAutoDelay(50); SwingUtilities.invokeAndWait(new Runnable() { --- 51,60 ----
*** 64,74 **** public void run() { createAndShowGUI(); } }); ! toolkit.realSync(); Point pointToClick = Util.invokeOnEDT(new Callable<Point>() { @Override public Point call() throws Exception { --- 62,72 ---- public void run() { createAndShowGUI(); } }); ! robot.waitForIdle(); Point pointToClick = Util.invokeOnEDT(new Callable<Point>() { @Override public Point call() throws Exception {
*** 77,87 **** }); robot.mouseMove(pointToClick.x, pointToClick.y); robot.mousePress(InputEvent.BUTTON1_MASK); ! toolkit.realSync(); if (dragWindowMouseEnteredCount != 1) { throw new RuntimeException("No MouseEntered event on Drag Window!"); } --- 75,85 ---- }); robot.mouseMove(pointToClick.x, pointToClick.y); robot.mousePress(InputEvent.BUTTON1_MASK); ! robot.waitForIdle(); if (dragWindowMouseEnteredCount != 1) { throw new RuntimeException("No MouseEntered event on Drag Window!"); }
*** 93,110 **** return getCenterPoint(button); } }); robot.mouseMove(pointToDrag.x, pointToDrag.y); ! toolkit.realSync(); if (buttonMouseEnteredCount != 0) { throw new RuntimeException("Extra MouseEntered event on button!"); } robot.mouseRelease(InputEvent.BUTTON1_MASK); ! toolkit.realSync(); if (labelMouseReleasedCount != 1) { throw new RuntimeException("No MouseReleased event on label!"); } --- 91,108 ---- return getCenterPoint(button); } }); robot.mouseMove(pointToDrag.x, pointToDrag.y); ! robot.waitForIdle(); if (buttonMouseEnteredCount != 0) { throw new RuntimeException("Extra MouseEntered event on button!"); } robot.mouseRelease(InputEvent.BUTTON1_MASK); ! robot.waitForIdle(); if (labelMouseReleasedCount != 1) { throw new RuntimeException("No MouseReleased event on label!"); }