@Test
public void testChildSourceWithLazyPreparationOnlyPreparesSourceOnce() throws IOException {

  FakeMediaSource[] childSources = createMediaSources(/* count= */ 2);
  mediaSource =
      new ConcatenatingMediaSource(
          /* isAtomic= */ false,
          /* useLazyPreparation= */ true,
          new DefaultShuffleOrder(0),
          childSources);
  testRunner = new MediaSourceTestRunner(mediaSource, /* allocator= */ null);
  Timeline timeline = testRunner.prepareSource();
  // The lazy preparation must only be triggered once, even if we create multiple periods from
  // the media source. FakeMediaSource.prepareSource asserts that it's not called twice, so
  // creating two periods shouldn't throw.
  MediaPeriodId mediaPeriodId =
      new MediaPeriodId(
          timeline.getUidOfPeriod(/* periodIndex= */ 0), /* windowSequenceNumber= */ 0);
  testRunner.createPeriod(mediaPeriodId);
  testRunner.createPeriod(mediaPeriodId);
}