Search in sources :

Example 1 with NoMatchingRootException

use of android.support.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(android.support.test.espresso.ViewAssertion) NoMatchingRootException(android.support.test.espresso.NoMatchingRootException) NoMatchingViewException(android.support.test.espresso.NoMatchingViewException) TextView(android.widget.TextView) Espresso.onView(android.support.test.espresso.Espresso.onView) RootMatchers.withDecorView(android.support.test.espresso.matcher.RootMatchers.withDecorView) View(android.view.View)

Example 2 with NoMatchingRootException

use of android.support.test.espresso.NoMatchingRootException in project AppCenter-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(android.support.test.espresso.ViewAssertion) NoMatchingRootException(android.support.test.espresso.NoMatchingRootException) NoMatchingViewException(android.support.test.espresso.NoMatchingViewException) TextView(android.widget.TextView) Espresso.onView(android.support.test.espresso.Espresso.onView) RootMatchers.withDecorView(android.support.test.espresso.matcher.RootMatchers.withDecorView) View(android.view.View)

Aggregations

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