Code example for VelocityTracker

Methods: addMovement

0
        addMotionEvent(vt, endX, endY, startime + duration, MotionEvent.ACTION_UP);
    } 
 
    private void addMotionEvent(VelocityTracker vt, int x, int y, long time, int action) {
        MotionEvent me = MotionEvent.obtain(time, time, action, x, y, 0);
        vt.addMovement(me);
        me.recycle();
    } 
 
    /** 
     * Float imprecision of the average computations and filtering 
     * (removing last MotionEvent for N > 3) implies that tests 
     *  accepts some approximated values. 
     */ 
    private void assertEqualFuzzy(float expected, float actual, float threshold) {
        boolean fuzzyEqual = actual >= expected - threshold && actual <= expected + threshold;
        Assert.assertTrue("Expected: <"+expected+"> but was: <"+actual+
                "> while accepting a variation of: <"+threshold+">", fuzzyEqual);
    } 
 
    private void assertGreater(float minExpected, float actual) {