Commit 87e141d3 by tonihei Committed by Andrew Lewis

Remove boilerplate setting up FakeTimeline and FakeMediaSource.

In many cases it doesn't matter for the test itself how many windows
a timeline has, or even how the timeline of a MediaSource looks like.

And since we introduced the MediaItem-based APIs, single-window
Timelines are the only fully supported Timelines. Thus there is no
point in specifiying this explicitly.

Using these assumptions, we can remove some boilerplate when setting
up standard FakeTimelines or FakeMediaSources with a standard
FakeTimeline.

#exofixit

PiperOrigin-RevId: 344210395
parent b7047a24
...@@ -109,7 +109,6 @@ import com.google.android.exoplayer2.util.Clock; ...@@ -109,7 +109,6 @@ import com.google.android.exoplayer2.util.Clock;
import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.util.MimeTypes;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Range; import com.google.common.collect.Range;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -196,7 +195,7 @@ public final class ExoPlayerTest { ...@@ -196,7 +195,7 @@ public final class ExoPlayerTest {
/** Tests playback of a source that exposes a single period. */ /** Tests playback of a source that exposes a single period. */
@Test @Test
public void playSinglePeriodTimeline() throws Exception { public void playSinglePeriodTimeline() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
FakeRenderer renderer = new FakeRenderer(C.TRACK_TYPE_VIDEO); FakeRenderer renderer = new FakeRenderer(C.TRACK_TYPE_VIDEO);
SimpleExoPlayer player = new TestExoPlayerBuilder(context).setRenderers(renderer).build(); SimpleExoPlayer player = new TestExoPlayerBuilder(context).setRenderers(renderer).build();
EventListener mockEventListener = mock(EventListener.class); EventListener mockEventListener = mock(EventListener.class);
...@@ -391,8 +390,7 @@ public final class ExoPlayerTest { ...@@ -391,8 +390,7 @@ public final class ExoPlayerTest {
MediaSource firstSource = new FakeMediaSource(firstTimeline, ExoPlayerTestRunner.VIDEO_FORMAT); MediaSource firstSource = new FakeMediaSource(firstTimeline, ExoPlayerTestRunner.VIDEO_FORMAT);
AtomicBoolean secondSourcePrepared = new AtomicBoolean(); AtomicBoolean secondSourcePrepared = new AtomicBoolean();
MediaSource secondSource = MediaSource secondSource =
new FakeMediaSource( new FakeMediaSource(new FakeTimeline(), ExoPlayerTestRunner.VIDEO_FORMAT) {
new FakeTimeline(/* windowCount= */ 1), ExoPlayerTestRunner.VIDEO_FORMAT) {
@Override @Override
public synchronized void prepareSourceInternal( public synchronized void prepareSourceInternal(
@Nullable TransferListener mediaTransferListener) { @Nullable TransferListener mediaTransferListener) {
...@@ -400,7 +398,7 @@ public final class ExoPlayerTest { ...@@ -400,7 +398,7 @@ public final class ExoPlayerTest {
secondSourcePrepared.set(true); secondSourcePrepared.set(true);
} }
}; };
Timeline thirdTimeline = new FakeTimeline(/* windowCount= */ 1); Timeline thirdTimeline = new FakeTimeline();
MediaSource thirdSource = new FakeMediaSource(thirdTimeline, ExoPlayerTestRunner.VIDEO_FORMAT); MediaSource thirdSource = new FakeMediaSource(thirdTimeline, ExoPlayerTestRunner.VIDEO_FORMAT);
SimpleExoPlayer player = new TestExoPlayerBuilder(context).setRenderers(renderer).build(); SimpleExoPlayer player = new TestExoPlayerBuilder(context).setRenderers(renderer).build();
EventListener mockEventListener = mock(EventListener.class); EventListener mockEventListener = mock(EventListener.class);
...@@ -490,7 +488,7 @@ public final class ExoPlayerTest { ...@@ -490,7 +488,7 @@ public final class ExoPlayerTest {
@Test @Test
public void shuffleModeEnabledChanges() throws Exception { public void shuffleModeEnabledChanges() throws Exception {
Timeline fakeTimeline = new FakeTimeline(/* windowCount= */ 1); Timeline fakeTimeline = new FakeTimeline();
MediaSource[] fakeMediaSources = { MediaSource[] fakeMediaSources = {
new FakeMediaSource(fakeTimeline, ExoPlayerTestRunner.VIDEO_FORMAT), new FakeMediaSource(fakeTimeline, ExoPlayerTestRunner.VIDEO_FORMAT),
new FakeMediaSource(fakeTimeline, ExoPlayerTestRunner.VIDEO_FORMAT), new FakeMediaSource(fakeTimeline, ExoPlayerTestRunner.VIDEO_FORMAT),
...@@ -725,7 +723,7 @@ public final class ExoPlayerTest { ...@@ -725,7 +723,7 @@ public final class ExoPlayerTest {
@Test @Test
public void internalDiscontinuityAtInitialPosition() throws Exception { public void internalDiscontinuityAtInitialPosition() throws Exception {
FakeTimeline timeline = new FakeTimeline(/* windowCount= */ 1); FakeTimeline timeline = new FakeTimeline();
FakeMediaSource mediaSource = FakeMediaSource mediaSource =
new FakeMediaSource(timeline, ExoPlayerTestRunner.VIDEO_FORMAT) { new FakeMediaSource(timeline, ExoPlayerTestRunner.VIDEO_FORMAT) {
@Override @Override
...@@ -760,10 +758,9 @@ public final class ExoPlayerTest { ...@@ -760,10 +758,9 @@ public final class ExoPlayerTest {
@Test @Test
public void allActivatedTrackSelectionAreReleasedForSinglePeriod() throws Exception { public void allActivatedTrackSelectionAreReleasedForSinglePeriod() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1);
MediaSource mediaSource = MediaSource mediaSource =
new FakeMediaSource( new FakeMediaSource(
timeline, ExoPlayerTestRunner.VIDEO_FORMAT, ExoPlayerTestRunner.AUDIO_FORMAT); new FakeTimeline(), ExoPlayerTestRunner.VIDEO_FORMAT, ExoPlayerTestRunner.AUDIO_FORMAT);
FakeRenderer videoRenderer = new FakeRenderer(C.TRACK_TYPE_VIDEO); FakeRenderer videoRenderer = new FakeRenderer(C.TRACK_TYPE_VIDEO);
FakeRenderer audioRenderer = new FakeRenderer(C.TRACK_TYPE_AUDIO); FakeRenderer audioRenderer = new FakeRenderer(C.TRACK_TYPE_AUDIO);
FakeTrackSelector trackSelector = new FakeTrackSelector(); FakeTrackSelector trackSelector = new FakeTrackSelector();
...@@ -820,10 +817,9 @@ public final class ExoPlayerTest { ...@@ -820,10 +817,9 @@ public final class ExoPlayerTest {
@Test @Test
public void allActivatedTrackSelectionAreReleasedWhenTrackSelectionsAreRemade() throws Exception { public void allActivatedTrackSelectionAreReleasedWhenTrackSelectionsAreRemade() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1);
MediaSource mediaSource = MediaSource mediaSource =
new FakeMediaSource( new FakeMediaSource(
timeline, ExoPlayerTestRunner.VIDEO_FORMAT, ExoPlayerTestRunner.AUDIO_FORMAT); new FakeTimeline(), ExoPlayerTestRunner.VIDEO_FORMAT, ExoPlayerTestRunner.AUDIO_FORMAT);
FakeRenderer videoRenderer = new FakeRenderer(C.TRACK_TYPE_VIDEO); FakeRenderer videoRenderer = new FakeRenderer(C.TRACK_TYPE_VIDEO);
FakeRenderer audioRenderer = new FakeRenderer(C.TRACK_TYPE_AUDIO); FakeRenderer audioRenderer = new FakeRenderer(C.TRACK_TYPE_AUDIO);
final FakeTrackSelector trackSelector = new FakeTrackSelector(); final FakeTrackSelector trackSelector = new FakeTrackSelector();
...@@ -859,10 +855,9 @@ public final class ExoPlayerTest { ...@@ -859,10 +855,9 @@ public final class ExoPlayerTest {
@Test @Test
public void allActivatedTrackSelectionAreReleasedWhenTrackSelectionsAreReused() throws Exception { public void allActivatedTrackSelectionAreReleasedWhenTrackSelectionsAreReused() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1);
MediaSource mediaSource = MediaSource mediaSource =
new FakeMediaSource( new FakeMediaSource(
timeline, ExoPlayerTestRunner.VIDEO_FORMAT, ExoPlayerTestRunner.AUDIO_FORMAT); new FakeTimeline(), ExoPlayerTestRunner.VIDEO_FORMAT, ExoPlayerTestRunner.AUDIO_FORMAT);
FakeRenderer videoRenderer = new FakeRenderer(C.TRACK_TYPE_VIDEO); FakeRenderer videoRenderer = new FakeRenderer(C.TRACK_TYPE_VIDEO);
FakeRenderer audioRenderer = new FakeRenderer(C.TRACK_TYPE_AUDIO); FakeRenderer audioRenderer = new FakeRenderer(C.TRACK_TYPE_AUDIO);
final FakeTrackSelector trackSelector = final FakeTrackSelector trackSelector =
...@@ -976,8 +971,7 @@ public final class ExoPlayerTest { ...@@ -976,8 +971,7 @@ public final class ExoPlayerTest {
final CountDownLatch createPeriodCalledCountDownLatch = new CountDownLatch(1); final CountDownLatch createPeriodCalledCountDownLatch = new CountDownLatch(1);
final FakeMediaPeriod[] fakeMediaPeriodHolder = new FakeMediaPeriod[1]; final FakeMediaPeriod[] fakeMediaPeriodHolder = new FakeMediaPeriod[1];
MediaSource mediaSource = MediaSource mediaSource =
new FakeMediaSource( new FakeMediaSource(new FakeTimeline(), ExoPlayerTestRunner.VIDEO_FORMAT) {
new FakeTimeline(/* windowCount= */ 1), ExoPlayerTestRunner.VIDEO_FORMAT) {
@Override @Override
protected FakeMediaPeriod createFakeMediaPeriod( protected FakeMediaPeriod createFakeMediaPeriod(
MediaPeriodId id, MediaPeriodId id,
...@@ -1029,7 +1023,6 @@ public final class ExoPlayerTest { ...@@ -1029,7 +1023,6 @@ public final class ExoPlayerTest {
public void seekBeforePreparationCompletes_seeksToCorrectPosition() throws Exception { public void seekBeforePreparationCompletes_seeksToCorrectPosition() throws Exception {
CountDownLatch createPeriodCalledCountDownLatch = new CountDownLatch(1); CountDownLatch createPeriodCalledCountDownLatch = new CountDownLatch(1);
FakeMediaPeriod[] fakeMediaPeriodHolder = new FakeMediaPeriod[1]; FakeMediaPeriod[] fakeMediaPeriodHolder = new FakeMediaPeriod[1];
Timeline timeline = new FakeTimeline(/* windowCount= */ 1);
FakeMediaSource mediaSource = FakeMediaSource mediaSource =
new FakeMediaSource(/* timeline= */ null, ExoPlayerTestRunner.VIDEO_FORMAT) { new FakeMediaSource(/* timeline= */ null, ExoPlayerTestRunner.VIDEO_FORMAT) {
@Override @Override
...@@ -1061,7 +1054,7 @@ public final class ExoPlayerTest { ...@@ -1061,7 +1054,7 @@ public final class ExoPlayerTest {
.waitForPlaybackState(Player.STATE_BUFFERING) .waitForPlaybackState(Player.STATE_BUFFERING)
// Ensure we use the MaskingMediaPeriod by delaying the initial timeline update. // Ensure we use the MaskingMediaPeriod by delaying the initial timeline update.
.delay(1) .delay(1)
.executeRunnable(() -> mediaSource.setNewSourceInfo(timeline)) .executeRunnable(() -> mediaSource.setNewSourceInfo(new FakeTimeline()))
.waitForTimelineChanged() .waitForTimelineChanged()
// Block until createPeriod has been called on the fake media source. // Block until createPeriod has been called on the fake media source.
.executeRunnable( .executeRunnable(
...@@ -1099,13 +1092,12 @@ public final class ExoPlayerTest { ...@@ -1099,13 +1092,12 @@ public final class ExoPlayerTest {
@Test @Test
public void stop_withoutReset_doesNotResetPosition_correctMasking() throws Exception { public void stop_withoutReset_doesNotResetPosition_correctMasking() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1);
int[] currentWindowIndex = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; int[] currentWindowIndex = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET};
long[] currentPosition = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; long[] currentPosition = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET};
long[] bufferedPosition = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; long[] bufferedPosition = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET};
long[] totalBufferedDuration = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; long[] totalBufferedDuration = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET};
final FakeMediaSource mediaSource = final FakeMediaSource mediaSource =
new FakeMediaSource(timeline, ExoPlayerTestRunner.VIDEO_FORMAT); new FakeMediaSource(new FakeTimeline(), ExoPlayerTestRunner.VIDEO_FORMAT);
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
.pause() .pause()
...@@ -1170,7 +1162,7 @@ public final class ExoPlayerTest { ...@@ -1170,7 +1162,7 @@ public final class ExoPlayerTest {
@Test @Test
public void stop_withoutReset_releasesMediaSource() throws Exception { public void stop_withoutReset_releasesMediaSource() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
final FakeMediaSource mediaSource = final FakeMediaSource mediaSource =
new FakeMediaSource(timeline, ExoPlayerTestRunner.VIDEO_FORMAT); new FakeMediaSource(timeline, ExoPlayerTestRunner.VIDEO_FORMAT);
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
...@@ -1192,13 +1184,12 @@ public final class ExoPlayerTest { ...@@ -1192,13 +1184,12 @@ public final class ExoPlayerTest {
@Test @Test
public void stop_withReset_doesResetPosition_correctMasking() throws Exception { public void stop_withReset_doesResetPosition_correctMasking() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1);
int[] currentWindowIndex = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; int[] currentWindowIndex = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET};
long[] currentPosition = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; long[] currentPosition = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET};
long[] bufferedPosition = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; long[] bufferedPosition = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET};
long[] totalBufferedDuration = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; long[] totalBufferedDuration = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET};
final FakeMediaSource mediaSource = final FakeMediaSource mediaSource =
new FakeMediaSource(timeline, ExoPlayerTestRunner.VIDEO_FORMAT); new FakeMediaSource(new FakeTimeline(), ExoPlayerTestRunner.VIDEO_FORMAT);
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
.pause() .pause()
...@@ -1264,7 +1255,7 @@ public final class ExoPlayerTest { ...@@ -1264,7 +1255,7 @@ public final class ExoPlayerTest {
@Test @Test
public void stop_withReset_releasesMediaSource() throws Exception { public void stop_withReset_releasesMediaSource() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
final FakeMediaSource mediaSource = final FakeMediaSource mediaSource =
new FakeMediaSource(timeline, ExoPlayerTestRunner.VIDEO_FORMAT); new FakeMediaSource(timeline, ExoPlayerTestRunner.VIDEO_FORMAT);
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
...@@ -1286,13 +1277,12 @@ public final class ExoPlayerTest { ...@@ -1286,13 +1277,12 @@ public final class ExoPlayerTest {
@Test @Test
public void release_correctMasking() throws Exception { public void release_correctMasking() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1);
int[] currentWindowIndex = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; int[] currentWindowIndex = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET};
long[] currentPosition = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; long[] currentPosition = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET};
long[] bufferedPosition = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; long[] bufferedPosition = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET};
long[] totalBufferedDuration = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; long[] totalBufferedDuration = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET};
final FakeMediaSource mediaSource = final FakeMediaSource mediaSource =
new FakeMediaSource(timeline, ExoPlayerTestRunner.VIDEO_FORMAT); new FakeMediaSource(new FakeTimeline(), ExoPlayerTestRunner.VIDEO_FORMAT);
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
.pause() .pause()
...@@ -1351,7 +1341,7 @@ public final class ExoPlayerTest { ...@@ -1351,7 +1341,7 @@ public final class ExoPlayerTest {
@Test @Test
public void settingNewStartPositionPossibleAfterStopWithReset() throws Exception { public void settingNewStartPositionPossibleAfterStopWithReset() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
Timeline secondTimeline = new FakeTimeline(/* windowCount= */ 2); Timeline secondTimeline = new FakeTimeline(/* windowCount= */ 2);
MediaSource secondSource = MediaSource secondSource =
new FakeMediaSource(secondTimeline, ExoPlayerTestRunner.VIDEO_FORMAT); new FakeMediaSource(secondTimeline, ExoPlayerTestRunner.VIDEO_FORMAT);
...@@ -1577,7 +1567,6 @@ public final class ExoPlayerTest { ...@@ -1577,7 +1567,6 @@ public final class ExoPlayerTest {
@Test @Test
public void stopDuringPreparationOverwritesPreparation() throws Exception { public void stopDuringPreparationOverwritesPreparation() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1);
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
.waitForPlaybackState(Player.STATE_BUFFERING) .waitForPlaybackState(Player.STATE_BUFFERING)
...@@ -1586,7 +1575,7 @@ public final class ExoPlayerTest { ...@@ -1586,7 +1575,7 @@ public final class ExoPlayerTest {
.build(); .build();
ExoPlayerTestRunner testRunner = ExoPlayerTestRunner testRunner =
new ExoPlayerTestRunner.Builder(context) new ExoPlayerTestRunner.Builder(context)
.setTimeline(timeline) .setTimeline(new FakeTimeline())
.setActionSchedule(actionSchedule) .setActionSchedule(actionSchedule)
.build() .build()
.start() .start()
...@@ -1600,7 +1589,7 @@ public final class ExoPlayerTest { ...@@ -1600,7 +1589,7 @@ public final class ExoPlayerTest {
@Test @Test
public void stopAndSeekAfterStopDoesNotResetTimeline() throws Exception { public void stopAndSeekAfterStopDoesNotResetTimeline() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
.waitForPlaybackState(Player.STATE_READY) .waitForPlaybackState(Player.STATE_READY)
...@@ -1626,7 +1615,7 @@ public final class ExoPlayerTest { ...@@ -1626,7 +1615,7 @@ public final class ExoPlayerTest {
@Test @Test
public void reprepareAfterPlaybackError() throws Exception { public void reprepareAfterPlaybackError() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
.waitForPlaybackState(Player.STATE_READY) .waitForPlaybackState(Player.STATE_READY)
...@@ -1654,7 +1643,7 @@ public final class ExoPlayerTest { ...@@ -1654,7 +1643,7 @@ public final class ExoPlayerTest {
@Test @Test
public void seekAndReprepareAfterPlaybackError() throws Exception { public void seekAndReprepareAfterPlaybackError() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
final long[] positionHolder = new long[2]; final long[] positionHolder = new long[2];
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
...@@ -1741,8 +1730,6 @@ public final class ExoPlayerTest { ...@@ -1741,8 +1730,6 @@ public final class ExoPlayerTest {
@Test @Test
public void restartAfterEmptyTimelineWithShuffleModeEnabledUsesCorrectFirstPeriod() public void restartAfterEmptyTimelineWithShuffleModeEnabledUsesCorrectFirstPeriod()
throws Exception { throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1);
FakeMediaSource mediaSource = new FakeMediaSource(timeline);
ConcatenatingMediaSource concatenatingMediaSource = ConcatenatingMediaSource concatenatingMediaSource =
new ConcatenatingMediaSource(/* isAtomic= */ false, new FakeShuffleOrder(0)); new ConcatenatingMediaSource(/* isAtomic= */ false, new FakeShuffleOrder(0));
AtomicInteger windowIndexAfterAddingSources = new AtomicInteger(); AtomicInteger windowIndexAfterAddingSources = new AtomicInteger();
...@@ -1756,7 +1743,7 @@ public final class ExoPlayerTest { ...@@ -1756,7 +1743,7 @@ public final class ExoPlayerTest {
.executeRunnable( .executeRunnable(
() -> () ->
concatenatingMediaSource.addMediaSources( concatenatingMediaSource.addMediaSources(
Arrays.asList(mediaSource, mediaSource))) ImmutableList.of(new FakeMediaSource(), new FakeMediaSource())))
.waitForTimelineChanged() .waitForTimelineChanged()
.executeRunnable( .executeRunnable(
new PlayerRunnable() { new PlayerRunnable() {
...@@ -1908,7 +1895,6 @@ public final class ExoPlayerTest { ...@@ -1908,7 +1895,6 @@ public final class ExoPlayerTest {
@Test @Test
public void playbackErrorAndReprepareWithPositionResetKeepsWindowSequenceNumber() public void playbackErrorAndReprepareWithPositionResetKeepsWindowSequenceNumber()
throws Exception { throws Exception {
FakeMediaSource mediaSource = new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1));
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
.pause() .pause()
...@@ -1942,7 +1928,6 @@ public final class ExoPlayerTest { ...@@ -1942,7 +1928,6 @@ public final class ExoPlayerTest {
}; };
ExoPlayerTestRunner testRunner = ExoPlayerTestRunner testRunner =
new ExoPlayerTestRunner.Builder(context) new ExoPlayerTestRunner.Builder(context)
.setMediaSources(mediaSource)
.setActionSchedule(actionSchedule) .setActionSchedule(actionSchedule)
.setAnalyticsListener(listener) .setAnalyticsListener(listener)
.build(); .build();
...@@ -1957,7 +1942,7 @@ public final class ExoPlayerTest { ...@@ -1957,7 +1942,7 @@ public final class ExoPlayerTest {
@Test @Test
public void playbackErrorTwiceStillKeepsTimeline() throws Exception { public void playbackErrorTwiceStillKeepsTimeline() throws Exception {
final Timeline timeline = new FakeTimeline(/* windowCount= */ 1); final Timeline timeline = new FakeTimeline();
final FakeMediaSource mediaSource2 = new FakeMediaSource(timeline); final FakeMediaSource mediaSource2 = new FakeMediaSource(timeline);
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
...@@ -1993,7 +1978,6 @@ public final class ExoPlayerTest { ...@@ -1993,7 +1978,6 @@ public final class ExoPlayerTest {
@Test @Test
public void sendMessagesDuringPreparation() throws Exception { public void sendMessagesDuringPreparation() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1);
PositionGrabbingMessageTarget target = new PositionGrabbingMessageTarget(); PositionGrabbingMessageTarget target = new PositionGrabbingMessageTarget();
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
...@@ -2003,7 +1987,6 @@ public final class ExoPlayerTest { ...@@ -2003,7 +1987,6 @@ public final class ExoPlayerTest {
.play() .play()
.build(); .build();
new ExoPlayerTestRunner.Builder(context) new ExoPlayerTestRunner.Builder(context)
.setTimeline(timeline)
.setActionSchedule(actionSchedule) .setActionSchedule(actionSchedule)
.build() .build()
.start() .start()
...@@ -2013,7 +1996,7 @@ public final class ExoPlayerTest { ...@@ -2013,7 +1996,7 @@ public final class ExoPlayerTest {
@Test @Test
public void sendMessagesAfterPreparation() throws Exception { public void sendMessagesAfterPreparation() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
PositionGrabbingMessageTarget target = new PositionGrabbingMessageTarget(); PositionGrabbingMessageTarget target = new PositionGrabbingMessageTarget();
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
...@@ -2034,7 +2017,6 @@ public final class ExoPlayerTest { ...@@ -2034,7 +2017,6 @@ public final class ExoPlayerTest {
@Test @Test
public void multipleSendMessages() throws Exception { public void multipleSendMessages() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1);
PositionGrabbingMessageTarget target50 = new PositionGrabbingMessageTarget(); PositionGrabbingMessageTarget target50 = new PositionGrabbingMessageTarget();
PositionGrabbingMessageTarget target80 = new PositionGrabbingMessageTarget(); PositionGrabbingMessageTarget target80 = new PositionGrabbingMessageTarget();
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
...@@ -2046,7 +2028,6 @@ public final class ExoPlayerTest { ...@@ -2046,7 +2028,6 @@ public final class ExoPlayerTest {
.play() .play()
.build(); .build();
new ExoPlayerTestRunner.Builder(context) new ExoPlayerTestRunner.Builder(context)
.setTimeline(timeline)
.setActionSchedule(actionSchedule) .setActionSchedule(actionSchedule)
.build() .build()
.start() .start()
...@@ -2058,7 +2039,6 @@ public final class ExoPlayerTest { ...@@ -2058,7 +2039,6 @@ public final class ExoPlayerTest {
@Test @Test
public void sendMessagesFromStartPositionOnlyOnce() throws Exception { public void sendMessagesFromStartPositionOnlyOnce() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1);
AtomicInteger counter = new AtomicInteger(); AtomicInteger counter = new AtomicInteger();
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
...@@ -2074,7 +2054,6 @@ public final class ExoPlayerTest { ...@@ -2074,7 +2054,6 @@ public final class ExoPlayerTest {
.play() .play()
.build(); .build();
new ExoPlayerTestRunner.Builder(context) new ExoPlayerTestRunner.Builder(context)
.setTimeline(timeline)
.setActionSchedule(actionSchedule) .setActionSchedule(actionSchedule)
.build() .build()
.start() .start()
...@@ -2085,7 +2064,6 @@ public final class ExoPlayerTest { ...@@ -2085,7 +2064,6 @@ public final class ExoPlayerTest {
@Test @Test
public void multipleSendMessagesAtSameTime() throws Exception { public void multipleSendMessagesAtSameTime() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1);
PositionGrabbingMessageTarget target1 = new PositionGrabbingMessageTarget(); PositionGrabbingMessageTarget target1 = new PositionGrabbingMessageTarget();
PositionGrabbingMessageTarget target2 = new PositionGrabbingMessageTarget(); PositionGrabbingMessageTarget target2 = new PositionGrabbingMessageTarget();
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
...@@ -2097,7 +2075,6 @@ public final class ExoPlayerTest { ...@@ -2097,7 +2075,6 @@ public final class ExoPlayerTest {
.play() .play()
.build(); .build();
new ExoPlayerTestRunner.Builder(context) new ExoPlayerTestRunner.Builder(context)
.setTimeline(timeline)
.setActionSchedule(actionSchedule) .setActionSchedule(actionSchedule)
.build() .build()
.start() .start()
...@@ -2190,7 +2167,6 @@ public final class ExoPlayerTest { ...@@ -2190,7 +2167,6 @@ public final class ExoPlayerTest {
@Test @Test
public void sendMessagesSeekOnDeliveryTimeDuringPreparation() throws Exception { public void sendMessagesSeekOnDeliveryTimeDuringPreparation() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1);
PositionGrabbingMessageTarget target = new PositionGrabbingMessageTarget(); PositionGrabbingMessageTarget target = new PositionGrabbingMessageTarget();
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
...@@ -2199,7 +2175,6 @@ public final class ExoPlayerTest { ...@@ -2199,7 +2175,6 @@ public final class ExoPlayerTest {
.seek(/* positionMs= */ 50) .seek(/* positionMs= */ 50)
.build(); .build();
new ExoPlayerTestRunner.Builder(context) new ExoPlayerTestRunner.Builder(context)
.setTimeline(timeline)
.setActionSchedule(actionSchedule) .setActionSchedule(actionSchedule)
.build() .build()
.start() .start()
...@@ -2209,7 +2184,7 @@ public final class ExoPlayerTest { ...@@ -2209,7 +2184,7 @@ public final class ExoPlayerTest {
@Test @Test
public void sendMessagesSeekOnDeliveryTimeAfterPreparation() throws Exception { public void sendMessagesSeekOnDeliveryTimeAfterPreparation() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
PositionGrabbingMessageTarget target = new PositionGrabbingMessageTarget(); PositionGrabbingMessageTarget target = new PositionGrabbingMessageTarget();
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
...@@ -2230,7 +2205,6 @@ public final class ExoPlayerTest { ...@@ -2230,7 +2205,6 @@ public final class ExoPlayerTest {
@Test @Test
public void sendMessagesSeekAfterDeliveryTimeDuringPreparation() throws Exception { public void sendMessagesSeekAfterDeliveryTimeDuringPreparation() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1);
PositionGrabbingMessageTarget target = new PositionGrabbingMessageTarget(); PositionGrabbingMessageTarget target = new PositionGrabbingMessageTarget();
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
...@@ -2241,7 +2215,6 @@ public final class ExoPlayerTest { ...@@ -2241,7 +2215,6 @@ public final class ExoPlayerTest {
.play() .play()
.build(); .build();
new ExoPlayerTestRunner.Builder(context) new ExoPlayerTestRunner.Builder(context)
.setTimeline(timeline)
.setActionSchedule(actionSchedule) .setActionSchedule(actionSchedule)
.build() .build()
.start() .start()
...@@ -2251,7 +2224,7 @@ public final class ExoPlayerTest { ...@@ -2251,7 +2224,7 @@ public final class ExoPlayerTest {
@Test @Test
public void sendMessagesSeekAfterDeliveryTimeAfterPreparation() throws Exception { public void sendMessagesSeekAfterDeliveryTimeAfterPreparation() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
PositionGrabbingMessageTarget target = new PositionGrabbingMessageTarget(); PositionGrabbingMessageTarget target = new PositionGrabbingMessageTarget();
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
...@@ -2273,7 +2246,6 @@ public final class ExoPlayerTest { ...@@ -2273,7 +2246,6 @@ public final class ExoPlayerTest {
@Test @Test
public void sendMessagesRepeatDoesNotRepost() throws Exception { public void sendMessagesRepeatDoesNotRepost() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1);
PositionGrabbingMessageTarget target = new PositionGrabbingMessageTarget(); PositionGrabbingMessageTarget target = new PositionGrabbingMessageTarget();
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
...@@ -2286,7 +2258,6 @@ public final class ExoPlayerTest { ...@@ -2286,7 +2258,6 @@ public final class ExoPlayerTest {
.setRepeatMode(Player.REPEAT_MODE_OFF) .setRepeatMode(Player.REPEAT_MODE_OFF)
.build(); .build();
new ExoPlayerTestRunner.Builder(context) new ExoPlayerTestRunner.Builder(context)
.setTimeline(timeline)
.setActionSchedule(actionSchedule) .setActionSchedule(actionSchedule)
.build() .build()
.start() .start()
...@@ -2297,7 +2268,6 @@ public final class ExoPlayerTest { ...@@ -2297,7 +2268,6 @@ public final class ExoPlayerTest {
@Test @Test
public void sendMessagesRepeatWithoutDeletingDoesRepost() throws Exception { public void sendMessagesRepeatWithoutDeletingDoesRepost() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1);
PositionGrabbingMessageTarget target = new PositionGrabbingMessageTarget(); PositionGrabbingMessageTarget target = new PositionGrabbingMessageTarget();
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
...@@ -2315,7 +2285,6 @@ public final class ExoPlayerTest { ...@@ -2315,7 +2285,6 @@ public final class ExoPlayerTest {
.play() .play()
.build(); .build();
new ExoPlayerTestRunner.Builder(context) new ExoPlayerTestRunner.Builder(context)
.setTimeline(timeline)
.setActionSchedule(actionSchedule) .setActionSchedule(actionSchedule)
.build() .build()
.start() .start()
...@@ -2436,7 +2405,7 @@ public final class ExoPlayerTest { ...@@ -2436,7 +2405,7 @@ public final class ExoPlayerTest {
@Test @Test
public void sendMessagesNonLinearPeriodOrder() throws Exception { public void sendMessagesNonLinearPeriodOrder() throws Exception {
Timeline fakeTimeline = new FakeTimeline(/* windowCount= */ 1); Timeline fakeTimeline = new FakeTimeline();
MediaSource[] fakeMediaSources = { MediaSource[] fakeMediaSources = {
new FakeMediaSource(fakeTimeline, ExoPlayerTestRunner.VIDEO_FORMAT), new FakeMediaSource(fakeTimeline, ExoPlayerTestRunner.VIDEO_FORMAT),
new FakeMediaSource(fakeTimeline, ExoPlayerTestRunner.VIDEO_FORMAT), new FakeMediaSource(fakeTimeline, ExoPlayerTestRunner.VIDEO_FORMAT),
...@@ -2471,7 +2440,6 @@ public final class ExoPlayerTest { ...@@ -2471,7 +2440,6 @@ public final class ExoPlayerTest {
@Test @Test
public void cancelMessageBeforeDelivery() throws Exception { public void cancelMessageBeforeDelivery() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1);
final PositionGrabbingMessageTarget target = new PositionGrabbingMessageTarget(); final PositionGrabbingMessageTarget target = new PositionGrabbingMessageTarget();
final AtomicReference<PlayerMessage> message = new AtomicReference<>(); final AtomicReference<PlayerMessage> message = new AtomicReference<>();
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
...@@ -2492,7 +2460,6 @@ public final class ExoPlayerTest { ...@@ -2492,7 +2460,6 @@ public final class ExoPlayerTest {
.play() .play()
.build(); .build();
new ExoPlayerTestRunner.Builder(context) new ExoPlayerTestRunner.Builder(context)
.setTimeline(timeline)
.setActionSchedule(actionSchedule) .setActionSchedule(actionSchedule)
.build() .build()
.start() .start()
...@@ -2503,7 +2470,6 @@ public final class ExoPlayerTest { ...@@ -2503,7 +2470,6 @@ public final class ExoPlayerTest {
@Test @Test
public void cancelRepeatedMessageAfterDelivery() throws Exception { public void cancelRepeatedMessageAfterDelivery() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1);
final CountingMessageTarget target = new CountingMessageTarget(); final CountingMessageTarget target = new CountingMessageTarget();
final AtomicReference<PlayerMessage> message = new AtomicReference<>(); final AtomicReference<PlayerMessage> message = new AtomicReference<>();
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
...@@ -2530,7 +2496,6 @@ public final class ExoPlayerTest { ...@@ -2530,7 +2496,6 @@ public final class ExoPlayerTest {
.play() .play()
.build(); .build();
new ExoPlayerTestRunner.Builder(context) new ExoPlayerTestRunner.Builder(context)
.setTimeline(timeline)
.setActionSchedule(actionSchedule) .setActionSchedule(actionSchedule)
.build() .build()
.start() .start()
...@@ -2543,8 +2508,7 @@ public final class ExoPlayerTest { ...@@ -2543,8 +2508,7 @@ public final class ExoPlayerTest {
public void sendMessages_withMediaRemoval_triggersCorrectMessagesAndDoesNotThrow() public void sendMessages_withMediaRemoval_triggersCorrectMessagesAndDoesNotThrow()
throws Exception { throws Exception {
ExoPlayer player = new TestExoPlayerBuilder(context).build(); ExoPlayer player = new TestExoPlayerBuilder(context).build();
MediaSource mediaSource = new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)); player.addMediaSources(ImmutableList.of(new FakeMediaSource(), new FakeMediaSource()));
player.addMediaSources(Arrays.asList(mediaSource, mediaSource));
player player
.createMessage((messageType, payload) -> {}) .createMessage((messageType, payload) -> {})
.setPosition(/* windowIndex= */ 0, /* positionMs= */ 0) .setPosition(/* windowIndex= */ 0, /* positionMs= */ 0)
...@@ -2761,7 +2725,7 @@ public final class ExoPlayerTest { ...@@ -2761,7 +2725,7 @@ public final class ExoPlayerTest {
@Test @Test
public void invalidSeekFallsBackToSubsequentPeriodOfTheRemovedPeriod() throws Exception { public void invalidSeekFallsBackToSubsequentPeriodOfTheRemovedPeriod() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
CountDownLatch sourceReleasedCountDownLatch = new CountDownLatch(/* count= */ 1); CountDownLatch sourceReleasedCountDownLatch = new CountDownLatch(/* count= */ 1);
MediaSource mediaSourceToRemove = MediaSource mediaSourceToRemove =
new FakeMediaSource(timeline) { new FakeMediaSource(timeline) {
...@@ -2992,9 +2956,7 @@ public final class ExoPlayerTest { ...@@ -2992,9 +2956,7 @@ public final class ExoPlayerTest {
long expectedDurationUs = 700_000; long expectedDurationUs = 700_000;
MediaSource mediaSource = MediaSource mediaSource =
new ClippingMediaSource( new ClippingMediaSource(
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)), new FakeMediaSource(), startPositionUs, startPositionUs + expectedDurationUs);
startPositionUs,
startPositionUs + expectedDurationUs);
Clock clock = new AutoAdvancingFakeClock(); Clock clock = new AutoAdvancingFakeClock();
AtomicReference<Player> playerReference = new AtomicReference<>(); AtomicReference<Player> playerReference = new AtomicReference<>();
AtomicLong positionAtDiscontinuityMs = new AtomicLong(C.TIME_UNSET); AtomicLong positionAtDiscontinuityMs = new AtomicLong(C.TIME_UNSET);
...@@ -3057,7 +3019,7 @@ public final class ExoPlayerTest { ...@@ -3057,7 +3019,7 @@ public final class ExoPlayerTest {
new FakeTimeline( new FakeTimeline(
new TimelineWindowDefinition( new TimelineWindowDefinition(
/* isSeekable= */ true, /* isDynamic= */ false, /* durationUs= */ C.TIME_UNSET)); /* isSeekable= */ true, /* isDynamic= */ false, /* durationUs= */ C.TIME_UNSET));
Timeline timelineSetDuration = new FakeTimeline(/* windowCount= */ 1); Timeline timelineSetDuration = new FakeTimeline();
MediaSource mediaSource = MediaSource mediaSource =
new ConcatenatingMediaSource( new ConcatenatingMediaSource(
new FakeMediaSource(timelineUnsetDuration, ExoPlayerTestRunner.VIDEO_FORMAT), new FakeMediaSource(timelineUnsetDuration, ExoPlayerTestRunner.VIDEO_FORMAT),
...@@ -3131,7 +3093,6 @@ public final class ExoPlayerTest { ...@@ -3131,7 +3093,6 @@ public final class ExoPlayerTest {
@Test @Test
public void seekToUnpreparedWindowWithNonZeroOffsetInConcatenationStartsAtCorrectPosition() public void seekToUnpreparedWindowWithNonZeroOffsetInConcatenationStartsAtCorrectPosition()
throws Exception { throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1);
FakeMediaSource mediaSource = new FakeMediaSource(/* timeline= */ null); FakeMediaSource mediaSource = new FakeMediaSource(/* timeline= */ null);
MediaSource clippedMediaSource = MediaSource clippedMediaSource =
new ClippingMediaSource( new ClippingMediaSource(
...@@ -3148,7 +3109,7 @@ public final class ExoPlayerTest { ...@@ -3148,7 +3109,7 @@ public final class ExoPlayerTest {
.seek(/* positionMs= */ 10) .seek(/* positionMs= */ 10)
.waitForPendingPlayerCommands() .waitForPendingPlayerCommands()
// Finish preparation. // Finish preparation.
.executeRunnable(() -> mediaSource.setNewSourceInfo(timeline)) .executeRunnable(() -> mediaSource.setNewSourceInfo(new FakeTimeline()))
.waitForTimelineChanged() .waitForTimelineChanged()
.waitForPlaybackState(Player.STATE_READY) .waitForPlaybackState(Player.STATE_READY)
.executeRunnable( .executeRunnable(
...@@ -3619,7 +3580,7 @@ public final class ExoPlayerTest { ...@@ -3619,7 +3580,7 @@ public final class ExoPlayerTest {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Test @Test
public void seekTo_windowIndexIsReset_deprecated() throws Exception { public void seekTo_windowIndexIsReset_deprecated() throws Exception {
FakeTimeline fakeTimeline = new FakeTimeline(/* windowCount= */ 1); FakeTimeline fakeTimeline = new FakeTimeline();
FakeMediaSource mediaSource = new FakeMediaSource(fakeTimeline); FakeMediaSource mediaSource = new FakeMediaSource(fakeTimeline);
LoopingMediaSource loopingMediaSource = new LoopingMediaSource(mediaSource, 2); LoopingMediaSource loopingMediaSource = new LoopingMediaSource(mediaSource, 2);
final int[] windowIndex = {C.INDEX_UNSET}; final int[] windowIndex = {C.INDEX_UNSET};
...@@ -3673,7 +3634,7 @@ public final class ExoPlayerTest { ...@@ -3673,7 +3634,7 @@ public final class ExoPlayerTest {
@Test @Test
public void seekTo_windowIndexIsReset() throws Exception { public void seekTo_windowIndexIsReset() throws Exception {
FakeTimeline fakeTimeline = new FakeTimeline(/* windowCount= */ 1); FakeTimeline fakeTimeline = new FakeTimeline();
FakeMediaSource mediaSource = new FakeMediaSource(fakeTimeline); FakeMediaSource mediaSource = new FakeMediaSource(fakeTimeline);
LoopingMediaSource loopingMediaSource = new LoopingMediaSource(mediaSource, 2); LoopingMediaSource loopingMediaSource = new LoopingMediaSource(mediaSource, 2);
final int[] windowIndex = {C.INDEX_UNSET}; final int[] windowIndex = {C.INDEX_UNSET};
...@@ -3835,8 +3796,8 @@ public final class ExoPlayerTest { ...@@ -3835,8 +3796,8 @@ public final class ExoPlayerTest {
positionMs, positionMs,
bufferedPositions, bufferedPositions,
totalBufferedDuration, totalBufferedDuration,
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)), new FakeMediaSource(),
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)), new FakeMediaSource(),
createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 9200)); createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 9200));
assertThat(windowIndex[0]).isEqualTo(0); assertThat(windowIndex[0]).isEqualTo(0);
...@@ -3864,8 +3825,8 @@ public final class ExoPlayerTest { ...@@ -3864,8 +3825,8 @@ public final class ExoPlayerTest {
positionMs, positionMs,
bufferedPositions, bufferedPositions,
totalBufferedDuration, totalBufferedDuration,
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)), new FakeMediaSource(),
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)), new FakeMediaSource(),
createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 0)); createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 0));
assertThat(windowIndex[0]).isEqualTo(2); assertThat(windowIndex[0]).isEqualTo(2);
...@@ -3898,8 +3859,8 @@ public final class ExoPlayerTest { ...@@ -3898,8 +3859,8 @@ public final class ExoPlayerTest {
positionMs, positionMs,
bufferedPositions, bufferedPositions,
totalBufferedDuration, totalBufferedDuration,
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)), new FakeMediaSource(),
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1))); new FakeMediaSource());
assertThat(windowIndex[0]).isEqualTo(1); assertThat(windowIndex[0]).isEqualTo(1);
assertThat(positionMs[0]).isEqualTo(1000); assertThat(positionMs[0]).isEqualTo(1000);
...@@ -3934,7 +3895,7 @@ public final class ExoPlayerTest { ...@@ -3934,7 +3895,7 @@ public final class ExoPlayerTest {
positionMs, positionMs,
bufferedPositions, bufferedPositions,
totalBufferedDuration, totalBufferedDuration,
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)), new FakeMediaSource(),
createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 4000)); createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 4000));
assertThat(windowIndex[0]).isEqualTo(1); assertThat(windowIndex[0]).isEqualTo(1);
...@@ -3969,7 +3930,7 @@ public final class ExoPlayerTest { ...@@ -3969,7 +3930,7 @@ public final class ExoPlayerTest {
positionMs, positionMs,
bufferedPositions, bufferedPositions,
totalBufferedDuration, totalBufferedDuration,
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)), new FakeMediaSource(),
createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 4000)); createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 4000));
assertThat(windowIndex[0]).isEqualTo(1); assertThat(windowIndex[0]).isEqualTo(1);
...@@ -4002,8 +3963,8 @@ public final class ExoPlayerTest { ...@@ -4002,8 +3963,8 @@ public final class ExoPlayerTest {
positionMs, positionMs,
bufferedPositions, bufferedPositions,
totalBufferedDuration, totalBufferedDuration,
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)), new FakeMediaSource(),
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)), new FakeMediaSource(),
createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 4000)); createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 4000));
assertThat(windowIndex[0]).isEqualTo(1); assertThat(windowIndex[0]).isEqualTo(1);
...@@ -4039,7 +4000,7 @@ public final class ExoPlayerTest { ...@@ -4039,7 +4000,7 @@ public final class ExoPlayerTest {
positionMs, positionMs,
bufferedPositions, bufferedPositions,
totalBufferedDuration, totalBufferedDuration,
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)), new FakeMediaSource(),
createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 4000)); createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 4000));
assertThat(windowIndex[0]).isEqualTo(0); assertThat(windowIndex[0]).isEqualTo(0);
...@@ -4072,8 +4033,8 @@ public final class ExoPlayerTest { ...@@ -4072,8 +4033,8 @@ public final class ExoPlayerTest {
positionMs, positionMs,
bufferedPositions, bufferedPositions,
totalBufferedDuration, totalBufferedDuration,
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)), new FakeMediaSource(),
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)), new FakeMediaSource(),
createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 4000)); createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 4000));
assertThat(windowIndex[0]).isEqualTo(0); assertThat(windowIndex[0]).isEqualTo(0);
...@@ -4106,8 +4067,8 @@ public final class ExoPlayerTest { ...@@ -4106,8 +4067,8 @@ public final class ExoPlayerTest {
positionMs, positionMs,
bufferedPositions, bufferedPositions,
totalBufferedDuration, totalBufferedDuration,
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)), new FakeMediaSource(),
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)), new FakeMediaSource(),
createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 4000), createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 4000),
createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 0)); createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 0));
...@@ -4141,7 +4102,7 @@ public final class ExoPlayerTest { ...@@ -4141,7 +4102,7 @@ public final class ExoPlayerTest {
positionMs, positionMs,
bufferedPositions, bufferedPositions,
totalBufferedDuration, totalBufferedDuration,
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)), new FakeMediaSource(),
createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 4000)); createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 4000));
assertThat(windowIndex[0]).isEqualTo(0); assertThat(windowIndex[0]).isEqualTo(0);
...@@ -4176,8 +4137,8 @@ public final class ExoPlayerTest { ...@@ -4176,8 +4137,8 @@ public final class ExoPlayerTest {
positionMs, positionMs,
bufferedPositions, bufferedPositions,
totalBufferedDuration, totalBufferedDuration,
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)), new FakeMediaSource(),
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)), new FakeMediaSource(),
createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 4000)); createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 4000));
assertThat(windowIndex[0]).isEqualTo(0); assertThat(windowIndex[0]).isEqualTo(0);
...@@ -4211,8 +4172,8 @@ public final class ExoPlayerTest { ...@@ -4211,8 +4172,8 @@ public final class ExoPlayerTest {
positionMs, positionMs,
bufferedPositions, bufferedPositions,
totalBufferedDuration, totalBufferedDuration,
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)), new FakeMediaSource(),
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)), new FakeMediaSource(),
createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 4000)); createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 4000));
assertThat(windowIndex[0]).isEqualTo(0); assertThat(windowIndex[0]).isEqualTo(0);
...@@ -4245,8 +4206,8 @@ public final class ExoPlayerTest { ...@@ -4245,8 +4206,8 @@ public final class ExoPlayerTest {
positionMs, positionMs,
bufferedPositions, bufferedPositions,
totalBufferedDuration, totalBufferedDuration,
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)), new FakeMediaSource(),
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)), new FakeMediaSource(),
createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 4000)); createPartiallyBufferedMediaSource(/* maxBufferedPositionMs= */ 4000));
assertThat(windowIndex[0]).isEqualTo(0); assertThat(windowIndex[0]).isEqualTo(0);
...@@ -4384,9 +4345,7 @@ public final class ExoPlayerTest { ...@@ -4384,9 +4345,7 @@ public final class ExoPlayerTest {
new PlayerRunnable() { new PlayerRunnable() {
@Override @Override
public void run(SimpleExoPlayer player) { public void run(SimpleExoPlayer player) {
player.addMediaSource( player.addMediaSource(/* index= */ 1, new FakeMediaSource());
/* index= */ 1,
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)));
windowIndex[0] = player.getCurrentWindowIndex(); windowIndex[0] = player.getCurrentWindowIndex();
isPlayingAd[0] = player.isPlayingAd(); isPlayingAd[0] = player.isPlayingAd();
positionMs[0] = player.getCurrentPosition(); positionMs[0] = player.getCurrentPosition();
...@@ -4412,8 +4371,7 @@ public final class ExoPlayerTest { ...@@ -4412,8 +4371,7 @@ public final class ExoPlayerTest {
new PlayerRunnable() { new PlayerRunnable() {
@Override @Override
public void run(SimpleExoPlayer player) { public void run(SimpleExoPlayer player) {
player.addMediaSource( player.addMediaSource(new FakeMediaSource());
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)));
windowIndex[2] = player.getCurrentWindowIndex(); windowIndex[2] = player.getCurrentWindowIndex();
isPlayingAd[2] = player.isPlayingAd(); isPlayingAd[2] = player.isPlayingAd();
positionMs[2] = player.getCurrentPosition(); positionMs[2] = player.getCurrentPosition();
...@@ -4425,8 +4383,7 @@ public final class ExoPlayerTest { ...@@ -4425,8 +4383,7 @@ public final class ExoPlayerTest {
.build(); .build();
new ExoPlayerTestRunner.Builder(context) new ExoPlayerTestRunner.Builder(context)
.setMediaSources( .setMediaSources(adsMediaSource, new FakeMediaSource())
adsMediaSource, new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)))
.setActionSchedule(actionSchedule) .setActionSchedule(actionSchedule)
.build() .build()
.start() .start()
...@@ -4622,7 +4579,7 @@ public final class ExoPlayerTest { ...@@ -4622,7 +4579,7 @@ public final class ExoPlayerTest {
/* chunkDurationUs= */ 500_000, /* bitratePercentStdDev= */ 10.0); /* chunkDurationUs= */ 500_000, /* bitratePercentStdDev= */ 10.0);
MediaSource chunkedMediaSource = MediaSource chunkedMediaSource =
new FakeAdaptiveMediaSource( new FakeAdaptiveMediaSource(
new FakeTimeline(/* windowCount= */ 1), new FakeTimeline(),
new TrackGroupArray(new TrackGroup(ExoPlayerTestRunner.VIDEO_FORMAT)), new TrackGroupArray(new TrackGroup(ExoPlayerTestRunner.VIDEO_FORMAT)),
new FakeChunkSource.Factory(dataSetFactory, new FakeDataSource.Factory())); new FakeChunkSource.Factory(dataSetFactory, new FakeDataSource.Factory()));
...@@ -4663,8 +4620,7 @@ public final class ExoPlayerTest { ...@@ -4663,8 +4620,7 @@ public final class ExoPlayerTest {
} }
}; };
MediaSource mediaSourceWithLoadInProgress = MediaSource mediaSourceWithLoadInProgress =
new FakeMediaSource( new FakeMediaSource(new FakeTimeline(), ExoPlayerTestRunner.VIDEO_FORMAT) {
new FakeTimeline(/* windowCount= */ 1), ExoPlayerTestRunner.VIDEO_FORMAT) {
@Override @Override
protected FakeMediaPeriod createFakeMediaPeriod( protected FakeMediaPeriod createFakeMediaPeriod(
MediaPeriodId id, MediaPeriodId id,
...@@ -4747,7 +4703,7 @@ public final class ExoPlayerTest { ...@@ -4747,7 +4703,7 @@ public final class ExoPlayerTest {
/* chunkDurationUs= */ 500_000, /* bitratePercentStdDev= */ 10.0); /* chunkDurationUs= */ 500_000, /* bitratePercentStdDev= */ 10.0);
MediaSource chunkedMediaSource = MediaSource chunkedMediaSource =
new FakeAdaptiveMediaSource( new FakeAdaptiveMediaSource(
new FakeTimeline(/* windowCount= */ 1), new FakeTimeline(),
new TrackGroupArray(new TrackGroup(ExoPlayerTestRunner.VIDEO_FORMAT)), new TrackGroupArray(new TrackGroup(ExoPlayerTestRunner.VIDEO_FORMAT)),
new FakeChunkSource.Factory(dataSetFactory, new FakeDataSource.Factory())); new FakeChunkSource.Factory(dataSetFactory, new FakeDataSource.Factory()));
...@@ -4931,7 +4887,7 @@ public final class ExoPlayerTest { ...@@ -4931,7 +4887,7 @@ public final class ExoPlayerTest {
@Test @Test
public void clearMediaItems() throws Exception { public void clearMediaItems() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
.waitForTimelineChanged(timeline, Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE) .waitForTimelineChanged(timeline, Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE)
...@@ -4959,7 +4915,7 @@ public final class ExoPlayerTest { ...@@ -4959,7 +4915,7 @@ public final class ExoPlayerTest {
@Test @Test
public void multipleModificationWithRecursiveListenerInvocations() throws Exception { public void multipleModificationWithRecursiveListenerInvocations() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
MediaSource mediaSource = new FakeMediaSource(timeline); MediaSource mediaSource = new FakeMediaSource(timeline);
Timeline secondTimeline = new FakeTimeline(/* windowCount= */ 2); Timeline secondTimeline = new FakeTimeline(/* windowCount= */ 2);
MediaSource secondMediaSource = new FakeMediaSource(secondTimeline); MediaSource secondMediaSource = new FakeMediaSource(secondTimeline);
...@@ -4995,10 +4951,6 @@ public final class ExoPlayerTest { ...@@ -4995,10 +4951,6 @@ public final class ExoPlayerTest {
@Test @Test
public void modifyPlaylistUnprepared_remainsInIdle_needsPrepareForBuffering() throws Exception { public void modifyPlaylistUnprepared_remainsInIdle_needsPrepareForBuffering() throws Exception {
Timeline firstTimeline = new FakeTimeline(/* windowCount= */ 1);
MediaSource firstMediaSource = new FakeMediaSource(firstTimeline);
Timeline secondTimeline = new FakeTimeline(/* windowCount= */ 1);
MediaSource secondMediaSource = new FakeMediaSource(secondTimeline);
int[] playbackStates = new int[4]; int[] playbackStates = new int[4];
int[] timelineWindowCounts = new int[4]; int[] timelineWindowCounts = new int[4];
int[] maskingPlaybackState = {C.INDEX_UNSET}; int[] maskingPlaybackState = {C.INDEX_UNSET};
...@@ -5015,13 +4967,13 @@ public final class ExoPlayerTest { ...@@ -5015,13 +4967,13 @@ public final class ExoPlayerTest {
new PlayerRunnable() { new PlayerRunnable() {
@Override @Override
public void run(SimpleExoPlayer player) { public void run(SimpleExoPlayer player) {
player.setMediaSource(firstMediaSource, /* startPositionMs= */ 1000); player.setMediaSource(new FakeMediaSource(), /* startPositionMs= */ 1000);
maskingPlaybackState[0] = player.getPlaybackState(); maskingPlaybackState[0] = player.getPlaybackState();
} }
}) })
.executeRunnable( .executeRunnable(
new PlaybackStateCollector(/* index= */ 2, playbackStates, timelineWindowCounts)) new PlaybackStateCollector(/* index= */ 2, playbackStates, timelineWindowCounts))
.addMediaSources(secondMediaSource) .addMediaSources(new FakeMediaSource())
.executeRunnable( .executeRunnable(
new PlaybackStateCollector(/* index= */ 3, playbackStates, timelineWindowCounts)) new PlaybackStateCollector(/* index= */ 3, playbackStates, timelineWindowCounts))
.seek(/* windowIndex= */ 1, /* positionMs= */ 2000) .seek(/* windowIndex= */ 1, /* positionMs= */ 2000)
...@@ -5033,7 +4985,7 @@ public final class ExoPlayerTest { ...@@ -5033,7 +4985,7 @@ public final class ExoPlayerTest {
.build(); .build();
ExoPlayerTestRunner exoPlayerTestRunner = ExoPlayerTestRunner exoPlayerTestRunner =
new ExoPlayerTestRunner.Builder(context) new ExoPlayerTestRunner.Builder(context)
.setMediaSources(firstMediaSource) .setMediaSources(new FakeMediaSource())
.setActionSchedule(actionSchedule) .setActionSchedule(actionSchedule)
.build() .build()
.start(/* doPrepare= */ false) .start(/* doPrepare= */ false)
...@@ -5083,7 +5035,7 @@ public final class ExoPlayerTest { ...@@ -5083,7 +5035,7 @@ public final class ExoPlayerTest {
@Test @Test
public void modifyPlaylistPrepared_remainsInEnded_needsSeekForBuffering() throws Exception { public void modifyPlaylistPrepared_remainsInEnded_needsSeekForBuffering() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
FakeMediaSource secondMediaSource = new FakeMediaSource(timeline); FakeMediaSource secondMediaSource = new FakeMediaSource(timeline);
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
...@@ -5142,7 +5094,7 @@ public final class ExoPlayerTest { ...@@ -5142,7 +5094,7 @@ public final class ExoPlayerTest {
@Test @Test
public void stopWithNoReset_modifyingPlaylistRemainsInIdleState_needsPrepareForBuffering() public void stopWithNoReset_modifyingPlaylistRemainsInIdleState_needsPrepareForBuffering()
throws Exception { throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
FakeMediaSource secondMediaSource = new FakeMediaSource(timeline); FakeMediaSource secondMediaSource = new FakeMediaSource(timeline);
int[] playbackStateHolder = new int[3]; int[] playbackStateHolder = new int[3];
int[] windowCountHolder = new int[3]; int[] windowCountHolder = new int[3];
...@@ -5225,7 +5177,7 @@ public final class ExoPlayerTest { ...@@ -5225,7 +5177,7 @@ public final class ExoPlayerTest {
@Test @Test
public void prepareWhenAlreadyPreparedIsANoop() throws Exception { public void prepareWhenAlreadyPreparedIsANoop() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG).waitForPlaybackState(Player.STATE_READY).prepare().build(); new ActionSchedule.Builder(TAG).waitForPlaybackState(Player.STATE_READY).prepare().build();
ExoPlayerTestRunner exoPlayerTestRunner = ExoPlayerTestRunner exoPlayerTestRunner =
...@@ -5568,8 +5520,6 @@ public final class ExoPlayerTest { ...@@ -5568,8 +5520,6 @@ public final class ExoPlayerTest {
@Test @Test
public void setMediaSources_empty_whenEmpty_correctMaskingWindowIndex() throws Exception { public void setMediaSources_empty_whenEmpty_correctMaskingWindowIndex() throws Exception {
Timeline secondTimeline = new FakeTimeline(/* windowCount= */ 1);
MediaSource secondMediaSource = new FakeMediaSource(secondTimeline);
final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET};
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
...@@ -5578,9 +5528,8 @@ public final class ExoPlayerTest { ...@@ -5578,9 +5528,8 @@ public final class ExoPlayerTest {
@Override @Override
public void run(SimpleExoPlayer player) { public void run(SimpleExoPlayer player) {
currentWindowIndices[0] = player.getCurrentWindowIndex(); currentWindowIndices[0] = player.getCurrentWindowIndex();
List<MediaSource> listOfTwo = new ArrayList<>(); List<MediaSource> listOfTwo =
listOfTwo.add(secondMediaSource); ImmutableList.of(new FakeMediaSource(), new FakeMediaSource());
listOfTwo.add(secondMediaSource);
player.addMediaSources(/* index= */ 0, listOfTwo); player.addMediaSources(/* index= */ 0, listOfTwo);
currentWindowIndices[1] = player.getCurrentWindowIndex(); currentWindowIndices[1] = player.getCurrentWindowIndex();
} }
...@@ -5620,7 +5569,7 @@ public final class ExoPlayerTest { ...@@ -5620,7 +5569,7 @@ public final class ExoPlayerTest {
currentWindowIndices[0] = player.getCurrentWindowIndex(); currentWindowIndices[0] = player.getCurrentWindowIndex();
currentPositions[0] = player.getCurrentPosition(); currentPositions[0] = player.getCurrentPosition();
List<MediaItem> listOfTwo = List<MediaItem> listOfTwo =
Lists.newArrayList( ImmutableList.of(
MediaItem.fromUri(Uri.EMPTY), MediaItem.fromUri(Uri.EMPTY)); MediaItem.fromUri(Uri.EMPTY), MediaItem.fromUri(Uri.EMPTY));
player.setMediaItems(listOfTwo, /* resetPosition= */ true); player.setMediaItems(listOfTwo, /* resetPosition= */ true);
currentWindowIndices[1] = player.getCurrentWindowIndex(); currentWindowIndices[1] = player.getCurrentWindowIndex();
...@@ -5644,8 +5593,6 @@ public final class ExoPlayerTest { ...@@ -5644,8 +5593,6 @@ public final class ExoPlayerTest {
@Test @Test
public void setMediaSources_empty_whenEmpty_validInitialSeek_correctMaskingWindowIndex() public void setMediaSources_empty_whenEmpty_validInitialSeek_correctMaskingWindowIndex()
throws Exception { throws Exception {
Timeline secondTimeline = new FakeTimeline(/* windowCount= */ 1);
MediaSource secondMediaSource = new FakeMediaSource(secondTimeline);
final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET};
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
...@@ -5657,9 +5604,8 @@ public final class ExoPlayerTest { ...@@ -5657,9 +5604,8 @@ public final class ExoPlayerTest {
@Override @Override
public void run(SimpleExoPlayer player) { public void run(SimpleExoPlayer player) {
currentWindowIndices[0] = player.getCurrentWindowIndex(); currentWindowIndices[0] = player.getCurrentWindowIndex();
List<MediaSource> listOfTwo = new ArrayList<>(); List<MediaSource> listOfTwo =
listOfTwo.add(secondMediaSource); ImmutableList.of(new FakeMediaSource(), new FakeMediaSource());
listOfTwo.add(secondMediaSource);
player.addMediaSources(/* index= */ 0, listOfTwo); player.addMediaSources(/* index= */ 0, listOfTwo);
currentWindowIndices[1] = player.getCurrentWindowIndex(); currentWindowIndices[1] = player.getCurrentWindowIndex();
} }
...@@ -5688,8 +5634,6 @@ public final class ExoPlayerTest { ...@@ -5688,8 +5634,6 @@ public final class ExoPlayerTest {
@Test @Test
public void setMediaSources_empty_whenEmpty_invalidInitialSeek_correctMaskingWindowIndex() public void setMediaSources_empty_whenEmpty_invalidInitialSeek_correctMaskingWindowIndex()
throws Exception { throws Exception {
Timeline secondTimeline = new FakeTimeline(/* windowCount= */ 1);
MediaSource secondMediaSource = new FakeMediaSource(secondTimeline);
final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET};
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
...@@ -5701,9 +5645,8 @@ public final class ExoPlayerTest { ...@@ -5701,9 +5645,8 @@ public final class ExoPlayerTest {
@Override @Override
public void run(SimpleExoPlayer player) { public void run(SimpleExoPlayer player) {
currentWindowIndices[0] = player.getCurrentWindowIndex(); currentWindowIndices[0] = player.getCurrentWindowIndex();
List<MediaSource> listOfTwo = new ArrayList<>(); List<MediaSource> listOfTwo =
listOfTwo.add(secondMediaSource); ImmutableList.of(new FakeMediaSource(), new FakeMediaSource());
listOfTwo.add(secondMediaSource);
player.addMediaSources(/* index= */ 0, listOfTwo); player.addMediaSources(/* index= */ 0, listOfTwo);
currentWindowIndices[1] = player.getCurrentWindowIndex(); currentWindowIndices[1] = player.getCurrentWindowIndex();
} }
...@@ -5731,10 +5674,6 @@ public final class ExoPlayerTest { ...@@ -5731,10 +5674,6 @@ public final class ExoPlayerTest {
@Test @Test
public void setMediaSources_whenEmpty_correctMaskingWindowIndex() throws Exception { public void setMediaSources_whenEmpty_correctMaskingWindowIndex() throws Exception {
Timeline firstTimeline = new FakeTimeline(/* windowCount= */ 1);
MediaSource firstMediaSource = new FakeMediaSource(firstTimeline);
Timeline secondTimeline = new FakeTimeline(/* windowCount= */ 1);
MediaSource secondMediaSource = new FakeMediaSource(secondTimeline);
final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET};
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
...@@ -5744,7 +5683,7 @@ public final class ExoPlayerTest { ...@@ -5744,7 +5683,7 @@ public final class ExoPlayerTest {
@Override @Override
public void run(SimpleExoPlayer player) { public void run(SimpleExoPlayer player) {
// Increase current window index. // Increase current window index.
player.addMediaSource(/* index= */ 0, secondMediaSource); player.addMediaSource(/* index= */ 0, new FakeMediaSource());
currentWindowIndices[0] = player.getCurrentWindowIndex(); currentWindowIndices[0] = player.getCurrentWindowIndex();
} }
}) })
...@@ -5753,7 +5692,7 @@ public final class ExoPlayerTest { ...@@ -5753,7 +5692,7 @@ public final class ExoPlayerTest {
@Override @Override
public void run(SimpleExoPlayer player) { public void run(SimpleExoPlayer player) {
// Current window index is unchanged. // Current window index is unchanged.
player.addMediaSource(/* index= */ 2, secondMediaSource); player.addMediaSource(/* index= */ 2, new FakeMediaSource());
currentWindowIndices[1] = player.getCurrentWindowIndex(); currentWindowIndices[1] = player.getCurrentWindowIndex();
} }
}) })
...@@ -5761,8 +5700,7 @@ public final class ExoPlayerTest { ...@@ -5761,8 +5700,7 @@ public final class ExoPlayerTest {
new PlayerRunnable() { new PlayerRunnable() {
@Override @Override
public void run(SimpleExoPlayer player) { public void run(SimpleExoPlayer player) {
MediaSource mediaSource = MediaSource mediaSource = new FakeMediaSource();
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1));
ConcatenatingMediaSource concatenatingMediaSource = ConcatenatingMediaSource concatenatingMediaSource =
new ConcatenatingMediaSource(mediaSource, mediaSource, mediaSource); new ConcatenatingMediaSource(mediaSource, mediaSource, mediaSource);
// Increase current window with multi window source. // Increase current window with multi window source.
...@@ -5783,7 +5721,7 @@ public final class ExoPlayerTest { ...@@ -5783,7 +5721,7 @@ public final class ExoPlayerTest {
}) })
.build(); .build();
new ExoPlayerTestRunner.Builder(context) new ExoPlayerTestRunner.Builder(context)
.setMediaSources(firstMediaSource) .setMediaSources(new FakeMediaSource())
.setActionSchedule(actionSchedule) .setActionSchedule(actionSchedule)
.build() .build()
.start() .start()
...@@ -5847,10 +5785,6 @@ public final class ExoPlayerTest { ...@@ -5847,10 +5785,6 @@ public final class ExoPlayerTest {
@Test @Test
public void setMediaSources_whenEmpty_invalidInitialSeek_correctMasking() throws Exception { public void setMediaSources_whenEmpty_invalidInitialSeek_correctMasking() throws Exception {
Timeline firstTimeline = new FakeTimeline(/* windowCount= */ 1);
MediaSource firstMediaSource = new FakeMediaSource(firstTimeline);
Timeline secondTimeline = new FakeTimeline(/* windowCount= */ 1, new Object());
MediaSource secondMediaSource = new FakeMediaSource(secondTimeline);
final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET};
final long[] currentPositions = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; final long[] currentPositions = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET};
final long[] bufferedPositions = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; final long[] bufferedPositions = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET};
...@@ -5867,7 +5801,7 @@ public final class ExoPlayerTest { ...@@ -5867,7 +5801,7 @@ public final class ExoPlayerTest {
currentPositions[0] = player.getCurrentPosition(); currentPositions[0] = player.getCurrentPosition();
bufferedPositions[0] = player.getBufferedPosition(); bufferedPositions[0] = player.getBufferedPosition();
// Increase current window index. // Increase current window index.
player.addMediaSource(/* index= */ 0, secondMediaSource); player.addMediaSource(/* index= */ 0, new FakeMediaSource());
currentWindowIndices[1] = player.getCurrentWindowIndex(); currentWindowIndices[1] = player.getCurrentWindowIndex();
currentPositions[1] = player.getCurrentPosition(); currentPositions[1] = player.getCurrentPosition();
bufferedPositions[1] = player.getBufferedPosition(); bufferedPositions[1] = player.getBufferedPosition();
...@@ -5888,7 +5822,7 @@ public final class ExoPlayerTest { ...@@ -5888,7 +5822,7 @@ public final class ExoPlayerTest {
.build(); .build();
new ExoPlayerTestRunner.Builder(context) new ExoPlayerTestRunner.Builder(context)
.initialSeek(/* windowIndex= */ 1, 2000) .initialSeek(/* windowIndex= */ 1, 2000)
.setMediaSources(firstMediaSource) .setMediaSources(new FakeMediaSource())
.setActionSchedule(actionSchedule) .setActionSchedule(actionSchedule)
.build() .build()
.start(/* doPrepare= */ false) .start(/* doPrepare= */ false)
...@@ -5901,10 +5835,6 @@ public final class ExoPlayerTest { ...@@ -5901,10 +5835,6 @@ public final class ExoPlayerTest {
@Test @Test
public void setMediaSources_correctMaskingWindowIndex() throws Exception { public void setMediaSources_correctMaskingWindowIndex() throws Exception {
Timeline firstTimeline = new FakeTimeline(/* windowCount= */ 1);
MediaSource firstMediaSource = new FakeMediaSource(firstTimeline);
Timeline secondTimeline = new FakeTimeline(/* windowCount= */ 1, new Object());
MediaSource secondMediaSource = new FakeMediaSource(secondTimeline);
final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET};
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
...@@ -5915,7 +5845,7 @@ public final class ExoPlayerTest { ...@@ -5915,7 +5845,7 @@ public final class ExoPlayerTest {
public void run(SimpleExoPlayer player) { public void run(SimpleExoPlayer player) {
currentWindowIndices[0] = player.getCurrentWindowIndex(); currentWindowIndices[0] = player.getCurrentWindowIndex();
// Increase current window index. // Increase current window index.
player.addMediaSource(/* index= */ 0, secondMediaSource); player.addMediaSource(/* index= */ 0, new FakeMediaSource());
currentWindowIndices[1] = player.getCurrentWindowIndex(); currentWindowIndices[1] = player.getCurrentWindowIndex();
} }
}) })
...@@ -5929,7 +5859,7 @@ public final class ExoPlayerTest { ...@@ -5929,7 +5859,7 @@ public final class ExoPlayerTest {
}) })
.build(); .build();
new ExoPlayerTestRunner.Builder(context) new ExoPlayerTestRunner.Builder(context)
.setMediaSources(firstMediaSource) .setMediaSources(new FakeMediaSource())
.setActionSchedule(actionSchedule) .setActionSchedule(actionSchedule)
.build() .build()
.start() .start()
...@@ -5940,10 +5870,6 @@ public final class ExoPlayerTest { ...@@ -5940,10 +5870,6 @@ public final class ExoPlayerTest {
@Test @Test
public void setMediaSources_whenIdle_correctMaskingPlaybackState() throws Exception { public void setMediaSources_whenIdle_correctMaskingPlaybackState() throws Exception {
Timeline firstTimeline = new FakeTimeline(/* windowCount= */ 1, 1L);
MediaSource firstMediaSource = new FakeMediaSource(firstTimeline);
Timeline secondTimeline = new FakeTimeline(/* windowCount= */ 1, 2L);
MediaSource secondMediaSource = new FakeMediaSource(secondTimeline);
final int[] maskingPlaybackStates = new int[4]; final int[] maskingPlaybackStates = new int[4];
Arrays.fill(maskingPlaybackStates, C.INDEX_UNSET); Arrays.fill(maskingPlaybackStates, C.INDEX_UNSET);
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
...@@ -5962,7 +5888,7 @@ public final class ExoPlayerTest { ...@@ -5962,7 +5888,7 @@ public final class ExoPlayerTest {
@Override @Override
public void run(SimpleExoPlayer player) { public void run(SimpleExoPlayer player) {
// Set media item with an implicit seek to the current position. // Set media item with an implicit seek to the current position.
player.setMediaSource(firstMediaSource); player.setMediaSource(new FakeMediaSource());
maskingPlaybackStates[1] = player.getPlaybackState(); maskingPlaybackStates[1] = player.getPlaybackState();
} }
}) })
...@@ -5971,7 +5897,8 @@ public final class ExoPlayerTest { ...@@ -5971,7 +5897,8 @@ public final class ExoPlayerTest {
@Override @Override
public void run(SimpleExoPlayer player) { public void run(SimpleExoPlayer player) {
// Set media item with an explicit seek. // Set media item with an explicit seek.
player.setMediaSource(secondMediaSource, /* startPositionMs= */ C.TIME_UNSET); player.setMediaSource(
new FakeMediaSource(), /* startPositionMs= */ C.TIME_UNSET);
maskingPlaybackStates[2] = player.getPlaybackState(); maskingPlaybackStates[2] = player.getPlaybackState();
} }
}) })
...@@ -6058,8 +5985,7 @@ public final class ExoPlayerTest { ...@@ -6058,8 +5985,7 @@ public final class ExoPlayerTest {
@Override @Override
public void run(SimpleExoPlayer player) { public void run(SimpleExoPlayer player) {
// Set media item with no seek. // Set media item with no seek.
player.setMediaSource( player.setMediaSource(new FakeMediaSource());
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)));
maskingPlaybackStates[0] = player.getPlaybackState(); maskingPlaybackStates[0] = player.getPlaybackState();
} }
}) })
...@@ -6098,7 +6024,7 @@ public final class ExoPlayerTest { ...@@ -6098,7 +6024,7 @@ public final class ExoPlayerTest {
maskingPlaybackStates[0] = player.getPlaybackState(); maskingPlaybackStates[0] = player.getPlaybackState();
} }
}) })
.setMediaSources(new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1))) .setMediaSources(new FakeMediaSource())
.prepare() .prepare()
.waitForPlaybackState(Player.STATE_READY) .waitForPlaybackState(Player.STATE_READY)
.build(); .build();
...@@ -6256,9 +6182,7 @@ public final class ExoPlayerTest { ...@@ -6256,9 +6182,7 @@ public final class ExoPlayerTest {
@Override @Override
public void run(SimpleExoPlayer player) { public void run(SimpleExoPlayer player) {
// Set media item with no seek (keep current position). // Set media item with no seek (keep current position).
player.setMediaSource( player.setMediaSource(new FakeMediaSource(), /* resetPosition= */ false);
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)),
/* resetPosition= */ false);
maskingPlaybackStates[0] = player.getPlaybackState(); maskingPlaybackStates[0] = player.getPlaybackState();
} }
}) })
...@@ -6499,9 +6423,7 @@ public final class ExoPlayerTest { ...@@ -6499,9 +6423,7 @@ public final class ExoPlayerTest {
new PlayerRunnable() { new PlayerRunnable() {
@Override @Override
public void run(SimpleExoPlayer player) { public void run(SimpleExoPlayer player) {
player.addMediaSource( player.addMediaSource(/* index= */ 0, new FakeMediaSource());
/* index= */ 0,
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)));
positions[0] = player.getCurrentPosition(); positions[0] = player.getCurrentPosition();
positions[1] = player.getBufferedPosition(); positions[1] = player.getBufferedPosition();
} }
...@@ -6547,9 +6469,7 @@ public final class ExoPlayerTest { ...@@ -6547,9 +6469,7 @@ public final class ExoPlayerTest {
/* index= */ 0, /* index= */ 0,
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 2))); new FakeMediaSource(new FakeTimeline(/* windowCount= */ 2)));
currentWindowIndices[2] = player.getCurrentWindowIndex(); currentWindowIndices[2] = player.getCurrentWindowIndex();
player.addMediaSource( player.addMediaSource(/* index= */ 0, new FakeMediaSource());
/* index= */ 0,
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)));
currentWindowIndices[3] = player.getCurrentWindowIndex(); currentWindowIndices[3] = player.getCurrentWindowIndex();
// With a non-empty timeline, we mask the periodId in the playback info. // With a non-empty timeline, we mask the periodId in the playback info.
currentPositions[1] = player.getCurrentPosition(); currentPositions[1] = player.getCurrentPosition();
...@@ -6590,8 +6510,6 @@ public final class ExoPlayerTest { ...@@ -6590,8 +6510,6 @@ public final class ExoPlayerTest {
public void public void
testAddMediaSources_skipSettingMediaItems_invalidInitialSeek_correctMaskingWindowIndex() testAddMediaSources_skipSettingMediaItems_invalidInitialSeek_correctMaskingWindowIndex()
throws Exception { throws Exception {
Timeline secondTimeline = new FakeTimeline(/* windowCount= */ 1);
MediaSource secondMediaSource = new FakeMediaSource(secondTimeline);
final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET};
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
...@@ -6603,7 +6521,7 @@ public final class ExoPlayerTest { ...@@ -6603,7 +6521,7 @@ public final class ExoPlayerTest {
@Override @Override
public void run(SimpleExoPlayer player) { public void run(SimpleExoPlayer player) {
currentWindowIndices[0] = player.getCurrentWindowIndex(); currentWindowIndices[0] = player.getCurrentWindowIndex();
player.addMediaSource(secondMediaSource); player.addMediaSource(new FakeMediaSource());
currentWindowIndices[1] = player.getCurrentWindowIndex(); currentWindowIndices[1] = player.getCurrentWindowIndex();
} }
}) })
...@@ -6630,7 +6548,7 @@ public final class ExoPlayerTest { ...@@ -6630,7 +6548,7 @@ public final class ExoPlayerTest {
@Test @Test
public void moveMediaItems_correctMaskingWindowIndex() throws Exception { public void moveMediaItems_correctMaskingWindowIndex() throws Exception {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
MediaSource firstMediaSource = new FakeMediaSource(timeline); MediaSource firstMediaSource = new FakeMediaSource(timeline);
MediaSource secondMediaSource = new FakeMediaSource(timeline); MediaSource secondMediaSource = new FakeMediaSource(timeline);
MediaSource thirdMediaSource = new FakeMediaSource(timeline); MediaSource thirdMediaSource = new FakeMediaSource(timeline);
...@@ -6711,10 +6629,6 @@ public final class ExoPlayerTest { ...@@ -6711,10 +6629,6 @@ public final class ExoPlayerTest {
@Test @Test
public void moveMediaItems_unprepared_correctMaskingWindowIndex() throws Exception { public void moveMediaItems_unprepared_correctMaskingWindowIndex() throws Exception {
Timeline firstTimeline = new FakeTimeline(/* windowCount= */ 1);
MediaSource firstMediaSource = new FakeMediaSource(firstTimeline);
Timeline secondTimeline = new FakeTimeline(/* windowCount= */ 1);
MediaSource secondMediaSource = new FakeMediaSource(secondTimeline);
final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET};
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
...@@ -6740,7 +6654,7 @@ public final class ExoPlayerTest { ...@@ -6740,7 +6654,7 @@ public final class ExoPlayerTest {
}) })
.build(); .build();
new ExoPlayerTestRunner.Builder(context) new ExoPlayerTestRunner.Builder(context)
.setMediaSources(firstMediaSource, secondMediaSource) .setMediaSources(new FakeMediaSource(), new FakeMediaSource())
.setActionSchedule(actionSchedule) .setActionSchedule(actionSchedule)
.build() .build()
.start(/* doPrepare= */ false) .start(/* doPrepare= */ false)
...@@ -6751,10 +6665,6 @@ public final class ExoPlayerTest { ...@@ -6751,10 +6665,6 @@ public final class ExoPlayerTest {
@Test @Test
public void removeMediaItems_correctMaskingWindowIndex() throws Exception { public void removeMediaItems_correctMaskingWindowIndex() throws Exception {
Timeline firstTimeline = new FakeTimeline(/* windowCount= */ 1);
MediaSource firstMediaSource = new FakeMediaSource(firstTimeline);
Timeline secondTimeline = new FakeTimeline(/* windowCount= */ 1);
MediaSource secondMediaSource = new FakeMediaSource(secondTimeline);
final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET}; final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET};
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
...@@ -6772,7 +6682,7 @@ public final class ExoPlayerTest { ...@@ -6772,7 +6682,7 @@ public final class ExoPlayerTest {
.build(); .build();
new ExoPlayerTestRunner.Builder(context) new ExoPlayerTestRunner.Builder(context)
.initialSeek(/* windowIndex= */ 1, /* positionMs= */ C.TIME_UNSET) .initialSeek(/* windowIndex= */ 1, /* positionMs= */ C.TIME_UNSET)
.setMediaSources(firstMediaSource, secondMediaSource) .setMediaSources(new FakeMediaSource(), new FakeMediaSource())
.setActionSchedule(actionSchedule) .setActionSchedule(actionSchedule)
.build() .build()
.start() .start()
...@@ -6783,10 +6693,6 @@ public final class ExoPlayerTest { ...@@ -6783,10 +6693,6 @@ public final class ExoPlayerTest {
@Test @Test
public void removeMediaItems_currentItemRemoved_correctMasking() throws Exception { public void removeMediaItems_currentItemRemoved_correctMasking() throws Exception {
Timeline firstTimeline = new FakeTimeline(/* windowCount= */ 1);
MediaSource firstMediaSource = new FakeMediaSource(firstTimeline);
Timeline secondTimeline = new FakeTimeline(/* windowCount= */ 1);
MediaSource secondMediaSource = new FakeMediaSource(secondTimeline);
final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET}; final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET};
final long[] currentPositions = {C.TIME_UNSET, C.TIME_UNSET}; final long[] currentPositions = {C.TIME_UNSET, C.TIME_UNSET};
final long[] bufferedPositions = {C.TIME_UNSET, C.TIME_UNSET}; final long[] bufferedPositions = {C.TIME_UNSET, C.TIME_UNSET};
...@@ -6810,7 +6716,7 @@ public final class ExoPlayerTest { ...@@ -6810,7 +6716,7 @@ public final class ExoPlayerTest {
.build(); .build();
new ExoPlayerTestRunner.Builder(context) new ExoPlayerTestRunner.Builder(context)
.initialSeek(/* windowIndex= */ 1, /* positionMs= */ 5000) .initialSeek(/* windowIndex= */ 1, /* positionMs= */ 5000)
.setMediaSources(firstMediaSource, secondMediaSource, firstMediaSource) .setMediaSources(new FakeMediaSource(), new FakeMediaSource(), new FakeMediaSource())
.setActionSchedule(actionSchedule) .setActionSchedule(actionSchedule)
.build() .build()
.start() .start()
...@@ -6957,10 +6863,6 @@ public final class ExoPlayerTest { ...@@ -6957,10 +6863,6 @@ public final class ExoPlayerTest {
@Test @Test
public void removeMediaItems_removeTailWithCurrentWindow_whenIdle_finishesPlayback() public void removeMediaItems_removeTailWithCurrentWindow_whenIdle_finishesPlayback()
throws Exception { throws Exception {
Timeline firstTimeline = new FakeTimeline(/* windowCount= */ 1);
MediaSource firstMediaSource = new FakeMediaSource(firstTimeline);
Timeline secondTimeline = new FakeTimeline(/* windowCount= */ 1, new Object());
MediaSource secondMediaSource = new FakeMediaSource(secondTimeline);
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
.seek(/* windowIndex= */ 1, /* positionMs= */ C.TIME_UNSET) .seek(/* windowIndex= */ 1, /* positionMs= */ C.TIME_UNSET)
...@@ -6971,7 +6873,7 @@ public final class ExoPlayerTest { ...@@ -6971,7 +6873,7 @@ public final class ExoPlayerTest {
.build(); .build();
ExoPlayerTestRunner exoPlayerTestRunner = ExoPlayerTestRunner exoPlayerTestRunner =
new ExoPlayerTestRunner.Builder(context) new ExoPlayerTestRunner.Builder(context)
.setMediaSources(firstMediaSource, secondMediaSource) .setMediaSources(new FakeMediaSource(), new FakeMediaSource())
.setActionSchedule(actionSchedule) .setActionSchedule(actionSchedule)
.build() .build()
.start(/* doPrepare= */ false) .start(/* doPrepare= */ false)
...@@ -6983,10 +6885,6 @@ public final class ExoPlayerTest { ...@@ -6983,10 +6885,6 @@ public final class ExoPlayerTest {
@Test @Test
public void clearMediaItems_correctMasking() throws Exception { public void clearMediaItems_correctMasking() throws Exception {
Timeline firstTimeline = new FakeTimeline(/* windowCount= */ 1);
MediaSource firstMediaSource = new FakeMediaSource(firstTimeline);
Timeline secondTimeline = new FakeTimeline(/* windowCount= */ 1);
MediaSource secondMediaSource = new FakeMediaSource(secondTimeline);
final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET}; final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET};
final int[] maskingPlaybackState = {C.INDEX_UNSET}; final int[] maskingPlaybackState = {C.INDEX_UNSET};
final long[] currentPosition = {C.TIME_UNSET, C.TIME_UNSET}; final long[] currentPosition = {C.TIME_UNSET, C.TIME_UNSET};
...@@ -7013,7 +6911,7 @@ public final class ExoPlayerTest { ...@@ -7013,7 +6911,7 @@ public final class ExoPlayerTest {
.build(); .build();
new ExoPlayerTestRunner.Builder(context) new ExoPlayerTestRunner.Builder(context)
.initialSeek(/* windowIndex= */ 1, /* positionMs= */ C.TIME_UNSET) .initialSeek(/* windowIndex= */ 1, /* positionMs= */ C.TIME_UNSET)
.setMediaSources(firstMediaSource, secondMediaSource) .setMediaSources(new FakeMediaSource(), new FakeMediaSource())
.setActionSchedule(actionSchedule) .setActionSchedule(actionSchedule)
.build() .build()
.start() .start()
...@@ -7030,10 +6928,6 @@ public final class ExoPlayerTest { ...@@ -7030,10 +6928,6 @@ public final class ExoPlayerTest {
@Test @Test
public void clearMediaItems_unprepared_correctMaskingWindowIndex_notEnded() throws Exception { public void clearMediaItems_unprepared_correctMaskingWindowIndex_notEnded() throws Exception {
Timeline firstTimeline = new FakeTimeline(/* windowCount= */ 1);
MediaSource firstMediaSource = new FakeMediaSource(firstTimeline);
Timeline secondTimeline = new FakeTimeline(/* windowCount= */ 1);
MediaSource secondMediaSource = new FakeMediaSource(secondTimeline);
final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET}; final int[] currentWindowIndices = {C.INDEX_UNSET, C.INDEX_UNSET};
final int[] currentStates = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; final int[] currentStates = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET};
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
...@@ -7064,7 +6958,7 @@ public final class ExoPlayerTest { ...@@ -7064,7 +6958,7 @@ public final class ExoPlayerTest {
.build(); .build();
new ExoPlayerTestRunner.Builder(context) new ExoPlayerTestRunner.Builder(context)
.initialSeek(/* windowIndex= */ 1, /* positionMs= */ C.TIME_UNSET) .initialSeek(/* windowIndex= */ 1, /* positionMs= */ C.TIME_UNSET)
.setMediaSources(firstMediaSource, secondMediaSource) .setMediaSources(new FakeMediaSource(), new FakeMediaSource())
.setActionSchedule(actionSchedule) .setActionSchedule(actionSchedule)
.build() .build()
.start(/* doPrepare= */ false) .start(/* doPrepare= */ false)
...@@ -7079,12 +6973,9 @@ public final class ExoPlayerTest { ...@@ -7079,12 +6973,9 @@ public final class ExoPlayerTest {
public void errorThrownDuringPlaylistUpdate_keepsConsistentPlayerState() { public void errorThrownDuringPlaylistUpdate_keepsConsistentPlayerState() {
FakeMediaSource source1 = FakeMediaSource source1 =
new FakeMediaSource( new FakeMediaSource(
new FakeTimeline(/* windowCount= */ 1), new FakeTimeline(), ExoPlayerTestRunner.VIDEO_FORMAT, ExoPlayerTestRunner.AUDIO_FORMAT);
ExoPlayerTestRunner.VIDEO_FORMAT,
ExoPlayerTestRunner.AUDIO_FORMAT);
FakeMediaSource source2 = FakeMediaSource source2 =
new FakeMediaSource( new FakeMediaSource(new FakeTimeline(), ExoPlayerTestRunner.AUDIO_FORMAT);
new FakeTimeline(/* windowCount= */ 1), ExoPlayerTestRunner.AUDIO_FORMAT);
AtomicInteger audioRendererEnableCount = new AtomicInteger(0); AtomicInteger audioRendererEnableCount = new AtomicInteger(0);
FakeRenderer videoRenderer = new FakeRenderer(C.TRACK_TYPE_VIDEO); FakeRenderer videoRenderer = new FakeRenderer(C.TRACK_TYPE_VIDEO);
FakeRenderer audioRenderer = FakeRenderer audioRenderer =
...@@ -7280,8 +7171,7 @@ public final class ExoPlayerTest { ...@@ -7280,8 +7171,7 @@ public final class ExoPlayerTest {
// Return no end of stream signal to prevent playback from ending. // Return no end of stream signal to prevent playback from ending.
FakeMediaPeriod.TrackDataFactory trackDataWithoutEos = (format, periodId) -> ImmutableList.of(); FakeMediaPeriod.TrackDataFactory trackDataWithoutEos = (format, periodId) -> ImmutableList.of();
MediaSource continuouslyAllocatingMediaSource = MediaSource continuouslyAllocatingMediaSource =
new FakeMediaSource( new FakeMediaSource(new FakeTimeline(), ExoPlayerTestRunner.VIDEO_FORMAT) {
new FakeTimeline(/* windowCount= */ 1), ExoPlayerTestRunner.VIDEO_FORMAT) {
@Override @Override
protected FakeMediaPeriod createFakeMediaPeriod( protected FakeMediaPeriod createFakeMediaPeriod(
MediaPeriodId id, MediaPeriodId id,
...@@ -7358,8 +7248,7 @@ public final class ExoPlayerTest { ...@@ -7358,8 +7248,7 @@ public final class ExoPlayerTest {
public void cancelLoad() {} public void cancelLoad() {}
}; };
MediaSource largeBufferAllocatingMediaSource = MediaSource largeBufferAllocatingMediaSource =
new FakeMediaSource( new FakeMediaSource(new FakeTimeline(), ExoPlayerTestRunner.VIDEO_FORMAT) {
new FakeTimeline(/* windowCount= */ 1), ExoPlayerTestRunner.VIDEO_FORMAT) {
@Override @Override
protected FakeMediaPeriod createFakeMediaPeriod( protected FakeMediaPeriod createFakeMediaPeriod(
MediaPeriodId id, MediaPeriodId id,
...@@ -7995,7 +7884,7 @@ public final class ExoPlayerTest { ...@@ -7995,7 +7884,7 @@ public final class ExoPlayerTest {
mediaSourceMaybeThrowSourceInfoRefreshError_isNotThrownUntilPlaybackReachedFailingItem() mediaSourceMaybeThrowSourceInfoRefreshError_isNotThrownUntilPlaybackReachedFailingItem()
throws Exception { throws Exception {
ExoPlayer player = new TestExoPlayerBuilder(context).build(); ExoPlayer player = new TestExoPlayerBuilder(context).build();
player.addMediaSource(new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1))); player.addMediaSource(new FakeMediaSource());
player.addMediaSource( player.addMediaSource(
new FakeMediaSource(/* timeline= */ null) { new FakeMediaSource(/* timeline= */ null) {
@Override @Override
...@@ -8021,7 +7910,7 @@ public final class ExoPlayerTest { ...@@ -8021,7 +7910,7 @@ public final class ExoPlayerTest {
public void mediaPeriodMaybeThrowPrepareError_isNotThrownUntilPlaybackReachedFailingItem() public void mediaPeriodMaybeThrowPrepareError_isNotThrownUntilPlaybackReachedFailingItem()
throws Exception { throws Exception {
ExoPlayer player = new TestExoPlayerBuilder(context).build(); ExoPlayer player = new TestExoPlayerBuilder(context).build();
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
player.addMediaSource(new FakeMediaSource(timeline, ExoPlayerTestRunner.VIDEO_FORMAT)); player.addMediaSource(new FakeMediaSource(timeline, ExoPlayerTestRunner.VIDEO_FORMAT));
player.addMediaSource( player.addMediaSource(
new FakeMediaSource(timeline, ExoPlayerTestRunner.VIDEO_FORMAT) { new FakeMediaSource(timeline, ExoPlayerTestRunner.VIDEO_FORMAT) {
...@@ -8066,7 +7955,7 @@ public final class ExoPlayerTest { ...@@ -8066,7 +7955,7 @@ public final class ExoPlayerTest {
public void sampleStreamMaybeThrowError_isNotThrownUntilPlaybackReachedFailingItem() public void sampleStreamMaybeThrowError_isNotThrownUntilPlaybackReachedFailingItem()
throws Exception { throws Exception {
ExoPlayer player = new TestExoPlayerBuilder(context).build(); ExoPlayer player = new TestExoPlayerBuilder(context).build();
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
player.addMediaSource(new FakeMediaSource(timeline, ExoPlayerTestRunner.VIDEO_FORMAT)); player.addMediaSource(new FakeMediaSource(timeline, ExoPlayerTestRunner.VIDEO_FORMAT));
player.addMediaSource( player.addMediaSource(
new FakeMediaSource(timeline, ExoPlayerTestRunner.VIDEO_FORMAT) { new FakeMediaSource(timeline, ExoPlayerTestRunner.VIDEO_FORMAT) {
...@@ -8120,11 +8009,9 @@ public final class ExoPlayerTest { ...@@ -8120,11 +8009,9 @@ public final class ExoPlayerTest {
@Test @Test
public void rendererError_isReportedWithReadingMediaPeriodId() throws Exception { public void rendererError_isReportedWithReadingMediaPeriodId() throws Exception {
FakeMediaSource source0 = FakeMediaSource source0 =
new FakeMediaSource( new FakeMediaSource(new FakeTimeline(), ExoPlayerTestRunner.VIDEO_FORMAT);
new FakeTimeline(/* windowCount= */ 1), ExoPlayerTestRunner.VIDEO_FORMAT);
FakeMediaSource source1 = FakeMediaSource source1 =
new FakeMediaSource( new FakeMediaSource(new FakeTimeline(), ExoPlayerTestRunner.AUDIO_FORMAT);
new FakeTimeline(/* windowCount= */ 1), ExoPlayerTestRunner.AUDIO_FORMAT);
RenderersFactory renderersFactory = RenderersFactory renderersFactory =
(eventHandler, videoListener, audioListener, textOutput, metadataOutput) -> (eventHandler, videoListener, audioListener, textOutput, metadataOutput) ->
new Renderer[] { new Renderer[] {
...@@ -8173,7 +8060,7 @@ public final class ExoPlayerTest { ...@@ -8173,7 +8060,7 @@ public final class ExoPlayerTest {
public void enableOffloadSchedulingWhilePlaying_isToggled_isReported() throws Exception { public void enableOffloadSchedulingWhilePlaying_isToggled_isReported() throws Exception {
FakeSleepRenderer sleepRenderer = new FakeSleepRenderer(C.TRACK_TYPE_AUDIO).sleepOnNextRender(); FakeSleepRenderer sleepRenderer = new FakeSleepRenderer(C.TRACK_TYPE_AUDIO).sleepOnNextRender();
SimpleExoPlayer player = new TestExoPlayerBuilder(context).setRenderers(sleepRenderer).build(); SimpleExoPlayer player = new TestExoPlayerBuilder(context).setRenderers(sleepRenderer).build();
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
player.setMediaSource(new FakeMediaSource(timeline, ExoPlayerTestRunner.AUDIO_FORMAT)); player.setMediaSource(new FakeMediaSource(timeline, ExoPlayerTestRunner.AUDIO_FORMAT));
player.prepare(); player.prepare();
player.play(); player.play();
...@@ -8190,7 +8077,7 @@ public final class ExoPlayerTest { ...@@ -8190,7 +8077,7 @@ public final class ExoPlayerTest {
throws Exception { throws Exception {
FakeSleepRenderer sleepRenderer = new FakeSleepRenderer(C.TRACK_TYPE_AUDIO).sleepOnNextRender(); FakeSleepRenderer sleepRenderer = new FakeSleepRenderer(C.TRACK_TYPE_AUDIO).sleepOnNextRender();
SimpleExoPlayer player = new TestExoPlayerBuilder(context).setRenderers(sleepRenderer).build(); SimpleExoPlayer player = new TestExoPlayerBuilder(context).setRenderers(sleepRenderer).build();
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
player.setMediaSource(new FakeMediaSource(timeline, ExoPlayerTestRunner.AUDIO_FORMAT)); player.setMediaSource(new FakeMediaSource(timeline, ExoPlayerTestRunner.AUDIO_FORMAT));
player.experimentalSetOffloadSchedulingEnabled(true); player.experimentalSetOffloadSchedulingEnabled(true);
player.prepare(); player.prepare();
...@@ -8205,7 +8092,7 @@ public final class ExoPlayerTest { ...@@ -8205,7 +8092,7 @@ public final class ExoPlayerTest {
public void enableOffloadScheduling_isEnable_playerSleeps() throws Exception { public void enableOffloadScheduling_isEnable_playerSleeps() throws Exception {
FakeSleepRenderer sleepRenderer = new FakeSleepRenderer(C.TRACK_TYPE_AUDIO); FakeSleepRenderer sleepRenderer = new FakeSleepRenderer(C.TRACK_TYPE_AUDIO);
SimpleExoPlayer player = new TestExoPlayerBuilder(context).setRenderers(sleepRenderer).build(); SimpleExoPlayer player = new TestExoPlayerBuilder(context).setRenderers(sleepRenderer).build();
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
player.setMediaSource(new FakeMediaSource(timeline, ExoPlayerTestRunner.AUDIO_FORMAT)); player.setMediaSource(new FakeMediaSource(timeline, ExoPlayerTestRunner.AUDIO_FORMAT));
player.experimentalSetOffloadSchedulingEnabled(true); player.experimentalSetOffloadSchedulingEnabled(true);
player.prepare(); player.prepare();
...@@ -8223,7 +8110,7 @@ public final class ExoPlayerTest { ...@@ -8223,7 +8110,7 @@ public final class ExoPlayerTest {
throws Exception { throws Exception {
FakeSleepRenderer sleepRenderer = new FakeSleepRenderer(C.TRACK_TYPE_AUDIO).sleepOnNextRender(); FakeSleepRenderer sleepRenderer = new FakeSleepRenderer(C.TRACK_TYPE_AUDIO).sleepOnNextRender();
SimpleExoPlayer player = new TestExoPlayerBuilder(context).setRenderers(sleepRenderer).build(); SimpleExoPlayer player = new TestExoPlayerBuilder(context).setRenderers(sleepRenderer).build();
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
player.setMediaSource(new FakeMediaSource(timeline, ExoPlayerTestRunner.AUDIO_FORMAT)); player.setMediaSource(new FakeMediaSource(timeline, ExoPlayerTestRunner.AUDIO_FORMAT));
player.experimentalSetOffloadSchedulingEnabled(true); player.experimentalSetOffloadSchedulingEnabled(true);
player.prepare(); player.prepare();
...@@ -8241,7 +8128,7 @@ public final class ExoPlayerTest { ...@@ -8241,7 +8128,7 @@ public final class ExoPlayerTest {
public void wakeupListenerWhileSleepingForOffload_isWokenUp_renderingResumes() throws Exception { public void wakeupListenerWhileSleepingForOffload_isWokenUp_renderingResumes() throws Exception {
FakeSleepRenderer sleepRenderer = new FakeSleepRenderer(C.TRACK_TYPE_AUDIO).sleepOnNextRender(); FakeSleepRenderer sleepRenderer = new FakeSleepRenderer(C.TRACK_TYPE_AUDIO).sleepOnNextRender();
SimpleExoPlayer player = new TestExoPlayerBuilder(context).setRenderers(sleepRenderer).build(); SimpleExoPlayer player = new TestExoPlayerBuilder(context).setRenderers(sleepRenderer).build();
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
player.setMediaSource(new FakeMediaSource(timeline, ExoPlayerTestRunner.AUDIO_FORMAT)); player.setMediaSource(new FakeMediaSource(timeline, ExoPlayerTestRunner.AUDIO_FORMAT));
player.experimentalSetOffloadSchedulingEnabled(true); player.experimentalSetOffloadSchedulingEnabled(true);
player.prepare(); player.prepare();
...@@ -8561,6 +8448,7 @@ public final class ExoPlayerTest { ...@@ -8561,6 +8448,7 @@ public final class ExoPlayerTest {
new TestExoPlayerBuilder(context) new TestExoPlayerBuilder(context)
.setClock(new AutoAdvancingFakeClock(/* initialTimeMs= */ nowUnixTimeMs)) .setClock(new AutoAdvancingFakeClock(/* initialTimeMs= */ nowUnixTimeMs))
.build(); .build();
Timeline nonLiveTimeline = new FakeTimeline();
Timeline liveTimeline = Timeline liveTimeline =
new FakeTimeline( new FakeTimeline(
new TimelineWindowDefinition( new TimelineWindowDefinition(
...@@ -8576,7 +8464,7 @@ public final class ExoPlayerTest { ...@@ -8576,7 +8464,7 @@ public final class ExoPlayerTest {
AdPlaybackState.NONE, AdPlaybackState.NONE,
new MediaItem.Builder().setUri(Uri.EMPTY).setLiveTargetOffsetMs(9_000).build())); new MediaItem.Builder().setUri(Uri.EMPTY).setLiveTargetOffsetMs(9_000).build()));
player.pause(); player.pause();
player.addMediaSource(new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1))); player.addMediaSource(new FakeMediaSource(nonLiveTimeline));
player.addMediaSource(new FakeMediaSource(liveTimeline)); player.addMediaSource(new FakeMediaSource(liveTimeline));
player.prepare(); player.prepare();
TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_READY); TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_READY);
...@@ -8755,8 +8643,7 @@ public final class ExoPlayerTest { ...@@ -8755,8 +8643,7 @@ public final class ExoPlayerTest {
.build(); .build();
// Set multiple values together. // Set multiple values together.
player.setMediaSource( player.setMediaSource(new FakeMediaSource(new FakeTimeline(), formatWithStaticMetadata));
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1), formatWithStaticMetadata));
player.seekTo(2_000); player.seekTo(2_000);
player.setPlaybackParameters(new PlaybackParameters(/* speed= */ 2.0f)); player.setPlaybackParameters(new PlaybackParameters(/* speed= */ 2.0f));
ShadowLooper.runMainLooperToNextTask(); ShadowLooper.runMainLooperToNextTask();
......
...@@ -30,7 +30,6 @@ import com.google.android.exoplayer2.source.MediaSource; ...@@ -30,7 +30,6 @@ import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.ShuffleOrder; import com.google.android.exoplayer2.source.ShuffleOrder;
import com.google.android.exoplayer2.testutil.FakeMediaSource; import com.google.android.exoplayer2.testutil.FakeMediaSource;
import com.google.android.exoplayer2.testutil.FakeShuffleOrder; import com.google.android.exoplayer2.testutil.FakeShuffleOrder;
import com.google.android.exoplayer2.testutil.FakeTimeline;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
...@@ -528,11 +527,11 @@ public class MediaSourceListTest { ...@@ -528,11 +527,11 @@ public class MediaSourceListTest {
} }
private static List<MediaSourceList.MediaSourceHolder> createFakeHolders() { private static List<MediaSourceList.MediaSourceHolder> createFakeHolders() {
MediaSource fakeMediaSource = new FakeMediaSource(new FakeTimeline(1));
List<MediaSourceList.MediaSourceHolder> holders = new ArrayList<>(); List<MediaSourceList.MediaSourceHolder> holders = new ArrayList<>();
for (int i = 0; i < MEDIA_SOURCE_LIST_SIZE; i++) { for (int i = 0; i < MEDIA_SOURCE_LIST_SIZE; i++) {
holders.add( holders.add(
new MediaSourceList.MediaSourceHolder(fakeMediaSource, /* useLazyPreparation= */ true)); new MediaSourceList.MediaSourceHolder(
new FakeMediaSource(), /* useLazyPreparation= */ true));
} }
return holders; return holders;
} }
......
...@@ -160,7 +160,7 @@ public final class AnalyticsCollectorTest { ...@@ -160,7 +160,7 @@ public final class AnalyticsCollectorTest {
ExoPlayerTestRunner.VIDEO_FORMAT.buildUpon().setDrmInitData(DRM_DATA_1).build(); ExoPlayerTestRunner.VIDEO_FORMAT.buildUpon().setDrmInitData(DRM_DATA_1).build();
private static final int TIMEOUT_MS = 10_000; private static final int TIMEOUT_MS = 10_000;
private static final Timeline SINGLE_PERIOD_TIMELINE = new FakeTimeline(/* windowCount= */ 1); private static final Timeline SINGLE_PERIOD_TIMELINE = new FakeTimeline();
private static final EventWindowAndPeriodId WINDOW_0 = private static final EventWindowAndPeriodId WINDOW_0 =
new EventWindowAndPeriodId(/* windowIndex= */ 0, /* mediaPeriodId= */ null); new EventWindowAndPeriodId(/* windowIndex= */ 0, /* mediaPeriodId= */ null);
private static final EventWindowAndPeriodId WINDOW_1 = private static final EventWindowAndPeriodId WINDOW_1 =
...@@ -1520,11 +1520,9 @@ public final class AnalyticsCollectorTest { ...@@ -1520,11 +1520,9 @@ public final class AnalyticsCollectorTest {
public void onPlayerError_thrownDuringRendererEnableAtPeriodTransition_isReportedForNewPeriod() public void onPlayerError_thrownDuringRendererEnableAtPeriodTransition_isReportedForNewPeriod()
throws Exception { throws Exception {
FakeMediaSource source0 = FakeMediaSource source0 =
new FakeMediaSource( new FakeMediaSource(new FakeTimeline(), ExoPlayerTestRunner.VIDEO_FORMAT);
new FakeTimeline(/* windowCount= */ 1), ExoPlayerTestRunner.VIDEO_FORMAT);
FakeMediaSource source1 = FakeMediaSource source1 =
new FakeMediaSource( new FakeMediaSource(new FakeTimeline(), ExoPlayerTestRunner.AUDIO_FORMAT);
new FakeTimeline(/* windowCount= */ 1), ExoPlayerTestRunner.AUDIO_FORMAT);
RenderersFactory renderersFactory = RenderersFactory renderersFactory =
(eventHandler, videoListener, audioListener, textOutput, metadataOutput) -> (eventHandler, videoListener, audioListener, textOutput, metadataOutput) ->
new Renderer[] { new Renderer[] {
...@@ -1554,11 +1552,9 @@ public final class AnalyticsCollectorTest { ...@@ -1554,11 +1552,9 @@ public final class AnalyticsCollectorTest {
public void onPlayerError_thrownDuringRenderAtPeriodTransition_isReportedForNewPeriod() public void onPlayerError_thrownDuringRenderAtPeriodTransition_isReportedForNewPeriod()
throws Exception { throws Exception {
FakeMediaSource source0 = FakeMediaSource source0 =
new FakeMediaSource( new FakeMediaSource(new FakeTimeline(), ExoPlayerTestRunner.VIDEO_FORMAT);
new FakeTimeline(/* windowCount= */ 1), ExoPlayerTestRunner.VIDEO_FORMAT);
FakeMediaSource source1 = FakeMediaSource source1 =
new FakeMediaSource( new FakeMediaSource(new FakeTimeline(), ExoPlayerTestRunner.AUDIO_FORMAT);
new FakeTimeline(/* windowCount= */ 1), ExoPlayerTestRunner.AUDIO_FORMAT);
RenderersFactory renderersFactory = RenderersFactory renderersFactory =
(eventHandler, videoListener, audioListener, textOutput, metadataOutput) -> (eventHandler, videoListener, audioListener, textOutput, metadataOutput) ->
new Renderer[] { new Renderer[] {
...@@ -1589,8 +1585,7 @@ public final class AnalyticsCollectorTest { ...@@ -1589,8 +1585,7 @@ public final class AnalyticsCollectorTest {
onPlayerError_thrownDuringRendererReplaceStreamAtPeriodTransition_isReportedForNewPeriod() onPlayerError_thrownDuringRendererReplaceStreamAtPeriodTransition_isReportedForNewPeriod()
throws Exception { throws Exception {
FakeMediaSource source = FakeMediaSource source =
new FakeMediaSource( new FakeMediaSource(new FakeTimeline(), ExoPlayerTestRunner.AUDIO_FORMAT);
new FakeTimeline(/* windowCount= */ 1), ExoPlayerTestRunner.AUDIO_FORMAT);
RenderersFactory renderersFactory = RenderersFactory renderersFactory =
(eventHandler, videoListener, audioListener, textOutput, metadataOutput) -> (eventHandler, videoListener, audioListener, textOutput, metadataOutput) ->
new Renderer[] { new Renderer[] {
...@@ -1634,7 +1629,7 @@ public final class AnalyticsCollectorTest { ...@@ -1634,7 +1629,7 @@ public final class AnalyticsCollectorTest {
player.addAnalyticsListener(listener); player.addAnalyticsListener(listener);
// Trigger some simultaneous events. // Trigger some simultaneous events.
player.setMediaSource(new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1), formats)); player.setMediaSource(new FakeMediaSource(new FakeTimeline(), formats));
player.seekTo(2_000); player.seekTo(2_000);
player.setPlaybackParameters(new PlaybackParameters(/* speed= */ 2.0f)); player.setPlaybackParameters(new PlaybackParameters(/* speed= */ 2.0f));
ShadowLooper.runMainLooperToNextTask(); ShadowLooper.runMainLooperToNextTask();
...@@ -1642,7 +1637,7 @@ public final class AnalyticsCollectorTest { ...@@ -1642,7 +1637,7 @@ public final class AnalyticsCollectorTest {
// Move to another item and fail with a third one to trigger events with different EventTimes. // Move to another item and fail with a third one to trigger events with different EventTimes.
player.prepare(); player.prepare();
TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_READY); TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_READY);
player.addMediaSource(new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1), formats)); player.addMediaSource(new FakeMediaSource(new FakeTimeline(), formats));
player.play(); player.play();
TestPlayerRunHelper.runUntilPositionDiscontinuity( TestPlayerRunHelper.runUntilPositionDiscontinuity(
player, Player.DISCONTINUITY_REASON_PERIOD_TRANSITION); player, Player.DISCONTINUITY_REASON_PERIOD_TRANSITION);
......
...@@ -61,7 +61,7 @@ public final class DefaultPlaybackSessionManagerTest { ...@@ -61,7 +61,7 @@ public final class DefaultPlaybackSessionManagerTest {
@Test @Test
public void updateSessions_withoutMediaPeriodId_createsNewSession() { public void updateSessions_withoutMediaPeriodId_createsNewSession() {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
EventTime eventTime = createEventTime(timeline, /* windowIndex= */ 0, /* mediaPeriodId */ null); EventTime eventTime = createEventTime(timeline, /* windowIndex= */ 0, /* mediaPeriodId */ null);
sessionManager.updateSessions(eventTime); sessionManager.updateSessions(eventTime);
...@@ -73,7 +73,7 @@ public final class DefaultPlaybackSessionManagerTest { ...@@ -73,7 +73,7 @@ public final class DefaultPlaybackSessionManagerTest {
@Test @Test
public void updateSessions_withMediaPeriodId_createsNewSession() { public void updateSessions_withMediaPeriodId_createsNewSession() {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
MediaPeriodId mediaPeriodId = MediaPeriodId mediaPeriodId =
new MediaPeriodId( new MediaPeriodId(
timeline.getUidOfPeriod(/* periodIndex= */ 0), /* windowSequenceNumber= */ 0); timeline.getUidOfPeriod(/* periodIndex= */ 0), /* windowSequenceNumber= */ 0);
...@@ -92,7 +92,7 @@ public final class DefaultPlaybackSessionManagerTest { ...@@ -92,7 +92,7 @@ public final class DefaultPlaybackSessionManagerTest {
@Test @Test
public void public void
updateSessions_ofSameWindow_withMediaPeriodId_afterWithoutMediaPeriodId_doesNotCreateNewSession() { updateSessions_ofSameWindow_withMediaPeriodId_afterWithoutMediaPeriodId_doesNotCreateNewSession() {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
MediaPeriodId mediaPeriodId = MediaPeriodId mediaPeriodId =
new MediaPeriodId( new MediaPeriodId(
timeline.getUidOfPeriod(/* periodIndex= */ 0), /* windowSequenceNumber= */ 0); timeline.getUidOfPeriod(/* periodIndex= */ 0), /* windowSequenceNumber= */ 0);
...@@ -113,7 +113,7 @@ public final class DefaultPlaybackSessionManagerTest { ...@@ -113,7 +113,7 @@ public final class DefaultPlaybackSessionManagerTest {
@Test @Test
public void updateSessions_ofSameWindow_withAd_afterWithoutMediaPeriodId_createsNewSession() { public void updateSessions_ofSameWindow_withAd_afterWithoutMediaPeriodId_createsNewSession() {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
MediaPeriodId mediaPeriodId = MediaPeriodId mediaPeriodId =
new MediaPeriodId( new MediaPeriodId(
timeline.getUidOfPeriod(/* periodIndex= */ 0), timeline.getUidOfPeriod(/* periodIndex= */ 0),
...@@ -141,7 +141,7 @@ public final class DefaultPlaybackSessionManagerTest { ...@@ -141,7 +141,7 @@ public final class DefaultPlaybackSessionManagerTest {
@Test @Test
public void public void
updateSessions_ofSameWindow_withoutMediaPeriodId_afterMediaPeriodId_doesNotCreateNewSession() { updateSessions_ofSameWindow_withoutMediaPeriodId_afterMediaPeriodId_doesNotCreateNewSession() {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
MediaPeriodId mediaPeriodId = MediaPeriodId mediaPeriodId =
new MediaPeriodId( new MediaPeriodId(
timeline.getUidOfPeriod(/* periodIndex= */ 0), /* windowSequenceNumber= */ 0); timeline.getUidOfPeriod(/* periodIndex= */ 0), /* windowSequenceNumber= */ 0);
...@@ -310,7 +310,7 @@ public final class DefaultPlaybackSessionManagerTest { ...@@ -310,7 +310,7 @@ public final class DefaultPlaybackSessionManagerTest {
@Test @Test
public void updateSessions_ofSameWindow_withNewWindowSequenceNumber_createsNewSession() { public void updateSessions_ofSameWindow_withNewWindowSequenceNumber_createsNewSession() {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
MediaPeriodId mediaPeriodId1 = MediaPeriodId mediaPeriodId1 =
new MediaPeriodId( new MediaPeriodId(
timeline.getUidOfPeriod(/* periodIndex= */ 0), /* windowSequenceNumber= */ 0); timeline.getUidOfPeriod(/* periodIndex= */ 0), /* windowSequenceNumber= */ 0);
...@@ -339,7 +339,7 @@ public final class DefaultPlaybackSessionManagerTest { ...@@ -339,7 +339,7 @@ public final class DefaultPlaybackSessionManagerTest {
@Test @Test
public void public void
updateSessions_withoutMediaPeriodId_andPreviouslyCreatedSessions_doesNotCreateNewSession() { updateSessions_withoutMediaPeriodId_andPreviouslyCreatedSessions_doesNotCreateNewSession() {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
MediaPeriodId mediaPeriodId1 = MediaPeriodId mediaPeriodId1 =
new MediaPeriodId( new MediaPeriodId(
timeline.getUidOfPeriod(/* periodIndex= */ 0), /* windowSequenceNumber= */ 0); timeline.getUidOfPeriod(/* periodIndex= */ 0), /* windowSequenceNumber= */ 0);
...@@ -372,7 +372,7 @@ public final class DefaultPlaybackSessionManagerTest { ...@@ -372,7 +372,7 @@ public final class DefaultPlaybackSessionManagerTest {
@Test @Test
public void updateSessions_afterSessionForMediaPeriodId_withSameMediaPeriodId_returnsSameValue() { public void updateSessions_afterSessionForMediaPeriodId_withSameMediaPeriodId_returnsSameValue() {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
MediaPeriodId mediaPeriodId = MediaPeriodId mediaPeriodId =
new MediaPeriodId( new MediaPeriodId(
timeline.getUidOfPeriod(/* periodIndex= */ 0), /* windowSequenceNumber= */ 0); timeline.getUidOfPeriod(/* periodIndex= */ 0), /* windowSequenceNumber= */ 0);
...@@ -390,7 +390,7 @@ public final class DefaultPlaybackSessionManagerTest { ...@@ -390,7 +390,7 @@ public final class DefaultPlaybackSessionManagerTest {
@Test @Test
public void updateSessions_withoutMediaPeriodId_afterSessionForMediaPeriodId_returnsSameValue() { public void updateSessions_withoutMediaPeriodId_afterSessionForMediaPeriodId_returnsSameValue() {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
MediaPeriodId mediaPeriodId = MediaPeriodId mediaPeriodId =
new MediaPeriodId( new MediaPeriodId(
timeline.getUidOfPeriod(/* periodIndex= */ 0), /* windowSequenceNumber= */ 0); timeline.getUidOfPeriod(/* periodIndex= */ 0), /* windowSequenceNumber= */ 0);
...@@ -474,7 +474,7 @@ public final class DefaultPlaybackSessionManagerTest { ...@@ -474,7 +474,7 @@ public final class DefaultPlaybackSessionManagerTest {
@Test @Test
public void getSessionForMediaPeriodId_returnsValue_butDoesNotCreateSession() { public void getSessionForMediaPeriodId_returnsValue_butDoesNotCreateSession() {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
MediaPeriodId mediaPeriodId = MediaPeriodId mediaPeriodId =
new MediaPeriodId( new MediaPeriodId(
timeline.getUidOfPeriod(/* periodIndex= */ 0), /* windowSequenceNumber= */ 0); timeline.getUidOfPeriod(/* periodIndex= */ 0), /* windowSequenceNumber= */ 0);
...@@ -488,7 +488,7 @@ public final class DefaultPlaybackSessionManagerTest { ...@@ -488,7 +488,7 @@ public final class DefaultPlaybackSessionManagerTest {
public void belongsToSession_withSameWindowIndex_returnsTrue() { public void belongsToSession_withSameWindowIndex_returnsTrue() {
EventTime eventTime = EventTime eventTime =
createEventTime(Timeline.EMPTY, /* windowIndex= */ 0, /* mediaPeriodId= */ null); createEventTime(Timeline.EMPTY, /* windowIndex= */ 0, /* mediaPeriodId= */ null);
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
EventTime eventTimeWithTimeline = EventTime eventTimeWithTimeline =
createEventTime(timeline, /* windowIndex= */ 0, /* mediaPeriodId= */ null); createEventTime(timeline, /* windowIndex= */ 0, /* mediaPeriodId= */ null);
MediaPeriodId mediaPeriodId = MediaPeriodId mediaPeriodId =
...@@ -532,7 +532,7 @@ public final class DefaultPlaybackSessionManagerTest { ...@@ -532,7 +532,7 @@ public final class DefaultPlaybackSessionManagerTest {
@Test @Test
public void belongsToSession_withOtherWindowSequenceNumber_returnsFalse() { public void belongsToSession_withOtherWindowSequenceNumber_returnsFalse() {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
MediaPeriodId mediaPeriodId1 = MediaPeriodId mediaPeriodId1 =
new MediaPeriodId( new MediaPeriodId(
timeline.getUidOfPeriod(/* periodIndex= */ 0), /* windowSequenceNumber= */ 0); timeline.getUidOfPeriod(/* periodIndex= */ 0), /* windowSequenceNumber= */ 0);
...@@ -592,7 +592,7 @@ public final class DefaultPlaybackSessionManagerTest { ...@@ -592,7 +592,7 @@ public final class DefaultPlaybackSessionManagerTest {
createEventTime(Timeline.EMPTY, /* windowIndex= */ 1, /* mediaPeriodId= */ null); createEventTime(Timeline.EMPTY, /* windowIndex= */ 1, /* mediaPeriodId= */ null);
sessionManager.updateSessions(eventTime1); sessionManager.updateSessions(eventTime1);
sessionManager.updateSessions(eventTime2); sessionManager.updateSessions(eventTime2);
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
EventTime newTimelineEventTime = EventTime newTimelineEventTime =
createEventTime(timeline, /* windowIndex= */ 0, /* mediaPeriodId= */ null); createEventTime(timeline, /* windowIndex= */ 0, /* mediaPeriodId= */ null);
...@@ -827,7 +827,7 @@ public final class DefaultPlaybackSessionManagerTest { ...@@ -827,7 +827,7 @@ public final class DefaultPlaybackSessionManagerTest {
@Test @Test
public void positionDiscontinuity_toSameWindow_withoutMediaPeriodId_doesNotFinishSession() { public void positionDiscontinuity_toSameWindow_withoutMediaPeriodId_doesNotFinishSession() {
Timeline timeline = new FakeTimeline(/* windowCount= */ 1); Timeline timeline = new FakeTimeline();
EventTime eventTime1 = EventTime eventTime1 =
createEventTime( createEventTime(
timeline, timeline,
......
...@@ -50,7 +50,7 @@ public final class PlaybackStatsListenerTest { ...@@ -50,7 +50,7 @@ public final class PlaybackStatsListenerTest {
/* currentMediaPeriodId= */ null, /* currentMediaPeriodId= */ null,
/* currentPlaybackPositionMs= */ 0, /* currentPlaybackPositionMs= */ 0,
/* totalBufferedDurationMs= */ 0); /* totalBufferedDurationMs= */ 0);
private static final Timeline TEST_TIMELINE = new FakeTimeline(/* windowCount= */ 1); private static final Timeline TEST_TIMELINE = new FakeTimeline();
private static final MediaSource.MediaPeriodId TEST_MEDIA_PERIOD_ID = private static final MediaSource.MediaPeriodId TEST_MEDIA_PERIOD_ID =
new MediaSource.MediaPeriodId( new MediaSource.MediaPeriodId(
TEST_TIMELINE.getPeriod(/* periodIndex= */ 0, new Timeline.Period(), /* setIds= */ true) TEST_TIMELINE.getPeriod(/* periodIndex= */ 0, new Timeline.Period(), /* setIds= */ true)
......
...@@ -854,7 +854,7 @@ public final class ConcatenatingMediaSourceTest { ...@@ -854,7 +854,7 @@ public final class ConcatenatingMediaSourceTest {
@Test @Test
public void duplicateNestedMediaSources() throws IOException, InterruptedException { public void duplicateNestedMediaSources() throws IOException, InterruptedException {
Timeline childTimeline = new FakeTimeline(/* windowCount= */ 1); Timeline childTimeline = new FakeTimeline();
FakeMediaSource childSource = new FakeMediaSource(childTimeline); FakeMediaSource childSource = new FakeMediaSource(childTimeline);
ConcatenatingMediaSource nestedConcatenation = new ConcatenatingMediaSource(); ConcatenatingMediaSource nestedConcatenation = new ConcatenatingMediaSource();
......
...@@ -110,7 +110,7 @@ public final class DefaultTrackSelectorTest { ...@@ -110,7 +110,7 @@ public final class DefaultTrackSelectorTest {
private static final TrackSelection[] TRACK_SELECTIONS_WITH_NO_SAMPLE_RENDERER = private static final TrackSelection[] TRACK_SELECTIONS_WITH_NO_SAMPLE_RENDERER =
new TrackSelection[] {new FixedTrackSelection(VIDEO_TRACK_GROUP, 0), null}; new TrackSelection[] {new FixedTrackSelection(VIDEO_TRACK_GROUP, 0), null};
private static final Timeline TIMELINE = new FakeTimeline(/* windowCount= */ 1); private static final Timeline TIMELINE = new FakeTimeline();
private static MediaPeriodId periodId; private static MediaPeriodId periodId;
......
...@@ -52,7 +52,7 @@ public final class MappingTrackSelectorTest { ...@@ -52,7 +52,7 @@ public final class MappingTrackSelectorTest {
private static final TrackGroup AUDIO_TRACK_GROUP = buildTrackGroup(MimeTypes.AUDIO_AAC); private static final TrackGroup AUDIO_TRACK_GROUP = buildTrackGroup(MimeTypes.AUDIO_AAC);
private static final TrackGroup METADATA_TRACK_GROUP = buildTrackGroup(MimeTypes.APPLICATION_ID3); private static final TrackGroup METADATA_TRACK_GROUP = buildTrackGroup(MimeTypes.APPLICATION_ID3);
private static final Timeline TIMELINE = new FakeTimeline(/* windowCount= */ 1); private static final Timeline TIMELINE = new FakeTimeline();
private static MediaPeriodId periodId; private static MediaPeriodId periodId;
......
...@@ -92,6 +92,11 @@ public class FakeMediaSource extends BaseMediaSource { ...@@ -92,6 +92,11 @@ public class FakeMediaSource extends BaseMediaSource {
@Nullable private Handler sourceInfoRefreshHandler; @Nullable private Handler sourceInfoRefreshHandler;
@Nullable private TransferListener transferListener; @Nullable private TransferListener transferListener;
/** Creates a {@link FakeMediaSource} with a default {@link FakeTimeline}. */
public FakeMediaSource() {
this(new FakeTimeline());
}
/** /**
* Creates a {@link FakeMediaSource}. This media source creates {@link FakeMediaPeriod}s with a * Creates a {@link FakeMediaSource}. This media source creates {@link FakeMediaPeriod}s with a
* {@link TrackGroupArray} using the given {@link Format}s. The provided {@link Timeline} may be * {@link TrackGroupArray} using the given {@link Format}s. The provided {@link Timeline} may be
......
...@@ -267,6 +267,14 @@ public final class FakeTimeline extends Timeline { ...@@ -267,6 +267,14 @@ public final class FakeTimeline extends Timeline {
} }
/** /**
* Create a fake timeline with one seekable, non-dynamic window with one period and a duration of
* {@link TimelineWindowDefinition#DEFAULT_WINDOW_DURATION_US}.
*/
public FakeTimeline() {
this(/* windowCount= */ 1);
}
/**
* Creates a fake timeline with the given number of seekable, non-dynamic windows with one period * Creates a fake timeline with the given number of seekable, non-dynamic windows with one period
* with a duration of {@link TimelineWindowDefinition#DEFAULT_WINDOW_DURATION_US} each. * with a duration of {@link TimelineWindowDefinition#DEFAULT_WINDOW_DURATION_US} each.
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment