Exemplo n.º 1
0
  private void execOffThreadWithOnThreadEventDispatch(Runnable testAction) throws Exception {
    _testMouseListener.setModifierCheckEnabled(false);
    _robot.setAutoDelay(MS_ROBOT_AUTO_DELAY);
    {
      // Make sure all the buttons and modifier keys are released.
      clearKeyboadAndMouse();
    }
    _testMouseListener.setModifierCheckEnabled(true);

    Throwable throwable = null;
    // final Object sync = new Object();
    final RunnableTask rt = new RunnableTask(testAction, null, true, System.err);
    try {
      // synchronized(sync) {
      new Thread(rt, "Test-Thread").start();
      int i = 0;
      while (!rt.isExecuted() && null == throwable) {
        System.err.println("WAIT-till-done: eventDispatch() #" + i++);
        eventDispatch();
      }
      if (null == throwable) {
        throwable = rt.getThrowable();
      }
      if (null != throwable) {
        throw new RuntimeException(throwable);
      }
      // }
    } finally {
      System.err.println("WAIT-till-done: DONE");
      _testMouseListener.setModifierCheckEnabled(false);
      clearKeyboadAndMouse();
    }
  }