use of android.support.test.espresso.UiController in project material-components-android by material-components.
the class NavigationViewActions method setItemBackground.
/** Sets item background on the content of the navigation view. */
public static ViewAction setItemBackground(@Nullable final Drawable itemBackground) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isDisplayed();
}
@Override
public String getDescription() {
return "Set item background";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
NavigationView navigationView = (NavigationView) view;
navigationView.setItemBackground(itemBackground);
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.support.test.espresso.UiController in project material-components-android by material-components.
the class NavigationViewActions method addHeaderView.
/** Add the specified view as a header to the navigation view. */
public static ViewAction addHeaderView(@NonNull final LayoutInflater inflater, @LayoutRes final int res) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isDisplayed();
}
@Override
public String getDescription() {
return "Add header view";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
NavigationView navigationView = (NavigationView) view;
navigationView.addHeaderView(inflater.inflate(res, null, false));
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.support.test.espresso.UiController in project material-components-android by material-components.
the class NavigationViewActions method removeHeaderView.
/** Removes a previously added header view from the navigation view. */
public static ViewAction removeHeaderView(@Nullable final View headerView) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isDisplayed();
}
@Override
public String getDescription() {
return "Remove header view";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
NavigationView navigationView = (NavigationView) view;
navigationView.removeHeaderView(headerView);
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.support.test.espresso.UiController in project material-components-android by material-components.
the class NavigationViewActions method setItemTextColor.
/** Sets item text color on the content of the navigation view. */
public static ViewAction setItemTextColor(final ColorStateList textColor) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isDisplayed();
}
@Override
public String getDescription() {
return "Set item text color";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
NavigationView navigationView = (NavigationView) view;
navigationView.setItemTextColor(textColor);
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.support.test.espresso.UiController in project material-components-android by material-components.
the class TabLayoutWithViewPagerTest method addItemsToPager.
private static <Q> ViewAction addItemsToPager(final String[] title, final Q[] content) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(ViewPager.class);
}
@Override
public String getDescription() {
return "Add items 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();
int itemCount = title.length;
for (int i = 0; i < itemCount; i++) {
viewPagerAdapter.add(title[i], content[i]);
}
viewPagerAdapter.notifyDataSetChanged();
uiController.loopMainThreadUntilIdle();
}
};
}
Aggregations