@Test public void testSearchUsingCategory() throws Exception { main.launchActivity(null); onView(withId(R.id.token_search_text_view)).perform(loopMainThreadForAtLeast(200)); onView(withText(exampleIngredients[0].getName())).check(matches(isDisplayed())); onView(withText(exampleIngredients[1].getName())).check(matches(isDisplayed())); onView(withId(R.id.ingredients_search_view)) .check(matches(isDisplayed())) .perform(clickExpand()); onView(withId(R.id.token_search_text_view)) .check(matches(isDisplayed())) .perform(typeTextIntoFocusedView("Tag")) .perform(loopMainThreadForAtLeast(500)); //Debounce onData(allOf(is(instanceOf(String.class)), is("Tag 2"))) .inRoot(RootMatchers.withDecorView(not(is(main .getActivity().getWindow().getDecorView())))) .perform(click()); onView(allOf(withId(R.id.ingredients_content),isAssignableFrom(RecyclerView.class))) .perform(loopMainThreadForAtLeast(500)); onView(withText(exampleIngredients[0].getName())).check(doesNotExist()); onView(withText(exampleIngredients[1].getName())).check(matches(isDisplayed())); onView(withText(exampleIngredients[2].getName())).check(doesNotExist()); }
@Test public void testAutoComplete() { // replace ProgressBar drawable while invisible since Espresso has issues with animations. onView(isAssignableFrom(ProgressBar.class)).perform(ViewActionUtils.replaceProgressBarDrawable()); // type d onView(withId(R.id.delayed_autocomplete_textview)).perform(typeText("d")); onView(withId(R.id.autocomplete_progress_bar)).check(matches(not(isDisplayed()))); // type e onView(withId(R.id.delayed_autocomplete_textview)).perform(typeText("e")); onView(withId(R.id.autocomplete_progress_bar)).check(matches(not(isDisplayed()))); // type n onView(withId(R.id.delayed_autocomplete_textview)).perform(typeText("n")); onView(withId(R.id.autocomplete_progress_bar)).check(matches(isDisplayed())); // idle until data is loaded registerIdlingResources(mIdlingResource); // select from list onData(allOf(is(instanceOf(String.class)), is("Denver International Airport [DEN]"))) .inRoot(RootMatchers.withDecorView(not(is(mActivityRule .getActivity().getWindow().getDecorView())))) .perform(click()); unregisterIdlingResources(mIdlingResource); }
public static org.hamcrest.Matcher findToastInRule(ActivityTestRule mActivityRule){ return RootMatchers.withDecorView(CoreMatchers.not(is(mActivityRule.getActivity().getWindow().getDecorView()))); }
public void testBackKeyShowsToast() { Espresso.pressBack(); Espresso.onView(ViewMatchers.withText(R.string.MPUBackButtonDisabled)).inRoot(RootMatchers.withDecorView(CoreMatchers.not(CoreMatchers.is(getActivity().getWindow().getDecorView())))).check(ViewAssertions.matches(ViewMatchers.isDisplayed())); }
public void testBackKeyShowsToast() { initWithAmount(106); Espresso.pressBack(); Espresso.onView(ViewMatchers.withText(R.string.MPUBackButtonDisabled)).inRoot(RootMatchers.withDecorView(CoreMatchers.not(CoreMatchers.is(getActivity().getWindow().getDecorView())))).check(ViewAssertions.matches(ViewMatchers.isDisplayed())); }
/** * Changes the root to search for this view to be a dialog */ public BaseView<T> inDialogRoot() { return inRoot(RootMatchers.isDialog()); }
/** * Changes the root to search for this view to be a platform popup */ public BaseView<T> inPlatformPopup() { return inRoot(RootMatchers.isPlatformPopup()); }
/** * Changes the root to search for this view to be touchable */ public BaseView<T> inTouchableRoot() { return inRoot(RootMatchers.isTouchable()); }
/** * Changes the root to search for this view to be a decor view */ public BaseView<T> inDecorView(Matcher<View> decorViewMatcher) { return inRoot(RootMatchers.withDecorView(decorViewMatcher)); }
/** * Changes the root to search for this view to be focusable */ public BaseView<T> inFocusableRoot() { return inRoot(RootMatchers.isFocusable()); }