Search in sources :

Example 1 with NoMatchingRootException

use of androidx.test.espresso.NoMatchingRootException in project mobile-center-sdk-android by Microsoft.

the class EspressoUtils method waitFor.

public static ViewInteraction waitFor(final ViewInteraction viewInteraction, final long millis) throws InterruptedException {
    final long startTime = System.currentTimeMillis();
    final long endTime = startTime + millis;
    final View[] found = new View[] { null };
    while (System.currentTimeMillis() < endTime) {
        try {
            viewInteraction.check(new ViewAssertion() {

                @Override
                public void check(View view, NoMatchingViewException noViewFoundException) {
                    found[0] = view;
                }
            });
        } catch (NoMatchingRootException ignored) {
        }
        if (found[0] != null)
            return viewInteraction;
        Thread.sleep(CHECK_DELAY);
    }
    Assert.fail();
    return viewInteraction;
}
Also used : ViewAssertion(androidx.test.espresso.ViewAssertion) NoMatchingRootException(androidx.test.espresso.NoMatchingRootException) NoMatchingViewException(androidx.test.espresso.NoMatchingViewException) Espresso.onView(androidx.test.espresso.Espresso.onView) RootMatchers.withDecorView(androidx.test.espresso.matcher.RootMatchers.withDecorView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

View (android.view.View)1 TextView (android.widget.TextView)1 Espresso.onView (androidx.test.espresso.Espresso.onView)1 NoMatchingRootException (androidx.test.espresso.NoMatchingRootException)1 NoMatchingViewException (androidx.test.espresso.NoMatchingViewException)1 ViewAssertion (androidx.test.espresso.ViewAssertion)1 RootMatchers.withDecorView (androidx.test.espresso.matcher.RootMatchers.withDecorView)1