Java Code Examples for android.support.test.espresso.Root

The following are top voted examples for showing how to use android.support.test.espresso.Root. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: TherapyGuide   File: Matchers.java   View source code 6 votes vote down vote up
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");
        }
    };
}
 
Example 2
Project: mangosta-android   File: MyViewMatchers.java   View source code 6 votes vote down vote up
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;
        }
    };
}
 
Example 3
Project: Vineyard   File: CustomMatchers.java   View source code 6 votes vote down vote up
/**
 * 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;
        }
    };
}
 
Example 4
Project: pubnative-android-sdk   File: LayoutActivityTest.java   View source code 5 votes vote down vote up
@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;
}
 
Example 5
Project: Attendance   File: CompaniesMvvmActivityEspressoTest.java   View source code 5 votes vote down vote up
@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;
}
 
Example 6
Project: friendly-plans   File: ToastMatcher.java   View source code 5 votes vote down vote up
@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;
}
 
Example 7
Project: zulip-android   File: ToastMatcher.java   View source code 5 votes vote down vote up
@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;
}
 
Example 8
Project: Ironhide   File: BaseView.java   View source code 5 votes vote down vote up
/**
 * 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();
}
 
Example 9
Project: americano   File: RootMatchers.java   View source code 5 votes vote down vote up
/**
 * 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;
        }
    };
}
 
Example 10
Project: akvo-caddisfly   File: ToastMatcher.java   View source code 5 votes vote down vote up
@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;
}
 
Example 11
Project: FitBuddy   File: ToastMatcher.java   View source code 5 votes vote down vote up
@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;
}
 
Example 12
Project: 2016.2-MissaoNascente   File: PreferenceControllerAcceptanceTest.java   View source code 4 votes vote down vote up
public static Matcher<Root> isPopupWindow() {
    return isPlatformPopup();
}
 
Example 13
Project: 2016.2-MissaoNascente   File: TutorialAcceptanceTest.java   View source code 4 votes vote down vote up
public static Matcher<Root> isPopupWindow() {
    return isPlatformPopup();
}
 
Example 14
Project: 2016.2-MissaoNascente   File: MainScreenAcceptanceTest.java   View source code 4 votes vote down vote up
public static Matcher<Root> isPopupWindow() {
    return isPlatformPopup();
}
 
Example 15
Project: zulip-android   File: BaseTest.java   View source code 4 votes vote down vote up
public static Matcher<Root> isToast() {
    return new ToastMatcher();
}
 
Example 16
Project: Ironhide   File: SpinnerView.java   View source code 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public SpinnerView<T> inRoot(Matcher<Root> rootMatcher) {
    return (SpinnerView<T>) super.inRoot(rootMatcher);
}
 
Example 17
Project: Ironhide   File: Recycler.java   View source code 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public Recycler<T> inRoot(Matcher<Root> rootMatcher) {
    return (Recycler<T>) super.inRoot(rootMatcher);
}
 
Example 18
Project: Ironhide   File: ListItem.java   View source code 4 votes vote down vote up
/** {@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");
}
 
Example 19
Project: Ironhide   File: ListAdapter.java   View source code 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public ListAdapter<T> inRoot(Matcher<Root> rootMatcher) {
    this.adapter = this.adapter.inRoot(rootMatcher);
    return this;
}
 
Example 20
Project: Ironhide   File: Clickable.java   View source code 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public Clickable<T> inRoot(Matcher<Root> rootMatcher) {
    return (Clickable<T>) super.inRoot(rootMatcher);
}
 
Example 21
Project: Ironhide   File: TextField.java   View source code 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public TextField<T> inRoot(Matcher<Root> rootMatcher) {
    return (TextField<T>) super.inRoot(rootMatcher);
}
 
Example 22
Project: Ironhide   File: DatePicker.java   View source code 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public DatePicker<T> inRoot(Matcher<Root> rootMatcher) {
    return (DatePicker<T>) super.inRoot(rootMatcher);
}
 
Example 23
Project: Ironhide   File: Swipeable.java   View source code 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public Swipeable<T> inRoot(Matcher<Root> rootMatcher) {
    return (Swipeable<T>) super.inRoot(rootMatcher);
}
 
Example 24
Project: Ironhide   File: LayoutView.java   View source code 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public LayoutView<T> inRoot(Matcher<Root> rootMatcher) {
    return (LayoutView<T>) super.inRoot(rootMatcher);
}
 
Example 25
Project: Ironhide   File: Zoomable.java   View source code 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public Zoomable<T> inRoot(Matcher<Root> rootMatcher) {
    return (Zoomable<T>) super.inRoot(rootMatcher);
}
 
Example 26
Project: Ironhide   File: NavDrawer.java   View source code 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public NavDrawer<T> inRoot(Matcher<Root> rootMatcher) {
    return (NavDrawer<T>) super.inRoot(rootMatcher);
}
 
Example 27
Project: FitBuddy   File: ToastMatcher.java   View source code 4 votes vote down vote up
public static Matcher<Root> isToast() {
    return new ToastMatcher();
}
 
Example 28
Project: Ironhide   File: BaseView.java   View source code 2 votes vote down vote up
/**
 * 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;
}