@SuppressWarnings("deprecation") // TODO: fix by using a fragment instead
  public static void assertDialogWasDisplayed(Activity activity, int dialogId) {
    // IMPLEMENTATION NOTE: This code below relies on the fact that, if a dialog with the ID was
    // every displayed, then dismissDialog will succeed, whereas if the dialog with the ID has
    // never been shown, then dismissDialog throws an IllegalArgumentException.
    try {
      activity.dismissDialog(dialogId);
      // Reset the "was displayed" state
      activity.removeDialog(dialogId);
    } catch (IllegalArgumentException e) {
      Assert.fail("No dialog with ID " + dialogId + " was ever displayed");
    }
  }
Asserts that the provided {@link Activity} displayed a dialog with the provided ID at some
point in the past. Note that this does not necessarily mean that the dialog is still being
displayed.

<p><b>Note:</b> this method resets the "was displayed" state of the dialog. This means that a
consecutive invocation of this method for the same dialog ID will fail unless the dialog was
displayed again prior to the invocation of this method.
javatests/com/google/android/apps/authenticator/testing/TestUtilities.java