@Test
public void halfRefreshRate() {

    // Drop from 2hz to 1hz
    RefreshRateEstimator estimator = new RefreshRateEstimator();
    estimator.addSample(0);
    estimator.addSample(500);
    estimator.addSample(1000);
    assertEquals(2.0, estimator.refreshRate, 0.01);
    estimator.addSample(2000);
    assertEquals(2.0, estimator.refreshRate, 0.01); // assumes missing sample
    estimator.addSample(3000);
    assertEquals(1.0, estimator.refreshRate, 0.5); // starts adjusting
    estimator.addSample(4000);
    assertEquals(1.0, estimator.refreshRate, 0.25);
    estimator.addSample(5000);
    estimator.addSample(6000);
    assertEquals(1.0, estimator.refreshRate, 0.1);
    estimator.addSample(7000);
    estimator.addSample(8000);
    estimator.addSample(9000);
    assertEquals(1.0, estimator.refreshRate, 0.01); // close enough
}