verify if a view was displayed even if for a moment
<p>I have a login UI with a corresponding API call in my code, which I want to test using Espresso. When I click on the login button, an API call is made and a ProgressBar appears for as long as the API call is executing and then it's visibility is set back to gone once we get a response. Most of the times, the call is very instantaneous, hence if I check for isDisplayed() on the ProgressBar view, I get false. Below is the code -</p>

<pre><code>    onView(withId(R.id.edit_text_username)).perform(typeText("asd"));
    onView(withId(R.id.edit_text_password)).perform(typeText("asd"), closeSoftKeyboard());
    onView(withId(R.id.forward_button)).check(matches(isEnabled()));
    onView(withId(R.id.forward_button)).perform(click());

    onView(withId(R.id.progress_bar_gateway)).check(matches(isDisplayed()));
</code></pre>

<p>Is there any way to check if the ProgressBar visibility was toggled from gone -> visible -> gone?</p>