@Test
public void testGetPeriodPositionDynamicWindowKnownDuration() {

  long windowDurationUs = 1000;
  SinglePeriodTimeline timeline =
      new SinglePeriodTimeline(
          windowDurationUs,
          windowDurationUs,
          /* windowPositionInPeriodUs= */ 0,
          /* windowDefaultStartPositionUs= */ 0,
          /* isSeekable= */ false,
          /* isDynamic= */ true,
          /* isLive= */ true,
          /* manifest= */ null,
          /* tag= */ null);
  // Should return null with a positive position projection beyond window duration.
  Pair<Object, Long> position =
      timeline.getPeriodPosition(window, period, 0, C.TIME_UNSET, windowDurationUs + 1);
  assertThat(position).isNull();
  // Should return (0, duration) with a projection equal to window duration.
  position = timeline.getPeriodPosition(window, period, 0, C.TIME_UNSET, windowDurationUs);
  assertThat(position.first).isEqualTo(timeline.getUidOfPeriod(0));
  assertThat(position.second).isEqualTo(windowDurationUs);
  // Should return (0, 0) without a position projection.
  position = timeline.getPeriodPosition(window, period, 0, C.TIME_UNSET, 0);
  assertThat(position.first).isEqualTo(timeline.getUidOfPeriod(0));
  assertThat(position.second).isEqualTo(0);
}