use of android.support.test.espresso.ViewAction in project material-components-android by material-components.
the class NavigationViewActions method setIconForMenuItem.
/** Sets icon for the menu item of the navigation view. */
public static ViewAction setIconForMenuItem(@IdRes final int menuItemId, final Drawable iconDrawable) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isDisplayed();
}
@Override
public String getDescription() {
return "Set menu item icon";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
NavigationView navigationView = (NavigationView) view;
navigationView.getMenu().findItem(menuItemId).setIcon(iconDrawable);
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.support.test.espresso.ViewAction in project material-components-android by material-components.
the class NavigationViewActions method inflateHeaderView.
/**
* Inflates a view from the specified layout ID and adds it as a header to the navigation view.
*/
public static ViewAction inflateHeaderView(@LayoutRes final int res) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isDisplayed();
}
@Override
public String getDescription() {
return "Inflate and add header view";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
NavigationView navigationView = (NavigationView) view;
navigationView.inflateHeaderView(res);
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.support.test.espresso.ViewAction 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.ViewAction 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.ViewAction 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();
}
};
}
Aggregations