android.support.test.espresso.Root Java Examples

The following examples show how to use android.support.test.espresso.Root. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MyViewMatchers.java    From mangosta-android with Apache License 2.0 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 #2
Source File: ToastMatcher.java    From friendly-plans with GNU General Public License v3.0 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 #3
Source File: ToastMatcher.java    From zulip-android with Apache License 2.0 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 #4
Source File: BaseTest.java    From zulip-android with Apache License 2.0 4 votes vote down vote up
public static Matcher<Root> isToast() {
    return new ToastMatcher();
}