@Test
public void testEvaluateQueueSizeDoNotReevaluateUntilAfterMinTimeBetweenBufferReevaluation() {

  Format format1 = videoFormat(/* bitrate= */ 500, /* width= */ 320, /* height= */ 240);
  Format format2 = videoFormat(/* bitrate= */ 1000, /* width= */ 640, /* height= */ 480);
  Format format3 = videoFormat(/* bitrate= */ 2000, /* width= */ 960, /* height= */ 720);
  TrackGroup trackGroup = new TrackGroup(format1, format2, format3);
  FakeMediaChunk chunk1 =
      new FakeMediaChunk(format1, /* startTimeUs= */ 0, /* endTimeUs= */ 10_000_000);
  FakeMediaChunk chunk2 =
      new FakeMediaChunk(format1, /* startTimeUs= */ 10_000_000, /* endTimeUs= */ 20_000_000);
  FakeMediaChunk chunk3 =
      new FakeMediaChunk(format1, /* startTimeUs= */ 20_000_000, /* endTimeUs= */ 30_000_000);
  List<FakeMediaChunk> queue = new ArrayList<>();
  queue.add(chunk1);
  queue.add(chunk2);
  queue.add(chunk3);
  when(mockBandwidthMeter.getBitrateEstimate()).thenReturn(500L);
  adaptiveTrackSelection =
      adaptiveTrackSelectionWithMinTimeBetweenBufferReevaluationMs(
          trackGroup,
          /* durationToRetainAfterDiscardMs= */ 15_000,
          /* minTimeBetweenBufferReevaluationMs= */ 2000);
  int initialQueueSize = adaptiveTrackSelection.evaluateQueueSize(0, queue);
  fakeClock.advanceTime(1999);
  when(mockBandwidthMeter.getBitrateEstimate()).thenReturn(1000L);
  // When bandwidth estimation is updated, we can discard chunks at the end of the queue now.
  // However, since min duration between buffer reevaluation = 2000, we will not reevaluate
  // queue size if time now is only 1999 ms after last buffer reevaluation.
  int newSize = adaptiveTrackSelection.evaluateQueueSize(0, queue);
  assertThat(newSize).isEqualTo(initialQueueSize);
}