use of com.google.android.apps.common.testing.ui.espresso.ViewAction in project double-espresso by JakeWharton.
the class DrawerActions method checkDrawer.
/**
* Returns true if the given matcher matches the drawer.
*/
private static boolean checkDrawer(int drawerLayoutId, final Matcher<View> matcher) {
final AtomicBoolean matches = new AtomicBoolean(false);
onView(withId(drawerLayoutId)).perform(new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(DrawerLayout.class);
}
@Override
public String getDescription() {
return "check drawer";
}
@Override
public void perform(UiController uiController, View view) {
matches.set(matcher.matches(view));
}
});
return matches.get();
}
use of com.google.android.apps.common.testing.ui.espresso.ViewAction in project double-espresso by JakeWharton.
the class DrawerActions method registerListener.
/**
* Returns a {@link ViewAction} that adds an {@link IdlingDrawerListener} as a drawer listener to
* the {@link DrawerLayout}. The idling drawer listener wraps any listener that already exists.
*/
private static ViewAction registerListener() {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(DrawerLayout.class);
}
@Override
public String getDescription() {
return "register idling drawer listener";
}
@Override
public void perform(UiController uiController, View view) {
DrawerLayout drawer = (DrawerLayout) view;
DrawerListener existingListener = getDrawerListener(drawer);
if (existingListener instanceof IdlingDrawerListener) {
// listener is already registered. No need to assign.
return;
}
drawer.setDrawerListener(IdlingDrawerListener.getInstance(existingListener));
}
};
}
Aggregations