Search in sources :

Example 41 with ViewAction

use of android.support.test.espresso.ViewAction in project material-components-android by material-components.

the class TextInputLayoutActions method setErrorTextAppearance.

public static ViewAction setErrorTextAppearance(final int resId) {
    return new ViewAction() {

        @Override
        public Matcher<View> getConstraints() {
            return isAssignableFrom(TextInputLayout.class);
        }

        @Override
        public String getDescription() {
            return "Sets the error text appearance";
        }

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();
            TextInputLayout layout = (TextInputLayout) view;
            layout.setErrorTextAppearance(resId);
            uiController.loopMainThreadUntilIdle();
        }
    };
}
Also used : ViewAction(android.support.test.espresso.ViewAction) UiController(android.support.test.espresso.UiController) TextInputLayout(android.support.design.widget.TextInputLayout) View(android.view.View)

Example 42 with ViewAction

use of android.support.test.espresso.ViewAction in project material-components-android by material-components.

the class TextInputLayoutActions method setErrorEnabled.

public static ViewAction setErrorEnabled(final boolean enabled) {
    return new ViewAction() {

        @Override
        public Matcher<View> getConstraints() {
            return isAssignableFrom(TextInputLayout.class);
        }

        @Override
        public String getDescription() {
            return "Enables/disables the error";
        }

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();
            TextInputLayout layout = (TextInputLayout) view;
            layout.setErrorEnabled(enabled);
            uiController.loopMainThreadUntilIdle();
        }
    };
}
Also used : ViewAction(android.support.test.espresso.ViewAction) UiController(android.support.test.espresso.UiController) TextInputLayout(android.support.design.widget.TextInputLayout) View(android.view.View)

Example 43 with ViewAction

use of android.support.test.espresso.ViewAction in project material-components-android by material-components.

the class TextInputLayoutActions method setCounterEnabled.

public static ViewAction setCounterEnabled(final boolean enabled) {
    return new ViewAction() {

        @Override
        public Matcher<View> getConstraints() {
            return isAssignableFrom(TextInputLayout.class);
        }

        @Override
        public String getDescription() {
            return "Sets the counter enabled";
        }

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();
            TextInputLayout layout = (TextInputLayout) view;
            layout.setCounterEnabled(enabled);
            uiController.loopMainThreadUntilIdle();
        }
    };
}
Also used : ViewAction(android.support.test.espresso.ViewAction) UiController(android.support.test.espresso.UiController) TextInputLayout(android.support.design.widget.TextInputLayout) View(android.view.View)

Example 44 with ViewAction

use of android.support.test.espresso.ViewAction in project material-components-android by material-components.

the class ViewPagerActions method scrollRight.

/** Moves <code>ViewPager</code> to the right by one page. */
public static ViewAction scrollRight() {
    return new ViewAction() {

        @Override
        public Matcher<View> getConstraints() {
            return isDisplayingAtLeast(90);
        }

        @Override
        public String getDescription() {
            return "ViewPager scroll one page to the right";
        }

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();
            ViewPager viewPager = (ViewPager) view;
            int current = viewPager.getCurrentItem();
            viewPager.setCurrentItem(current + 1, false);
            uiController.loopMainThreadUntilIdle();
        }
    };
}
Also used : ViewAction(android.support.test.espresso.ViewAction) UiController(android.support.test.espresso.UiController) View(android.view.View) ViewPager(android.support.v4.view.ViewPager)

Example 45 with ViewAction

use of android.support.test.espresso.ViewAction in project material-components-android by material-components.

the class ViewPagerActions method scrollLeft.

/** Moves <code>ViewPager</code> to the left by one page. */
public static ViewAction scrollLeft() {
    return new ViewAction() {

        @Override
        public Matcher<View> getConstraints() {
            return isDisplayingAtLeast(90);
        }

        @Override
        public String getDescription() {
            return "ViewPager scroll one page to the left";
        }

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();
            ViewPager viewPager = (ViewPager) view;
            int current = viewPager.getCurrentItem();
            viewPager.setCurrentItem(current - 1, false);
            uiController.loopMainThreadUntilIdle();
        }
    };
}
Also used : ViewAction(android.support.test.espresso.ViewAction) UiController(android.support.test.espresso.UiController) View(android.view.View) ViewPager(android.support.v4.view.ViewPager)

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