Search in sources :

Example 36 with FakeTimeline

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);
}
Also used : Timeline(com.google.android.exoplayer2.Timeline) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) FakeMediaSource(com.google.android.exoplayer2.testutil.FakeMediaSource) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) Test(org.junit.Test)

Example 37 with FakeTimeline

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();
}
Also used : Timeline(com.google.android.exoplayer2.Timeline) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) FakeMediaSource(com.google.android.exoplayer2.testutil.FakeMediaSource) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) MediaPeriodId(com.google.android.exoplayer2.source.MediaSource.MediaPeriodId) Test(org.junit.Test)

Example 38 with FakeTimeline

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);
}
Also used : Timeline(com.google.android.exoplayer2.Timeline) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) Test(org.junit.Test)

Example 39 with FakeTimeline

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);
}
Also used : Timeline(com.google.android.exoplayer2.Timeline) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) TimelineWindowDefinition(com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition) Test(org.junit.Test)

Example 40 with FakeTimeline

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);
}
Also used : PlaceholderTimeline(com.google.android.exoplayer2.source.MaskingMediaSource.PlaceholderTimeline) Timeline(com.google.android.exoplayer2.Timeline) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) TimelineWindowDefinition(com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition) Test(org.junit.Test)

Aggregations

FakeTimeline (com.google.android.exoplayer2.testutil.FakeTimeline)242 Test (org.junit.Test)240 FakeMediaSource (com.google.android.exoplayer2.testutil.FakeMediaSource)159 TestExoPlayerBuilder (com.google.android.exoplayer2.testutil.TestExoPlayerBuilder)136 SinglePeriodTimeline (com.google.android.exoplayer2.source.SinglePeriodTimeline)118 TimelineWindowDefinition (com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition)117 NoUidTimeline (com.google.android.exoplayer2.testutil.NoUidTimeline)117 ActionSchedule (com.google.android.exoplayer2.testutil.ActionSchedule)98 ExoPlayerTestRunner (com.google.android.exoplayer2.testutil.ExoPlayerTestRunner)87 MediaPeriodId (com.google.android.exoplayer2.source.MediaSource.MediaPeriodId)69 ConcatenatingMediaSource (com.google.android.exoplayer2.source.ConcatenatingMediaSource)62 AdPlaybackState (com.google.android.exoplayer2.source.ads.AdPlaybackState)62 MediaSource (com.google.android.exoplayer2.source.MediaSource)60 PlayerRunnable (com.google.android.exoplayer2.testutil.ActionSchedule.PlayerRunnable)60 Timeline (com.google.android.exoplayer2.Timeline)53 ServerSideAdInsertionMediaSource (com.google.android.exoplayer2.source.ads.ServerSideAdInsertionMediaSource)50 ClippingMediaSource (com.google.android.exoplayer2.source.ClippingMediaSource)49 CompositeMediaSource (com.google.android.exoplayer2.source.CompositeMediaSource)49 MaskingMediaSource (com.google.android.exoplayer2.source.MaskingMediaSource)49 FakeAdaptiveMediaSource (com.google.android.exoplayer2.testutil.FakeAdaptiveMediaSource)49