Confetto { protected static Long computeMillisToReachTarget(Float targetVelocity, float initialVelocity, float acceleration) { if (targetVelocity != null) { if (acceleration != 0f) { final long time = (long) ((targetVelocity - initialVelocity) / acceleration); return time > 0 ? time : 0; } else { if (targetVelocity < initialVelocity) { return 0L; } else { return null; } } } else { return null; } }  void prepare(Rect bound); boolean onTouchDown(MotionEvent event); void onTouchMove(MotionEvent event); void onTouchUp(MotionEvent event); abstract int getWidth(); abstract int getHeight(); void reset(); boolean applyUpdate(long passedTime); void draw(Canvas canvas); void setInitialDelay(long val); void setInitialX(float val); void setInitialY(float val); void setInitialVelocityX(float val); void setInitialVelocityY(float val); void setAccelerationX(float val); void setAccelerationY(float val); void setTargetVelocityX(Float val); void setTargetVelocityY(Float val); void setInitialRotation(float val); void setInitialRotationalVelocity(float val); void setRotationalAcceleration(float val); void setTargetRotationalVelocity(Float val); void setTTL(long val); void setFadeOut(Interpolator fadeOutInterpolator);  }
@Test public void test_computeMillisToReachTarget() { Long time = Confetto.computeMillisToReachTarget(null, 0f, 0f); assertNull(time); time = Confetto.computeMillisToReachTarget(0f, 10f, 10f); assertEquals(0, time.longValue()); time = Confetto.computeMillisToReachTarget(20f, 10f, 10f); assertEquals(1, time.longValue()); time = Confetto.computeMillisToReachTarget(30f, 0f, 10f); assertEquals(3, time.longValue()); time = Confetto.computeMillisToReachTarget(20f, 10f, 0f); assertNull(time); }