Search in sources :

Example 6 with ViewAction

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

the class ViewPagerActions method scrollToPage.

/** Moves <code>ViewPager</code> to specific page. */
public static ViewAction scrollToPage(final int page) {
    return new ViewAction() {

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

        @Override
        public String getDescription() {
            return "ViewPager move to a specific page";
        }

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();
            ViewPager viewPager = (ViewPager) view;
            viewPager.setCurrentItem(page, 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 7 with ViewAction

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

the class ViewPagerActions method scrollToFirst.

/** Moves <code>ViewPager</code> to the first page. */
public static ViewAction scrollToFirst() {
    return new ViewAction() {

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

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

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();
            ViewPager viewPager = (ViewPager) view;
            int size = viewPager.getAdapter().getCount();
            if (size > 0) {
                viewPager.setCurrentItem(0, 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 8 with ViewAction

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

the class ViewPagerActions method scrollToLast.

/** Moves <code>ViewPager</code> to the last page. */
public static ViewAction scrollToLast() {
    return new ViewAction() {

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

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

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();
            ViewPager viewPager = (ViewPager) view;
            int size = viewPager.getAdapter().getCount();
            if (size > 0) {
                viewPager.setCurrentItem(size - 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 9 with ViewAction

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

the class ViewPagerActions method setAdapter.

/** Sets the specified adapter on <code>ViewPager</code>. */
public static ViewAction setAdapter(@Nullable final PagerAdapter adapter) {
    return new ViewAction() {

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

        @Override
        public String getDescription() {
            return "ViewPager set adapter";
        }

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();
            ViewPager viewPager = (ViewPager) view;
            viewPager.setAdapter(adapter);
            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 10 with ViewAction

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

the class BottomNavigationViewActions method setItemIconTintList.

/** Sets item icon tint list on the content of the bottom navigation view. */
public static ViewAction setItemIconTintList(@Nullable final ColorStateList tint) {
    return new ViewAction() {

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

        @Override
        public String getDescription() {
            return "Set item icon tint list";
        }

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();
            BottomNavigationView navigationView = (BottomNavigationView) view;
            navigationView.setItemIconTintList(tint);
            uiController.loopMainThreadUntilIdle();
        }
    };
}
Also used : ViewAction(android.support.test.espresso.ViewAction) BottomNavigationView(android.support.design.widget.BottomNavigationView) UiController(android.support.test.espresso.UiController) BottomNavigationView(android.support.design.widget.BottomNavigationView) View(android.view.View)

Aggregations

ViewAction (android.support.test.espresso.ViewAction)64 View (android.view.View)60 UiController (android.support.test.espresso.UiController)55 NavigationView (android.support.design.widget.NavigationView)17 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