use of android.support.test.espresso.UiController in project material-components-android by material-components.
the class FloatingActionButtonActions method hideThenShow.
public static ViewAction hideThenShow(final int animDuration) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(FloatingActionButton.class);
}
@Override
public String getDescription() {
return "Calls hide() then show()";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
FloatingActionButton fab = (FloatingActionButton) view;
fab.hide();
fab.show();
uiController.loopMainThreadForAtLeast(animDuration + 100);
}
};
}
use of android.support.test.espresso.UiController in project material-components-android by material-components.
the class FloatingActionButtonActions method setImageResource.
public static ViewAction setImageResource(@DrawableRes final int resId) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(FloatingActionButton.class);
}
@Override
public String getDescription() {
return "Sets FloatingActionButton image resource";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
final FloatingActionButton fab = (FloatingActionButton) view;
fab.setImageResource(resId);
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.support.test.espresso.UiController in project material-components-android by material-components.
the class NavigationViewActions method setCheckedItem.
/** Sets checked item on the navigation view. */
public static ViewAction setCheckedItem(@IdRes final int id) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isDisplayed();
}
@Override
public String getDescription() {
return "Set checked item";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
NavigationView navigationView = (NavigationView) view;
navigationView.setCheckedItem(id);
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.support.test.espresso.UiController in project material-components-android by material-components.
the class CoordinatorSnackbarWithFabTest method getSnackbarLocationOnScreen.
/** Returns the location of our snackbar on the screen. */
private static int[] getSnackbarLocationOnScreen() {
final int[] location = new int[2];
onView(isAssignableFrom(Snackbar.SnackbarLayout.class)).perform(new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isEnabled();
}
@Override
public String getDescription() {
return "Snackbar matcher";
}
@Override
public void perform(UiController uiController, View view) {
view.getLocationOnScreen(location);
}
});
return location;
}
use of android.support.test.espresso.UiController in project material-components-android by material-components.
the class TabLayoutWithViewPagerTest method addItemToPager.
private static <Q> ViewAction addItemToPager(final String title, final Q content) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(ViewPager.class);
}
@Override
public String getDescription() {
return "Add item and notify on content change";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
final ViewPager viewPager = (ViewPager) view;
// no way to avoid this cast
@SuppressWarnings("unchecked") final BasePagerAdapter<Q> viewPagerAdapter = (BasePagerAdapter<Q>) viewPager.getAdapter();
viewPagerAdapter.add(title, content);
viewPagerAdapter.notifyDataSetChanged();
uiController.loopMainThreadUntilIdle();
}
};
}
Aggregations