Search in sources :

Example 1 with GeneralClickAction

use of android.support.test.espresso.action.GeneralClickAction in project CompactCalendarView by SundeepK.

the class ApplicationTest method clickXY.

public ViewAction clickXY(final float x, final float y) {
    final DisplayMetrics dm = activity.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);
}
Also used : GeneralClickAction(android.support.test.espresso.action.GeneralClickAction) CoordinatesProvider(android.support.test.espresso.action.CoordinatesProvider) DisplayMetrics(android.util.DisplayMetrics) View(android.view.View) TextView(android.widget.TextView) Espresso.onView(android.support.test.espresso.Espresso.onView) CompactCalendarView(com.github.sundeepk.compactcalendarview.CompactCalendarView)

Aggregations

Espresso.onView (android.support.test.espresso.Espresso.onView)1 CoordinatesProvider (android.support.test.espresso.action.CoordinatesProvider)1 GeneralClickAction (android.support.test.espresso.action.GeneralClickAction)1 DisplayMetrics (android.util.DisplayMetrics)1 View (android.view.View)1 TextView (android.widget.TextView)1 CompactCalendarView (com.github.sundeepk.compactcalendarview.CompactCalendarView)1