Search in sources :

Example 41 with UiController

use of android.support.test.espresso.UiController 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)

Example 42 with UiController

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

the class CollapsingToolbarLayoutActions method setContentScrimColor.

public static ViewAction setContentScrimColor(@ColorInt final int color) {
    return new ViewAction() {

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

        @Override
        public String getDescription() {
            return "Set the content scrim to a color";
        }

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();
            CollapsingToolbarLayout ctl = (CollapsingToolbarLayout) view;
            ctl.setContentScrimColor(color);
            uiController.loopMainThreadUntilIdle();
        }
    };
}
Also used : ViewAction(android.support.test.espresso.ViewAction) UiController(android.support.test.espresso.UiController) CollapsingToolbarLayout(android.support.design.widget.CollapsingToolbarLayout) View(android.view.View)

Example 43 with UiController

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

the class FloatingActionButtonActions method setBackgroundTintList.

public static ViewAction setBackgroundTintList(@ColorInt final ColorStateList tint) {
    return new ViewAction() {

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

        @Override
        public String getDescription() {
            return "Sets FloatingActionButton background tint";
        }

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

Example 44 with UiController

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

the class FloatingActionButtonActions method setCompatElevation.

public static ViewAction setCompatElevation(final float size) {
    return new ViewAction() {

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

        @Override
        public String getDescription() {
            return "Sets FloatingActionButton elevation";
        }

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();
            final FloatingActionButton fab = (FloatingActionButton) view;
            fab.setCompatElevation(size);
            uiController.loopMainThreadUntilIdle();
        }
    };
}
Also used : ViewAction(android.support.test.espresso.ViewAction) UiController(android.support.test.espresso.UiController) FloatingActionButton(android.support.design.widget.FloatingActionButton) View(android.view.View)

Example 45 with UiController

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

the class NavigationViewActions method setItemTextAppearance.

/** Sets item text appearance on the content of the navigation view. */
public static ViewAction setItemTextAppearance(@StyleRes final int resId) {
    return new ViewAction() {

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

        @Override
        public String getDescription() {
            return "Set item text appearance";
        }

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

Aggregations

UiController (android.support.test.espresso.UiController)57 View (android.view.View)57 ViewAction (android.support.test.espresso.ViewAction)56 NavigationView (android.support.design.widget.NavigationView)18 TextView (android.widget.TextView)11 ViewPager (android.support.v4.view.ViewPager)8 TabLayout (android.support.design.widget.TabLayout)7 TextInputLayout (android.support.design.widget.TextInputLayout)7 Espresso.onView (android.support.test.espresso.Espresso.onView)7 FloatingActionButton (android.support.design.widget.FloatingActionButton)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 DrawerLayout (android.support.v4.widget.DrawerLayout)2 HorizontalScrollView (android.widget.HorizontalScrollView)2 TimeoutException (java.util.concurrent.TimeoutException)2 NotFoundException (android.content.res.Resources.NotFoundException)1