@Deprecated
  @TestOnly
  public static void dispatchPendingFlushes() {
    if (!SwingUtilities.isEventDispatchThread()) throw new IllegalStateException("Must call from EDT");

    Semaphore semaphore = new Semaphore();
    semaphore.down();
    invokeLater(ModalityState.any(), Conditions.alwaysFalse(), semaphore::up);
    while (!semaphore.isUp()) {
      EDT.dispatchAllInvocationEvents();
    }
  }
@Deprecated
  @TestOnly
  public static void dispatchPendingFlushes()