v7/appcompat/src/androidTest/java/androidx/appcompat/testutils/TestUtils.java
public static void emulateTapOnView(Instrumentation instrumentation, View anchorView,
            int offsetX, int offsetY) {
        final int touchSlop = ViewConfiguration.get(anchorView.getContext()).getScaledTouchSlop();
        // Get anchor coordinates on the screen
        final int[] viewOnScreenXY = new int[2];
        anchorView.getLocationOnScreen(viewOnScreenXY);
        int xOnScreen = viewOnScreenXY[0] + offsetX;
        int yOnScreen = viewOnScreenXY[1] + offsetY;
        final long downTime = SystemClock.uptimeMillis();

        injectDownEvent(instrumentation, downTime, xOnScreen, yOnScreen);
        injectMoveEventForTap(instrumentation, downTime, touchSlop, xOnScreen, yOnScreen);
        injectUpEvent(instrumentation, downTime, false, xOnScreen, yOnScreen);

        // Wait for the system to process all events in the queue
        instrumentation.waitForIdleSync();
    }
/**
     * Emulates a tap on a point relative to the top-left corner of the passed {@link View}. Offset
     * parameters are used to compute the final screen coordinates of the tap point.
     *
     * @param instrumentation the instrumentation used to run the test
     * @param anchorView the anchor view to determine the tap location on the screen
     * @param offsetX extra X offset for the tap
     * @param offsetY extra Y offset for the tap
     */
Emulates a tap on a point relative to the top-left corner of the passed  View. Offset
parameters are used to compute the final screen coordinates of the tap point.

@param instrumentation the instrumentation used to run the test
@param anchorView the anchor view to determine the tap location on the screen
@param offsetX extra X offset for the tap
@param offsetY extra Y offset for the tap
Emulates a tap on a point relative to the top - left corner of the passed View . Offset parameters are used to compute the final screen coordinates of the tap point . @param instrumentation the instrumentation used to run the test @param anchorView the anchor view to determine the tap location on the screen @param offsetX extra X offset for the tap @param offsetY extra Y offset for the tap
public static void emulateTapOnView(Instrumentation instrumentation, View anchorView,
            int offsetX, int offsetY) {
        final int touchSlop = ViewConfiguration.get(anchorView.getContext()).getScaledTouchSlop();
        final int[] viewOnScreenXY = new int[2];
        anchorView.getLocationOnScreen(viewOnScreenXY);
        int xOnScreen = viewOnScreenXY[0] + offsetX;
        int yOnScreen = viewOnScreenXY[1] + offsetY;
        final long downTime = SystemClock.uptimeMillis();
        injectDownEvent(instrumentation, downTime, xOnScreen, yOnScreen);
        injectMoveEventForTap(instrumentation, downTime, touchSlop, xOnScreen, yOnScreen);
        injectUpEvent(instrumentation, downTime, false, xOnScreen, yOnScreen);
        instrumentation.waitForIdleSync();
    }
public static void emulateTapOnView ( Instrumentation instrumentation , View anchorView , int offsetX , int offsetY ) { final int touchSlop = ViewConfiguration . get ( anchorView . getContext ( ) ) . getScaledTouchSlop ( ) ; final int [ ] viewOnScreenXY = new int [ 2 ] ; anchorView . getLocationOnScreen ( viewOnScreenXY ) ; int xOnScreen = viewOnScreenXY [ 0 ] + offsetX ; int yOnScreen = viewOnScreenXY [ 1 ] + offsetY ; final long downTime = SystemClock . uptimeMillis ( ) ; injectDownEvent ( instrumentation , downTime , xOnScreen , yOnScreen ) ; injectMoveEventForTap ( instrumentation , downTime , touchSlop , xOnScreen , yOnScreen ) ; injectUpEvent ( instrumentation , downTime , false , xOnScreen , yOnScreen ) ; instrumentation . waitForIdleSync ( ) ; }
Emulates a tap on a point relative to the top-left corner of the passed {@link View}.
Emulates a tap on a point relative to the top - left corner of the passed { @link View } .
// Get anchor coordinates on the screen // Wait for the system to process all events in the queue