Code example for GestureDetector

0
    private GestureDetector detector;
    private MotionEvent motionEvent;
 
    @Before 
    public void setUp() throws Exception { 
        detector = new GestureDetector(null);
        motionEvent = MotionEvent.obtain(-1, -1, MotionEvent.ACTION_UP, 100, 30, -1);
    } 
 
    @Test 
    public void test_getOnTouchEventMotionEvent() throws Exception { 
        detector.onTouchEvent(motionEvent);
        assertSame(motionEvent, shadowOf(detector).getOnTouchEventMotionEvent());
    } 
 
    @Test 
    public void test_reset() throws Exception { 
        detector.onTouchEvent(motionEvent);
        assertSame(motionEvent, shadowOf(detector).getOnTouchEventMotionEvent());
 
        shadowOf(detector).reset();