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)));
}
};
}
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
}
}
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;
}
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)));
}
};
}
Aggregations