Java Code Examples for android.support.test.espresso.action.Swiper

The following are top voted examples for showing how to use android.support.test.espresso.action.Swiper. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Material-BottomNavigation   File: ViewActionsCompat.java   View source code 5 votes vote down vote up
public static ViewAction swipeUp(final Swiper swipe) {
    return ViewActions.actionWithAssertions(new GeneralSwipeAction(
        swipe,
        GeneralLocation.CENTER,
        GeneralLocation.TOP_CENTER,
        Press.FINGER
    ));
}
 
Example 2
Project: Material-BottomNavigation   File: ViewActionsCompat.java   View source code 5 votes vote down vote up
public static ViewAction swipeDown(final Swiper swipe) {
    return ViewActions.actionWithAssertions(new GeneralSwipeAction(
        swipe,
        GeneralLocation.CENTER,
        GeneralLocation.BOTTOM_CENTER,
        Press.FINGER
    ));
}
 
Example 3
Project: material-activity-chooser   File: NoConstraintsSwipeAction.java   View source code 5 votes vote down vote up
public NoConstraintsSwipeAction(Swiper swiper, CoordinatesProvider startCoordinatesProvider,
                                CoordinatesProvider endCoordinatesProvider, PrecisionDescriber precisionDescriber) {
  this.swiper = swiper;
  this.startCoordinatesProvider = startCoordinatesProvider;
  this.endCoordinatesProvider = endCoordinatesProvider;
  this.precisionDescriber = precisionDescriber;
}
 
Example 4
Project: Ironhide   File: SwipeAction.java   View source code 5 votes vote down vote up
/**
 * Gets a swipe action.
 *
 * @param speed the speed of the swipe
 * @param direction the direction of the swipe
 * @return  the swipe action requested
 */
public static GeneralSwipeAction getSwipe(Swiper speed, SwipeDirection direction) {
    Pair<Swiper, SwipeDirection> key = new Pair<>(speed, direction);

    if (!bufferedSwipeActions.containsKey(key))
        bufferedSwipeActions.put(key, generateSwipe(speed, direction));

    return bufferedSwipeActions.get(key);
}
 
Example 5
Project: material-activity-chooser   File: NoConstraintsSwipeAction.java   View source code 4 votes vote down vote up
@Override
public void perform(UiController uiController, View view) {
  float[] startCoordinates = startCoordinatesProvider.calculateCoordinates(view);
  float[] endCoordinates = endCoordinatesProvider.calculateCoordinates(view);
  float[] precision = precisionDescriber.describePrecision();

  Swiper.Status status = Swiper.Status.FAILURE;

  for (int tries = 0; tries < MAX_TRIES && status != Swiper.Status.SUCCESS; tries++) {
    try {
      status = swiper.sendSwipe(uiController, startCoordinates, endCoordinates, precision);
    } catch (RuntimeException re) {
      throw new PerformException.Builder()
          .withActionDescription(this.getDescription())
          .withViewDescription(HumanReadables.describe(view))
          .withCause(re)
          .build();
    }

    int duration = ViewConfiguration.getPressedStateDuration();
    // ensures that all work enqueued to process the swipe has been run.
    if (duration > 0) {
      uiController.loopMainThreadForAtLeast(duration);
    }
  }

  if (status == Swiper.Status.FAILURE) {
    throw new PerformException.Builder()
        .withActionDescription(getDescription())
        .withViewDescription(HumanReadables.describe(view))
        .withCause(new RuntimeException(String.format(
            "Couldn't swipe from: %s,%s to: %s,%s precision: %s, %s . Swiper: %s "
            + "start coordinate provider: %s precision describer: %s. Tried %s times",
            startCoordinates[0],
            startCoordinates[1],
            endCoordinates[0],
            endCoordinates[1],
            precision[0],
            precision[1],
            swiper,
            startCoordinatesProvider,
            precisionDescriber,
            MAX_TRIES)))
        .build();
  }
}
 
Example 6
Project: Ironhide   File: Swipeable.java   View source code 2 votes vote down vote up
/**
 * {@link Swipeable#swipe(
 *  android.support.test.espresso.action.Swiper,
 *  com.mindbodyonline.ironhide.Infrastructure.Extensions.SwipeAction.SwipeDirection,
 *  int)}
 * with {@link Swipeable#DEFAULT_TIMES}
 */
public T swipe(Swiper speed, SwipeAction.SwipeDirection direction) {
    return swipe(speed, direction, DEFAULT_TIMES);
}
 
Example 7
Project: Ironhide   File: SwipeAction.java   View source code 2 votes vote down vote up
/**
 * Creates a new swipe action.
 *
 * @param speed the speed of the swipe
 * @param direction the direction of the swipe
 * @return  the swipe action requested
 */
private static GeneralSwipeAction generateSwipe(Swiper speed, SwipeDirection direction) {
    return new GeneralSwipeAction(speed, direction.start, direction.end, Press.FINGER);
}