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

The following examples show how to use android.support.test.espresso.action.GeneralClickAction. 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 Project: SmoothClicker   Author: pylapp   File: ItSelectMultiPointsActivity.java    License: 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 Project: SmoothClicker   Author: pylapp   File: ItClickerActivity.java    License: 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 Project: CompactCalendarView   Author: SundeepK   File: ApplicationTest.java    License: 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 Project: material-activity-chooser   Author: zawadz88   File: ViewActions.java    License: Apache License 2.0 4 votes vote down vote up
public static ViewAction clickOnTop() {
    return new GeneralClickAction(Tap.SINGLE, GeneralLocation.TOP_CENTER, Press.FINGER);
}
 
Example #5
Source Project: easy-adapter   Author: ribot   File: CustomViewActions.java    License: Apache License 2.0 4 votes vote down vote up
public static ViewAction clickOnChild(int childViewId) {
    return actionWithAssertions((new ChildClickAction(
            new GeneralClickAction(Tap.SINGLE, GeneralLocation.VISIBLE_CENTER, Press.FINGER),
            childViewId)));
}
 
Example #6
Source Project: easy-adapter   Author: ribot   File: CustomViewActions.java    License: Apache License 2.0 4 votes vote down vote up
public ChildClickAction(GeneralClickAction generalClickAction, int childViewId) {
    mGeneralClickAction = generalClickAction;
    mChildViewId = childViewId;
}