public static void invokeAndWait(final Project p, final ModalityState state, @NotNull Runnable r) {
    startTestRunnable(r);
    ApplicationManager.getApplication().invokeAndWait(DisposeAwareRunnable.create(() -> runAndFinishTestRunnable(r), p), state);
  }
public static void invokeAndWait(final Project p, final ModalityState state, @NotNull Runnable r)