Java 类android.support.test.espresso.action.CoordinatesProvider 实例源码

项目:ChimpCheck    文件:ChimpActionFactory.java   
private static CoordinatesProvider getCoordinatesProvider(final int x, final int y){
    return 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;
            float[] coordinates = {screenX, screenY};

            return coordinates;
        }
    };
}
项目:material-components-android    文件:BottomSheetBehaviorTest.java   
@Test
@MediumTest
public void testSwipeUpToExpand() {
  Espresso.onView(ViewMatchers.withId(R.id.bottom_sheet))
      .perform(
          DesignViewActions.withCustomConstraints(
              new GeneralSwipeAction(
                  Swipe.FAST,
                  GeneralLocation.VISIBLE_CENTER,
                  new CoordinatesProvider() {
                    @Override
                    public float[] calculateCoordinates(View view) {
                      return new float[] {view.getWidth() / 2, 0};
                    }
                  },
                  Press.FINGER),
              ViewMatchers.isDisplayingAtLeast(5)));
  registerIdlingResourceCallback();
  try {
    Espresso.onView(ViewMatchers.withId(R.id.bottom_sheet))
        .check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
    assertThat(getBehavior().getState(), is(BottomSheetBehavior.STATE_EXPANDED));
  } finally {
    unregisterIdlingResourceCallback();
  }
}
项目:SmoothClicker    文件:ItSelectMultiPointsActivity.java   
/**
 * 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);
}
项目:SmoothClicker    文件:ItClickerActivity.java   
/**
 * 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);
}
项目:Todo.txt-gDrive    文件:MainActivityTest.java   
private static 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;
                    float[] coordinates = {screenX, screenY};

                    return coordinates;
                }
            },
            Press.FINGER);
}
项目:translationRecorder    文件:TestUtils.java   
public static 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;
                    float[] coordinates = {screenX, screenY};

                    return coordinates;
                }
            },
            Press.FINGER);
}
项目:GitHub    文件:Utils.java   
/**
 * 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.
 */
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;
        }
    };
}
项目:SwipeCoordinator    文件:ViewActions.java   
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);
}
项目:SwipeCoordinator    文件:ViewActions.java   
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);
}
项目:SwipeCoordinator    文件:ViewActions.java   
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);
}
项目:SwipeCoordinator    文件:ViewActions.java   
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);
}
项目:material-components-android    文件:BottomSheetBehaviorTest.java   
@Test
@MediumTest
public void testHalfExpandedToExpanded() throws Throwable {
  getBehavior().setFitToContents(false);
  checkSetState(BottomSheetBehavior.STATE_HALF_EXPANDED, ViewMatchers.isDisplayed());
  Espresso.onView(ViewMatchers.withId(R.id.bottom_sheet))
      .perform(
          DesignViewActions.withCustomConstraints(
              new GeneralSwipeAction(
                  Swipe.FAST,
                  GeneralLocation.VISIBLE_CENTER,
                  new CoordinatesProvider() {
                    @Override
                    public float[] calculateCoordinates(View view) {
                      return new float[] {view.getWidth() / 2, 0};
                    }
                  },
                  Press.FINGER),
              ViewMatchers.isDisplayingAtLeast(5)));
  registerIdlingResourceCallback();
  try {
    Espresso.onView(ViewMatchers.withId(R.id.bottom_sheet))
        .check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
    assertThat(getBehavior().getState(), is(BottomSheetBehavior.STATE_EXPANDED));
  } finally {
    unregisterIdlingResourceCallback();
  }
}
项目:material-components-android    文件:BottomSheetBehaviorTest.java   
@Test
@MediumTest
public void testCollapsedToExpanded() throws Throwable {
  getBehavior().setFitToContents(false);
  checkSetState(BottomSheetBehavior.STATE_COLLAPSED, ViewMatchers.isDisplayed());
  Espresso.onView(ViewMatchers.withId(R.id.bottom_sheet))
      .perform(
          DesignViewActions.withCustomConstraints(
              new GeneralSwipeAction(
                  Swipe.FAST,
                  GeneralLocation.VISIBLE_CENTER,
                  new CoordinatesProvider() {
                    @Override
                    public float[] calculateCoordinates(View view) {
                      return new float[] {view.getWidth() / 2, 0};
                    }
                  },
                  Press.FINGER),
              ViewMatchers.isDisplayingAtLeast(5)));
  registerIdlingResourceCallback();
  try {
    Espresso.onView(ViewMatchers.withId(R.id.bottom_sheet))
        .check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
    assertThat(getBehavior().getState(), is(BottomSheetBehavior.STATE_EXPANDED));
  } finally {
    unregisterIdlingResourceCallback();
  }
}
项目:material-components-android    文件:BottomSheetBehaviorTest.java   
@Test
@MediumTest
public void testInvisible() throws Throwable {
  // Make the bottomsheet invisible
  activityTestRule.runOnUiThread(
      new Runnable() {
        @Override
        public void run() {
          getBottomSheet().setVisibility(View.INVISIBLE);
          assertThat(getBehavior().getState(), is(BottomSheetBehavior.STATE_COLLAPSED));
        }
      });
  // Swipe up as if to expand it
  Espresso.onView(ViewMatchers.withId(R.id.bottom_sheet))
      .perform(
          DesignViewActions.withCustomConstraints(
              new GeneralSwipeAction(
                  Swipe.FAST,
                  GeneralLocation.VISIBLE_CENTER,
                  new CoordinatesProvider() {
                    @Override
                    public float[] calculateCoordinates(View view) {
                      return new float[] {view.getWidth() / 2, 0};
                    }
                  },
                  Press.FINGER),
              not(ViewMatchers.isDisplayed())));
  // Check that the bottom sheet stays the same collapsed state
  activityTestRule.runOnUiThread(
      new Runnable() {
        @Override
        public void run() {
          assertThat(getBehavior().getState(), is(BottomSheetBehavior.STATE_COLLAPSED));
        }
      });
}
项目:material-activity-chooser    文件:NoConstraintsSwipeAction.java   
public NoConstraintsSwipeAction(Swiper swiper, CoordinatesProvider startCoordinatesProvider,
                                CoordinatesProvider endCoordinatesProvider, PrecisionDescriber precisionDescriber) {
  this.swiper = swiper;
  this.startCoordinatesProvider = startCoordinatesProvider;
  this.endCoordinatesProvider = endCoordinatesProvider;
  this.precisionDescriber = precisionDescriber;
}
项目:Bill-Calculator    文件:Tester.java   
ViewAction swipeAwayRight() {
    return actionWithAssertions(new GeneralSwipeAction(Swipe.FAST,
            GeneralLocation.CENTER,
            new CoordinatesProvider() {
                @Override
                public float[] calculateCoordinates(View view) {
                    float xy[] = GeneralLocation.CENTER_RIGHT.calculateCoordinates(view);
                    xy[0] += 20f * view.getWidth();
                    return xy;
                }
            },
            Press.FINGER));
}
项目:Ironhide    文件:GeneralZoomAction.java   
public GeneralZoomAction(Zoomer zoomer,
                         CoordinatesProvider[] startCoordinatesProviders,
                         CoordinatesProvider[] endCoordinatesProviders,
                         PrecisionDescriber precisionDescriber) {
    this.zoomer = zoomer;
    this.startCoordinatesProviders = startCoordinatesProviders;
    this.endCoordinatesProviders = endCoordinatesProviders;
    this.precisionDescriber = precisionDescriber;
}
项目:material-components-android    文件:BottomSheetBehaviorTest.java   
public DragAction(
    CoordinatesProvider start, CoordinatesProvider end, PrecisionDescriber precisionDescriber) {
  this.start = start;
  this.end = end;
  this.precisionDescriber = precisionDescriber;
}
项目:Bill-Calculator    文件:CustomClickAction.java   
private CustomClickAction(Tapper tapper, CoordinatesProvider coordinatesProvider,
                          PrecisionDescriber precisionDescriber) {
    this.coordinatesProvider = coordinatesProvider;
    this.tapper = tapper;
    this.precisionDescriber = precisionDescriber;
}
项目:Ironhide    文件:SwipeAction.java   
private SwipeDirection(CoordinatesProvider start, CoordinatesProvider end) {
    this.start = start;
    this.end = end;
}
项目:Ironhide    文件:ZoomAction.java   
/**
 * Variadic parameters to simplify the look of this function.
 * First two assumed to be start locations,
 *  next two assumed to be end location,
 *  and the rest are ignored.
 */
private ZoomDirection(CoordinatesProvider... providers) {
    this.start = new CoordinatesProvider[]{ providers[0], providers[1] };
    this.end = new CoordinatesProvider[]{ providers[2], providers[3] };
}