Search in sources :

Example 11 with ViewAction

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();
        }
    };
}
Also used : ViewAction(android.support.test.espresso.ViewAction) TabLayout(android.support.design.widget.TabLayout) UiController(android.support.test.espresso.UiController) View(android.view.View)

Example 12 with ViewAction

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();
        }
    };
}
Also used : ViewAction(android.support.test.espresso.ViewAction) TabLayout(android.support.design.widget.TabLayout) UiController(android.support.test.espresso.UiController) View(android.view.View)

Example 13 with ViewAction

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();
        }
    };
}
Also used : ViewAction(android.support.test.espresso.ViewAction) TabLayout(android.support.design.widget.TabLayout) UiController(android.support.test.espresso.UiController) View(android.view.View)

Example 14 with ViewAction

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();
        }
    };
}
Also used : ViewAction(android.support.test.espresso.ViewAction) UiController(android.support.test.espresso.UiController) TextView(android.widget.TextView) NavigationView(android.support.design.widget.NavigationView) TextView(android.widget.TextView) View(android.view.View)

Example 15 with ViewAction

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();
        }
    };
}
Also used : ViewAction(android.support.test.espresso.ViewAction) UiController(android.support.test.espresso.UiController) TextView(android.widget.TextView) NavigationView(android.support.design.widget.NavigationView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

ViewAction (android.support.test.espresso.ViewAction)65 View (android.view.View)61 UiController (android.support.test.espresso.UiController)56 NavigationView (android.support.design.widget.NavigationView)18 Espresso.onView (android.support.test.espresso.Espresso.onView)11 TextView (android.widget.TextView)11 Test (org.junit.Test)9 ViewPager (android.support.v4.view.ViewPager)8 TabLayout (android.support.design.widget.TabLayout)7 TextInputLayout (android.support.design.widget.TextInputLayout)7 FloatingActionButton (android.support.design.widget.FloatingActionButton)6 RecyclerView (android.support.v7.widget.RecyclerView)6 ViewGroup (android.view.ViewGroup)4 Matcher (org.hamcrest.Matcher)4 BaseMatcher (org.hamcrest.BaseMatcher)3 TabLayoutActions.setupWithViewPager (android.support.design.testutils.TabLayoutActions.setupWithViewPager)2 BottomNavigationView (android.support.design.widget.BottomNavigationView)2 CollapsingToolbarLayout (android.support.design.widget.CollapsingToolbarLayout)2 ViewInteraction (android.support.test.espresso.ViewInteraction)2 DrawerLayout (android.support.v4.widget.DrawerLayout)2