android.support.test.espresso.action.CoordinatesProvider Java Examples

The following examples show how to use android.support.test.espresso.action.CoordinatesProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ItSelectMultiPointsActivity.java    From SmoothClicker with MIT License 6 votes vote down vote up
/**
 * Custom ViewAction to click on dedicated coordinates
 * @param x -
 * @param y -
 * @return ViewAction -
 */
private ViewAction clickXY( final int x, final int y ){
    return new GeneralClickAction(
            Tap.SINGLE,
            new CoordinatesProvider() {
                @Override
                public float[] calculateCoordinates( View view ){

                    final int[] screenPos = new int[2];
                    view.getLocationOnScreen(screenPos);

                    final float screenX = screenPos[0] + x;
                    final float screenY = screenPos[1] + y;

                    return new float[]{screenX, screenY};

                }
            },
            Press.FINGER);
}
 
Example #2
Source File: ItClickerActivity.java    From SmoothClicker with MIT License 6 votes vote down vote up
/**
 * Custom ViewAction to click on dedicated coordinates
 * @param x -
 * @param y -
 * @return ViewAction -
 */
private ViewAction clickXY( final int x, final int y ){
    return new GeneralClickAction(
            Tap.SINGLE,
            new CoordinatesProvider() {
                @Override
                public float[] calculateCoordinates( View view ){

                    final int[] screenPos = new int[2];
                    view.getLocationOnScreen(screenPos);

                    final float screenX = screenPos[0] + x;
                    final float screenY = screenPos[1] + y;

                    return new float[]{screenX, screenY};

                }
            },
            Press.FINGER);
}
 
Example #3
Source File: ApplicationTest.java    From CompactCalendarView with MIT License 6 votes vote down vote up
public ViewAction clickXY(final float x, final float y){
    final DisplayMetrics dm = activityRule.getActivity().getResources().getDisplayMetrics() ;
    final float spX = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, x, dm);
    final float spY = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, y, dm);
    return new GeneralClickAction(
            Tap.SINGLE,
            new CoordinatesProvider() {
                @Override
                public float[] calculateCoordinates(View view) {

                    final int[] screenPos = new int[2];
                    view.getLocationOnScreen(screenPos);

                    final float screenX = screenPos[0] + spX;
                    final float screenY = screenPos[1] + spY;
                    float[] coordinates = {screenX, screenY};

                    return coordinates;
                }
            },
            Press.FINGER);
}
 
Example #4
Source File: CustomClickAction.java    From android-espresso-revealed with Apache License 2.0 5 votes vote down vote up
public CustomClickAction(Tapper tapper, CoordinatesProvider coordinatesProvider,
                         PrecisionDescriber precisionDescriber, ViewAction rollbackAction) {
    this.coordinatesProvider = coordinatesProvider;
    this.tapper = tapper;
    this.precisionDescriber = precisionDescriber;
    this.rollbackAction = Optional.fromNullable(rollbackAction);
}
 
Example #5
Source File: CustomSwipeActions.java    From android-espresso-revealed with Apache License 2.0 5 votes vote down vote up
/**
 * Translates the given coordinates by the given distances. The distances are given in term
 * of the view's size -- 1.0 means to translate by an amount equivalent to the view's length.
 */
private static CoordinatesProvider translate(final CoordinatesProvider coords,
                                             final float dx, final float dy) {
    return new CoordinatesProvider() {
        @Override
        public float[] calculateCoordinates(View view) {
            float xy[] = coords.calculateCoordinates(view);
            xy[0] += dx * view.getWidth();
            xy[1] += dy * view.getHeight();
            return xy;
        }
    };
}
 
Example #6
Source File: ViewActions.java    From SwipeCoordinator with Apache License 2.0 5 votes vote down vote up
static ViewAction swipeRightNotReachingThreshold(Context context) {
  final float x = getWidthScreen(context) * 0.3f;
  return new GeneralSwipeAction(Swipe.SLOW, GeneralLocation.TOP_LEFT, new CoordinatesProvider() {
    @Override public float[] calculateCoordinates(View view) {
      return new float[] {x, 0f};
    }
  }, Press.FINGER);
}
 
Example #7
Source File: ViewActions.java    From SwipeCoordinator with Apache License 2.0 5 votes vote down vote up
static ViewAction swipeRightReachingThreshold(Context context) {
  final float x = getWidthScreen(context) * 0.8f;
  return new GeneralSwipeAction(Swipe.SLOW, GeneralLocation.TOP_LEFT, new CoordinatesProvider() {
    @Override public float[] calculateCoordinates(View view) {
      return new float[] {x, 0f};
    }
  }, Press.FINGER);
}
 
Example #8
Source File: ViewActions.java    From SwipeCoordinator with Apache License 2.0 5 votes vote down vote up
static ViewAction swipeDownNotReachingThreshold(Context context) {
  final float y = getHeightScreen(context) * 0.3f;
  return new GeneralSwipeAction(Swipe.SLOW, GeneralLocation.TOP_LEFT, new CoordinatesProvider() {
    @Override public float[] calculateCoordinates(View view) {
      return new float[] {0f, y};
    }
  }, Press.FINGER);
}
 
Example #9
Source File: ViewActions.java    From SwipeCoordinator with Apache License 2.0 5 votes vote down vote up
static ViewAction swipeDownReachingThreshold(Context context) {
  final float y = getHeightScreen(context) * 0.8f;
  return new GeneralSwipeAction(Swipe.SLOW, GeneralLocation.TOP_LEFT, new CoordinatesProvider() {
    @Override public float[] calculateCoordinates(View view) {
      return new float[] {0f, y};
    }
  }, Press.FINGER);
}
 
Example #10
Source File: NoConstraintsSwipeAction.java    From material-activity-chooser with Apache License 2.0 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 #11
Source File: CustomClickAction.java    From android-espresso-revealed with Apache License 2.0 4 votes vote down vote up
public CustomClickAction(Tapper tapper, CoordinatesProvider coordinatesProvider,
                         PrecisionDescriber precisionDescriber) {
    this(tapper, coordinatesProvider, precisionDescriber, null);
}
 
Example #12
Source File: MapActivityTest.java    From mobile-android-samples with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private static ViewAction swipe() {

        CoordinatesProvider start = GeneralLocation.TOP_CENTER;
        CoordinatesProvider end = GeneralLocation.BOTTOM_CENTER;
        return new GeneralSwipeAction(Swipe.SLOW, start, end, Press.FINGER);
    }