public void doTest() throws Exception {

    try {
      dialog.activated.waitForFlagTriggered();
      assertTrue(
          dialog.activated.flag(),
          "Dialog did not trigger " + "Window Activated event when it became visible");

      dialog.closeGained.waitForFlagTriggered();
      assertTrue(
          dialog.closeGained.flag(),
          "the 1st Dialog button " + "did not gain focus when it became visible");

      assertTrue(
          dialog.closeButton.hasFocus(),
          "the 1st Dialog button " + "gained the focus but lost it afterwards");

      dialog.checkUnblockedDialog(robot, "Modal Dialog shouldn't be blocked.");

      if ((modalityType == Dialog.ModalityType.APPLICATION_MODAL)
          || (modalityType == Dialog.ModalityType.DOCUMENT_MODAL)
          || (modalityType == Dialog.ModalityType.TOOLKIT_MODAL)
          || dialog.isModal()) {
        parent.checkBlockedDialog(
            robot, "Dialog is the parent of a visible " + modalityType + " Dialog.");
      } else {
        parent.checkUnblockedDialog(
            robot, "Dialog is the parent of a visible " + modalityType + " Dialog.");
      }

      robot.waitForIdle(delay);
    } finally {
      EventQueue.invokeAndWait(this::closeAll);
    }
  }