use of android.support.test.espresso.ViewAction 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, final boolean autoRefresh) {
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, autoRefresh);
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.support.test.espresso.ViewAction in project material-components-android by material-components.
the class TabLayoutActions method setTabMode.
/** Sets the specified tab mode in the <code>TabLayout</code>. */
public static ViewAction setTabMode(final int tabMode) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isDisplayingAtLeast(90);
}
@Override
public String getDescription() {
return "Sets tab mode";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
TabLayout tabLayout = (TabLayout) view;
tabLayout.setTabMode(tabMode);
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.support.test.espresso.ViewAction in project material-components-android by material-components.
the class TabLayoutActions method selectTab.
/** Selects the specified tab in the <code>TabLayout</code>. */
public static ViewAction selectTab(final int tabIndex) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isDisplayingAtLeast(90);
}
@Override
public String getDescription() {
return "Selects tab";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
TabLayout tabLayout = (TabLayout) view;
tabLayout.getTabAt(tabIndex).select();
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.support.test.espresso.ViewAction in project material-components-android by material-components.
the class TestUtilsActions method setCompoundDrawablesRelative.
/** Sets compound drawables on {@link TextView} */
public static ViewAction setCompoundDrawablesRelative(@Nullable final Drawable start, @Nullable final Drawable top, @Nullable final Drawable end, @Nullable final Drawable bottom) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(TextView.class);
}
@Override
public String getDescription() {
return "TextView set compound drawables relative";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
TextView textView = (TextView) view;
TextViewCompat.setCompoundDrawablesRelative(textView, start, top, end, bottom);
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.support.test.espresso.ViewAction in project material-components-android by material-components.
the class TestUtilsActions method setText.
/** Sets text content on {@link TextView} */
public static ViewAction setText(@Nullable final CharSequence text) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(TextView.class);
}
@Override
public String getDescription() {
return "TextView set text";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
TextView textView = (TextView) view;
textView.setText(text);
uiController.loopMainThreadUntilIdle();
}
};
}
Aggregations