title: Android Espresso: How to check that Toast message is NOT shown?
body: <p>I'm working now in my functional tests and in one of them I have to test that a toast message is NOT shown. Considering this is the code I'm using to check if the toast message is shown (this code works):</p>
  
  <pre><code>onView(withText(R.string.my_toast_message))
          .inRoot(withDecorView(not(getActivity().getWindow().getDecorView())))
          .check(matches(isDisplayed()));
  </code></pre>
  
  <p>below you can find the code I'm using to check that a toast message is NOT shown (none of them work):</p>
  
  <p>Approach one:</p>
  
  <pre><code>onView(withText(R.string.error_invalid_login))
          .inRoot(withDecorView(not(getActivity().getWindow().getDecorView())))
          .check(matches(not(isDisplayed())));
  </code></pre>
  
  <p>Approach two:</p>
  
  <pre><code>onView(withText(R.string.error_invalid_login))
          .inRoot(withDecorView(not(getActivity().getWindow().getDecorView())))
          .check(doesNotExist());
  </code></pre>
  
  <p>Any idea about how can I check that a toast message is not shown would be really appreciated :)</p>