title: Android testing: how to check a dialog is displayed on screen? (using ActivityInstrumentationTestCase2)
body: <p>I'm trying to finally add UI tests to my Android application, to increase coverage (all my other layers are properly tested, hence all my bugs now come from the UI...)
  I started to use <code>ActivityInstrumentationTestCase2</code> as my base class for emulator unit-tests, and simple things are easy to check and work nice.</p>
  
  <p>But now, I'm trying to check a Dialog appears as expected, and I don't know how to do that.</p>
  
  <p>My test:</p>
  
  <pre><code>public void testOpensAboutDialogWhenAboutButtonClicked() {
      final MyActivity activity = getActivity();
      final Instrumentation instrumentation = getInstrumentation();
  
      final Button aboutButton = (Button) activity.findViewById(R.id.about);
      TouchUtils.clickView(this, aboutButton);
  
      // how to test for the AboutDialog?
  }
  </code></pre>
  
  <p>Now my dialog doesn't have an id, so I can't get a pointer to it using findViewById.
  It has been created using the builder classes available:</p>
  
  <pre><code>final AlertDialog about = new AlertDialog.Builder(parent)
              .setTitle(parent.getString(R.string.about_title))
              .setCancelable(true)
              .setIcon(R.drawable.skull)
              ....
  </code></pre>
  
  <p>Any ideas, or pointers to tutorials?</p>
  
  <p><strong>EDIT:</strong> To answer Jens comment, I'm <strong>not</strong> using managed dialogs, just creating the AlertDialog and showing it with .show()</p>