use of android.support.test.espresso.ViewAction in project material-components-android by material-components.
the class TestUtilsActions method reinflateMenu.
/**
* Clears and inflates the menu.
*
* @param menuResId The menu resource XML to be used.
*/
public static ViewAction reinflateMenu(@MenuRes final int menuResId) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(NavigationView.class);
}
@Override
public String getDescription() {
return "clear and inflate menu " + menuResId;
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
final NavigationView nv = (NavigationView) view;
nv.getMenu().clear();
nv.inflateMenu(menuResId);
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.support.test.espresso.ViewAction in project material-components-android by material-components.
the class DrawerLayoutActions method openDrawer.
/** Opens the drawer at the specified edge gravity. */
public static ViewAction openDrawer(final int drawerEdgeGravity) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(DrawerLayout.class);
}
@Override
public String getDescription() {
return "Opens the drawer";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
DrawerLayout drawerLayout = (DrawerLayout) view;
drawerLayout.openDrawer(drawerEdgeGravity);
// Wait for a full second to let the inner ViewDragHelper complete the operation
uiController.loopMainThreadForAtLeast(1000);
}
};
}
use of android.support.test.espresso.ViewAction in project material-components-android by material-components.
the class DrawerLayoutActions method closeDrawer.
/** Closes the drawer at the specified edge gravity. */
public static ViewAction closeDrawer(final int drawerEdgeGravity) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(DrawerLayout.class);
}
@Override
public String getDescription() {
return "Closes the drawer";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
DrawerLayout drawerLayout = (DrawerLayout) view;
drawerLayout.closeDrawer(drawerEdgeGravity);
// Wait for a full second to let the inner ViewDragHelper complete the operation
uiController.loopMainThreadForAtLeast(1000);
}
};
}
use of android.support.test.espresso.ViewAction in project material-components-android by material-components.
the class FloatingActionButtonActions method showThenHide.
public static ViewAction showThenHide(final int animDuration) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(FloatingActionButton.class);
}
@Override
public String getDescription() {
return "Calls show() then hide()";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
FloatingActionButton fab = (FloatingActionButton) view;
fab.show();
fab.hide();
uiController.loopMainThreadForAtLeast(animDuration + 50);
}
};
}
use of android.support.test.espresso.ViewAction in project material-components-android by material-components.
the class FloatingActionButtonActions method setSize.
public static ViewAction setSize(@FloatingActionButton.Size final int size) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(FloatingActionButton.class);
}
@Override
public String getDescription() {
return "Sets FloatingActionButton size";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
final FloatingActionButton fab = (FloatingActionButton) view;
fab.setSize(size);
uiController.loopMainThreadUntilIdle();
}
};
}
Aggregations