use of com.google.android.exoplayer2.testutil.FakeTimeline in project ExoPlayer by google.
the class ConcatenatingMediaSourceTest method dynamicChangeOfEmptyTimelines.
@Test
public void dynamicChangeOfEmptyTimelines() throws IOException {
FakeMediaSource[] childSources = new FakeMediaSource[] { new FakeMediaSource(Timeline.EMPTY), new FakeMediaSource(Timeline.EMPTY), new FakeMediaSource(Timeline.EMPTY) };
Timeline nonEmptyTimeline = new FakeTimeline(/* windowCount = */
1);
mediaSource.addMediaSources(Arrays.asList(childSources));
Timeline timeline = testRunner.prepareSource();
TimelineAsserts.assertEmpty(timeline);
childSources[0].setNewSourceInfo(nonEmptyTimeline);
timeline = testRunner.assertTimelineChangeBlocking();
TimelineAsserts.assertPeriodCounts(timeline, 1);
childSources[2].setNewSourceInfo(nonEmptyTimeline);
timeline = testRunner.assertTimelineChangeBlocking();
TimelineAsserts.assertPeriodCounts(timeline, 1, 1);
childSources[1].setNewSourceInfo(nonEmptyTimeline);
timeline = testRunner.assertTimelineChangeBlocking();
TimelineAsserts.assertPeriodCounts(timeline, 1, 1, 1);
}
use of com.google.android.exoplayer2.testutil.FakeTimeline in project ExoPlayer by google.
the class ConcatenatingMediaSourceTest method duplicateNestedMediaSources.
@Test
public void duplicateNestedMediaSources() throws IOException, InterruptedException {
Timeline childTimeline = new FakeTimeline();
FakeMediaSource childSource = new FakeMediaSource(childTimeline);
ConcatenatingMediaSource nestedConcatenation = new ConcatenatingMediaSource();
testRunner.prepareSource();
mediaSource.addMediaSources(Arrays.asList(childSource, nestedConcatenation, nestedConcatenation));
testRunner.assertTimelineChangeBlocking();
nestedConcatenation.addMediaSource(childSource);
testRunner.assertTimelineChangeBlocking();
nestedConcatenation.addMediaSource(childSource);
Timeline timeline = testRunner.assertTimelineChangeBlocking();
TimelineAsserts.assertPeriodCounts(timeline, 1, 1, 1, 1, 1);
testRunner.assertPrepareAndReleaseAllPeriods();
Object childPeriodUid = childTimeline.getUidOfPeriod(/* periodIndex= */
0);
assertThat(childSource.getCreatedMediaPeriods()).containsAtLeast(new MediaPeriodId(childPeriodUid, /* windowSequenceNumber= */
0), new MediaPeriodId(childPeriodUid, /* windowSequenceNumber= */
1), new MediaPeriodId(childPeriodUid, /* windowSequenceNumber= */
2), new MediaPeriodId(childPeriodUid, /* windowSequenceNumber= */
3), new MediaPeriodId(childPeriodUid, /* windowSequenceNumber= */
4));
// Assert that only one manifest load is needed because the source is reused.
testRunner.assertCompletedManifestLoads(/* windowIndices=... */
0);
assertCompletedAllMediaPeriodLoads(timeline);
testRunner.releaseSource();
childSource.assertReleased();
}
use of com.google.android.exoplayer2.testutil.FakeTimeline in project ExoPlayer by google.
the class LoopingMediaSourceTest method infiniteLoopTimeline.
@Test
public void infiniteLoopTimeline() throws IOException {
Timeline timeline = getLoopingTimeline(multiWindowTimeline, Integer.MAX_VALUE);
TimelineAsserts.assertWindowTags(timeline, 111, 222, 333);
TimelineAsserts.assertPeriodCounts(timeline, 1, 1, 1);
boolean shuffled = false;
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_OFF, shuffled, 2, 0, 1);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ONE, shuffled, 0, 1, 2);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ALL, shuffled, 2, 0, 1);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_OFF, shuffled, 1, 2, 0);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ONE, shuffled, 0, 1, 2);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ALL, shuffled, 1, 2, 0);
// FakeTimeline has FakeShuffleOrder which returns a reverse order.
shuffled = true;
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_OFF, shuffled, 1, 2, 0);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ONE, shuffled, 0, 1, 2);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ALL, shuffled, 1, 2, 0);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_OFF, shuffled, 2, 0, 1);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ONE, shuffled, 0, 1, 2);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ALL, shuffled, 2, 0, 1);
}
use of com.google.android.exoplayer2.testutil.FakeTimeline in project ExoPlayer by google.
the class MergingMediaSourceTest method prepare_withDurationClipping_usesDurationOfShortestSource.
@Test
public void prepare_withDurationClipping_usesDurationOfShortestSource() throws IOException {
FakeTimeline timeline1 = new FakeTimeline(new TimelineWindowDefinition(/* isSeekable= */
true, /* isDynamic= */
true, /* durationUs= */
30));
FakeTimeline timeline2 = new FakeTimeline(new TimelineWindowDefinition(/* isSeekable= */
true, /* isDynamic= */
true, /* durationUs= */
C.TIME_UNSET));
FakeTimeline timeline3 = new FakeTimeline(new TimelineWindowDefinition(/* isSeekable= */
true, /* isDynamic= */
true, /* durationUs= */
10));
Timeline mergedTimeline = prepareMergingMediaSource(/* clipDurations= */
true, timeline1, timeline2, timeline3);
assertThat(mergedTimeline).isEqualTo(timeline3);
}
use of com.google.android.exoplayer2.testutil.FakeTimeline in project ExoPlayer by google.
the class ClippingMediaSourceTest method windowAndPeriodIndices.
@Test
public void windowAndPeriodIndices() throws IOException {
Timeline timeline = new FakeTimeline(new TimelineWindowDefinition(1, 111, true, false, TEST_PERIOD_DURATION_US));
Timeline clippedTimeline = getClippedTimeline(timeline, TEST_CLIP_AMOUNT_US, TEST_PERIOD_DURATION_US - TEST_CLIP_AMOUNT_US);
TimelineAsserts.assertWindowTags(clippedTimeline, 111);
TimelineAsserts.assertPeriodCounts(clippedTimeline, 1);
TimelineAsserts.assertPreviousWindowIndices(clippedTimeline, Player.REPEAT_MODE_OFF, false, C.INDEX_UNSET);
TimelineAsserts.assertPreviousWindowIndices(clippedTimeline, Player.REPEAT_MODE_ONE, false, 0);
TimelineAsserts.assertPreviousWindowIndices(clippedTimeline, Player.REPEAT_MODE_ALL, false, 0);
TimelineAsserts.assertNextWindowIndices(clippedTimeline, Player.REPEAT_MODE_OFF, false, C.INDEX_UNSET);
TimelineAsserts.assertNextWindowIndices(clippedTimeline, Player.REPEAT_MODE_ONE, false, 0);
TimelineAsserts.assertNextWindowIndices(clippedTimeline, Player.REPEAT_MODE_ALL, false, 0);
}
Aggregations