@Test
public void testDynamicChangeOfEmptyTimelines() throws IOException {

  FakeMediaSource[] childSources =
      new FakeMediaSource[] {
        new FakeMediaSource(Timeline.EMPTY),
        new FakeMediaSource(Timeline.EMPTY),
        new FakeMediaSource(Timeline.EMPTY),
      };
  Timeline nonEmptyTimeline = new FakeTimeline(/* windowCount = */ 1);
  mediaSource.addMediaSources(Arrays.asList(childSources));
  Timeline timeline = testRunner.prepareSource();
  TimelineAsserts.assertEmpty(timeline);
  childSources[0].setNewSourceInfo(nonEmptyTimeline, /* newManifest== */ null);
  timeline = testRunner.assertTimelineChangeBlocking();
  TimelineAsserts.assertPeriodCounts(timeline, 1);
  childSources[2].setNewSourceInfo(nonEmptyTimeline, /* newManifest== */ null);
  timeline = testRunner.assertTimelineChangeBlocking();
  TimelineAsserts.assertPeriodCounts(timeline, 1, 1);
  childSources[1].setNewSourceInfo(nonEmptyTimeline, /* newManifest== */ null);
  timeline = testRunner.assertTimelineChangeBlocking();
  TimelineAsserts.assertPeriodCounts(timeline, 1, 1, 1);
}