Search in sources :

Example 1 with NoMatchingViewException

use of androidx.test.espresso.NoMatchingViewException in project DiscreteScrollView by yarolegovich.

the class CustomAssertions method doesNotHaveChildren.

public static ViewAssertion doesNotHaveChildren() {
    return new ViewAssertion() {

        @Override
        public void check(View view, NoMatchingViewException noViewFoundException) {
            ensureViewFound(noViewFoundException);
            assertThat(view, isAssignableFrom(ViewGroup.class));
            ViewGroup viewGroup = (ViewGroup) view;
            assertThat(viewGroup.getChildCount(), is(equalTo(0)));
        }
    };
}
Also used : ViewAssertion(androidx.test.espresso.ViewAssertion) ViewGroup(android.view.ViewGroup) NoMatchingViewException(androidx.test.espresso.NoMatchingViewException) DiscreteScrollView(com.yarolegovich.discretescrollview.DiscreteScrollView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 2 with NoMatchingViewException

use of androidx.test.espresso.NoMatchingViewException in project quickstart-android by firebase.

the class MainActivityTest method selectFavoriteFoodIfPossible.

private void selectFavoriteFoodIfPossible(String food) {
    try {
        ViewInteraction appCompatTextView = onView(allOf(withId(android.R.id.text1), withText(food), withParent(allOf(withId(R.id.select_dialog_listview), withParent(withId(R.id.contentPanel)))), isDisplayed()));
        appCompatTextView.perform(click());
    } catch (NoMatchingViewException e) {
    // This is ok
    }
}
Also used : ViewInteraction(androidx.test.espresso.ViewInteraction) NoMatchingViewException(androidx.test.espresso.NoMatchingViewException)

Example 3 with NoMatchingViewException

use of androidx.test.espresso.NoMatchingViewException 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)

Example 4 with NoMatchingViewException

use of androidx.test.espresso.NoMatchingViewException in project DiscreteScrollView by yarolegovich.

the class CustomAssertions method currentPositionIs.

public static ViewAssertion currentPositionIs(final int expectedPosition) {
    return new ViewAssertion() {

        @Override
        public void check(View view, NoMatchingViewException noViewFoundException) {
            ensureViewFound(noViewFoundException);
            assertThat(view, isAssignableFrom(DiscreteScrollView.class));
            DiscreteScrollView dsv = (DiscreteScrollView) view;
            assertThat(dsv.getCurrentItem(), is(equalTo(expectedPosition)));
            View midChild = findCenteredChildIn(dsv);
            assertThat(midChild, is(notNullValue()));
            RecyclerView.ViewHolder holder = dsv.getChildViewHolder(midChild);
            assertThat(holder.getAdapterPosition(), is(equalTo(expectedPosition)));
        }
    };
}
Also used : ViewAssertion(androidx.test.espresso.ViewAssertion) NoMatchingViewException(androidx.test.espresso.NoMatchingViewException) DiscreteScrollView(com.yarolegovich.discretescrollview.DiscreteScrollView) RecyclerView(androidx.recyclerview.widget.RecyclerView) DiscreteScrollView(com.yarolegovich.discretescrollview.DiscreteScrollView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Aggregations

NoMatchingViewException (androidx.test.espresso.NoMatchingViewException)4 View (android.view.View)3 ViewAssertion (androidx.test.espresso.ViewAssertion)3 RecyclerView (androidx.recyclerview.widget.RecyclerView)2 DiscreteScrollView (com.yarolegovich.discretescrollview.DiscreteScrollView)2 ViewGroup (android.view.ViewGroup)1 TextView (android.widget.TextView)1 Espresso.onView (androidx.test.espresso.Espresso.onView)1 NoMatchingRootException (androidx.test.espresso.NoMatchingRootException)1 ViewInteraction (androidx.test.espresso.ViewInteraction)1 RootMatchers.withDecorView (androidx.test.espresso.matcher.RootMatchers.withDecorView)1