@SmallTest
  public void testFling() {
    class TestData extends Parameter {
      final int velocity;
      final int mimimumVelocity;
      final int scrollPosition;
      final int expectedEndScrollPosition;
      final boolean expectedIsScrolling;

      TestData(
          int velocity,
          int mimimumVelocity,
          int scrollPosition,
          int expectedEndScrollPosition,
          boolean expectedIsScrolling) {
        this.velocity = velocity;
        this.mimimumVelocity = mimimumVelocity;
        this.scrollPosition = scrollPosition;
        this.expectedEndScrollPosition = expectedEndScrollPosition;
        this.expectedIsScrolling = expectedIsScrolling;
      }
    }
    int pageSize = 10;
    int viewSize = 20;
    int contentSize = 110;
    final long timestamp = 12345;
    TestData[] testDataList = {
      // Velocity is 0 so scroll animation does not start.
      new TestData(0, 0, 0, 0, false),
      // Usual situation to start scroll.
      new TestData(-1, 1, 5, 0, true),
      new TestData(+1, 1, 5, 10, true),
      // Velocity is lower than mininum velocity so animation does not start.
      new TestData(-1, 2, 5, 0, false),
      new TestData(+1, 2, 5, 0, false),
      // Animation starts on the page edge position.
      new TestData(-1, 1, 10, 0, true),
      new TestData(+1, 1, 10, 20, true),
      // Minimum and maximum boundary check.
      new TestData(-1, 1, 0, 0, false),
      new TestData(+1, 1, 100, 90, false),
    };
    SnapScroller scroller =
        new SnapScroller(
            new SnapScroller.TimestampCalculator() {
              @Override
              public long getTimestamp() {
                return timestamp;
              }
            });
    scroller.setContentSize(contentSize);
    scroller.setPageSize(pageSize);
    scroller.setViewSize(viewSize);
    for (TestData testData : testDataList) {
      scroller.scrollTo(testData.scrollPosition);
      scroller.setMinimumVelocity(testData.mimimumVelocity);
      scroller.fling(testData.velocity);
      assertEquals(testData.toString(), testData.expectedIsScrolling, scroller.isScrolling());
      if (scroller.isScrolling()) {
        assertEquals(
            testData.toString(), testData.scrollPosition, scroller.getStartScrollPosition());
        assertEquals(
            testData.toString(),
            testData.expectedEndScrollPosition,
            scroller.getEndScrollPosition());
        assertEquals(testData.toString(), timestamp, scroller.getStartScrollTime());
      }
    }
  }