Search in sources :

Example 46 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 47 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)

Example 48 with UiController

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

the class NavigationViewActions method setItemIconTintList.

/** Sets item icon tint list on the content of the 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();
            NavigationView navigationView = (NavigationView) view;
            navigationView.setItemIconTintList(tint);
            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)

Example 49 with UiController

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

the class NavigationViewActions method setIconForMenuItem.

/** Sets icon for the menu item of the navigation view. */
public static ViewAction setIconForMenuItem(@IdRes final int menuItemId, final Drawable iconDrawable) {
    return new ViewAction() {

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

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

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();
            NavigationView navigationView = (NavigationView) view;
            navigationView.getMenu().findItem(menuItemId).setIcon(iconDrawable);
            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)

Example 50 with UiController

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

the class NavigationViewActions method inflateHeaderView.

/**
   * Inflates a view from the specified layout ID and adds it as a header to the navigation view.
   */
public static ViewAction inflateHeaderView(@LayoutRes final int res) {
    return new ViewAction() {

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

        @Override
        public String getDescription() {
            return "Inflate and add header view";
        }

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();
            NavigationView navigationView = (NavigationView) view;
            navigationView.inflateHeaderView(res);
            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)64 View (android.view.View)64 ViewAction (android.support.test.espresso.ViewAction)63 NavigationView (android.support.design.widget.NavigationView)18 Espresso.onView (android.support.test.espresso.Espresso.onView)14 TextView (android.widget.TextView)14 ViewPager (android.support.v4.view.ViewPager)9 TabLayout (android.support.design.widget.TabLayout)8 TextInputLayout (android.support.design.widget.TextInputLayout)7 FloatingActionButton (android.support.design.widget.FloatingActionButton)6 BottomNavigationView (android.support.design.widget.BottomNavigationView)4 ViewGroup (android.view.ViewGroup)4 Matcher (org.hamcrest.Matcher)4 BaseMatcher (org.hamcrest.BaseMatcher)3 TypeSafeMatcher (org.hamcrest.TypeSafeMatcher)3 TabLayoutActions.setupWithViewPager (android.support.design.testutils.TabLayoutActions.setupWithViewPager)2 CollapsingToolbarLayout (android.support.design.widget.CollapsingToolbarLayout)2 DrawerLayout (android.support.v4.widget.DrawerLayout)2 RecyclerView (android.support.v7.widget.RecyclerView)2 HorizontalScrollView (android.widget.HorizontalScrollView)2