use of android.support.test.espresso.UiController in project material-components-android by material-components.
the class NavigationViewActions method removeMenuItem.
/**
* Removes the specified menu item from the navigation view.
*
* @param menuItemId The ID of the menu item to be removed.
*/
public static ViewAction removeMenuItem(@IdRes final int menuItemId) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(NavigationView.class);
}
@Override
public String getDescription() {
return "Remove menu item " + menuItemId;
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
NavigationView navigationView = (NavigationView) view;
navigationView.getMenu().removeItem(menuItemId);
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.support.test.espresso.UiController in project material-components-android by material-components.
the class TabLayoutActions method setupWithViewPager.
/** Wires <code>TabLayout</code> to <code>ViewPager</code> content. */
public static ViewAction setupWithViewPager(@Nullable final ViewPager viewPager) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isDisplayingAtLeast(90);
}
@Override
public String getDescription() {
return "Setup with ViewPager content";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
TabLayout tabLayout = (TabLayout) view;
tabLayout.setupWithViewPager(viewPager);
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.support.test.espresso.UiController in project material-components-android by material-components.
the class TabLayoutActions method setScrollPosition.
/**
* Calls <code>setScrollPosition(position, positionOffset, true)</code> on the <code>TabLayout
* </code>
*/
public static ViewAction setScrollPosition(final int position, final float positionOffset) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return ViewMatchers.isAssignableFrom(TabLayout.class);
}
@Override
public String getDescription() {
return "setScrollPosition(" + position + ", " + positionOffset + ", true)";
}
@Override
public void perform(UiController uiController, View view) {
TabLayout tabs = (TabLayout) view;
tabs.setScrollPosition(position, positionOffset, true);
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.support.test.espresso.UiController in project material-components-android by material-components.
the class TestUtilsActions method addTabs.
/** Adds tabs to {@link TabLayout} */
public static ViewAction addTabs(final String... tabs) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(TabLayout.class);
}
@Override
public String getDescription() {
return "TabLayout add tabs";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
TabLayout tabLayout = (TabLayout) view;
for (int i = 0; i < tabs.length; i++) {
tabLayout.addTab(tabLayout.newTab().setText(tabs[i]));
}
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.support.test.espresso.UiController in project material-components-android by material-components.
the class TestUtilsActions method setTitle.
/** Sets title on the {@link CollapsingToolbarLayout}. */
public static ViewAction setTitle(final CharSequence title) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(CollapsingToolbarLayout.class);
}
@Override
public String getDescription() {
return "set toolbar title";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) view;
collapsingToolbarLayout.setTitle(title);
uiController.loopMainThreadUntilIdle();
}
};
}
Aggregations