public static Matcher<Root> showsToast() { return new TypeSafeMatcher<Root>() { @Override public boolean matchesSafely(Root root) { int type = root.getWindowLayoutParams().get().type; if (type == WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY) { IBinder windowToken = root.getDecorView().getWindowToken(); IBinder appToken = root.getDecorView().getApplicationWindowToken(); if (windowToken == appToken) { // windowToken == appToken means this window isn't contained by any other windows. // if it was a window for an activity, it would have TYPE_BASE_APPLICATION. return true; } } return false; } @Override public void describeTo(Description description) { description.appendText("is toast"); } }; }
public static Matcher<Root> isToast() { return new TypeSafeMatcher<Root>() { @Override public void describeTo(Description description) { description.appendText("is toast"); } @Override public boolean matchesSafely(Root root) { int type = root.getWindowLayoutParams().get().type; if (type == WindowManager.LayoutParams.TYPE_TOAST) { IBinder windowToken = root.getDecorView().getWindowToken(); IBinder appToken = root.getDecorView().getApplicationWindowToken(); if (windowToken == appToken) { // windowToken == appToken means this window isn't contained by any other windows. // if it was a window for an activity, it would have TYPE_BASE_APPLICATION. return true; } } return false; } }; }
/** * Matcher that is Toast window. */ public static Matcher<Root> isToast() { return new TypeSafeMatcher<Root>() { @Override public void describeTo(Description description) { description.appendText("is toast"); } @Override public boolean matchesSafely(Root root) { int type = root.getWindowLayoutParams().get().type; if ((type == WindowManager.LayoutParams.TYPE_TOAST)) { IBinder windowToken = root.getDecorView().getWindowToken(); IBinder appToken = root.getDecorView().getApplicationWindowToken(); if (windowToken == appToken) { // windowToken == appToken means this window isn't contained by any other windows. // if it was a window for an activity, it would have TYPE_BASE_APPLICATION. return true; } } return false; } }; }
@Override public boolean matchesSafely(Root root) { int type = root.getWindowLayoutParams().get().type; if (type == WindowManager.LayoutParams.TYPE_TOAST) { IBinder windowToken = root.getDecorView().getWindowToken(); IBinder appToken = root.getDecorView().getApplicationWindowToken(); if (windowToken == appToken) { // windowToken == appToken means this window isn't contained by any other windows. // if it was a window for an activity, it would have TYPE_BASE_APPLICATION. return true; } } return false; }
@Override public boolean matchesSafely(Root root) { int type = root.getWindowLayoutParams().get().type; if ((type == WindowManager.LayoutParams.TYPE_TOAST)) { IBinder windowToken = root.getDecorView().getWindowToken(); IBinder appToken = root.getDecorView().getApplicationWindowToken(); if (windowToken == appToken) { return true; } } return false; }
@Override public boolean matchesSafely(Root root) { int type = root.getWindowLayoutParams().get().type; if (type == WindowManager.LayoutParams.TYPE_TOAST) { IBinder windowToken = root.getDecorView().getWindowToken(); IBinder appToken = root.getDecorView().getApplicationWindowToken(); if (windowToken == appToken) { return true; } } return false; }
/** * Checks that the root of the current view matches the given rootMatcher * * @param rootMatcher The RootMatcher used to check the root of the element * @return The model reached by interacting with this element */ protected T checkRootMatches(Matcher<Root> rootMatcher) { onView(getSelector()) .inRoot(rootMatcher) .check(ViewAssertions.matches(ViewMatchers.isDisplayed())); return returnGeneric(); }
/** * Matches {@link Root}s that are toasts. */ public static Matcher<Root> isToast() { return new TypeSafeMatcher<Root>() { @Override public void describeTo(Description description) { description.appendText("is toast"); } @Override public boolean matchesSafely(Root root) { return root.getWindowLayoutParams().get().type == WindowManager.LayoutParams.TYPE_TOAST; } }; }
@Override public boolean matchesSafely(Root root) { int type = root.getWindowLayoutParams().get().type; if (type == WindowManager.LayoutParams.TYPE_TOAST) { IBinder windowToken = root.getDecorView().getWindowToken(); IBinder appToken = root.getDecorView().getApplicationWindowToken(); if (windowToken.equals(appToken)) { // windowToken == appToken means this window isn't contained by any other windows. // if it was a window for an activity, it would have TYPE_BASE_APPLICATION. return true; } } return false; }
public static Matcher<Root> isPopupWindow() { return isPlatformPopup(); }
public static Matcher<Root> isToast() { return new ToastMatcher(); }
/** {@inheritDoc} */ @Override public SpinnerView<T> inRoot(Matcher<Root> rootMatcher) { return (SpinnerView<T>) super.inRoot(rootMatcher); }
/** {@inheritDoc} */ @Override public Recycler<T> inRoot(Matcher<Root> rootMatcher) { return (Recycler<T>) super.inRoot(rootMatcher); }
/** {@inheritDoc} */ @Override public ListItem<T> inRoot(Matcher<Root> rootMatcher) { throw new UnsupportedOperationException("It is too late to call this method. Use ListAdapter's root changers instead"); }
/** {@inheritDoc} */ @Override public ListAdapter<T> inRoot(Matcher<Root> rootMatcher) { this.adapter = this.adapter.inRoot(rootMatcher); return this; }
/** {@inheritDoc} */ @Override public Clickable<T> inRoot(Matcher<Root> rootMatcher) { return (Clickable<T>) super.inRoot(rootMatcher); }
/** {@inheritDoc} */ @Override public TextField<T> inRoot(Matcher<Root> rootMatcher) { return (TextField<T>) super.inRoot(rootMatcher); }
/** {@inheritDoc} */ @Override public DatePicker<T> inRoot(Matcher<Root> rootMatcher) { return (DatePicker<T>) super.inRoot(rootMatcher); }
/** {@inheritDoc} */ @Override public Swipeable<T> inRoot(Matcher<Root> rootMatcher) { return (Swipeable<T>) super.inRoot(rootMatcher); }
/** {@inheritDoc} */ @Override public LayoutView<T> inRoot(Matcher<Root> rootMatcher) { return (LayoutView<T>) super.inRoot(rootMatcher); }
/** {@inheritDoc} */ @Override public Zoomable<T> inRoot(Matcher<Root> rootMatcher) { return (Zoomable<T>) super.inRoot(rootMatcher); }
/** {@inheritDoc} */ @Override public NavDrawer<T> inRoot(Matcher<Root> rootMatcher) { return (NavDrawer<T>) super.inRoot(rootMatcher); }
/** * Changes the root for this view to match the given rootMatcher * @param rootMatcher a rootMatcher using Espresso's RootMatchers * @return this */ protected BaseView<T> inRoot(Matcher<Root> rootMatcher) { this.viewInteraction = this.viewInteraction.inRoot(rootMatcher); return this; }