Search in sources :

Example 6 with MediaSourceTestRunner

use of com.google.android.exoplayer2.testutil.MediaSourceTestRunner in project ExoPlayer by google.

the class ClippingMediaSourceTest method getClippedTimelines.

private static Timeline[] getClippedTimelines(FakeMediaSource fakeMediaSource, ClippingMediaSource clippingMediaSource, Timeline... additionalTimelines) throws IOException {
    MediaSourceTestRunner testRunner = new MediaSourceTestRunner(clippingMediaSource, /* allocator= */
    null);
    Timeline[] clippedTimelines = new Timeline[additionalTimelines.length + 1];
    try {
        clippedTimelines[0] = testRunner.prepareSource();
        MediaPeriod mediaPeriod = testRunner.createPeriod(new MediaPeriodId(clippedTimelines[0].getUidOfPeriod(/* periodIndex= */
        0), /* windowSequenceNumber= */
        0));
        for (int i = 0; i < additionalTimelines.length; i++) {
            fakeMediaSource.setNewSourceInfo(additionalTimelines[i]);
            clippedTimelines[i + 1] = testRunner.assertTimelineChangeBlocking();
        }
        testRunner.releasePeriod(mediaPeriod);
        testRunner.releaseSource();
        fakeMediaSource.assertReleased();
        return clippedTimelines;
    } finally {
        testRunner.release();
    }
}
Also used : PlaceholderTimeline(com.google.android.exoplayer2.source.MaskingMediaSource.PlaceholderTimeline) Timeline(com.google.android.exoplayer2.Timeline) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) MediaSourceTestRunner(com.google.android.exoplayer2.testutil.MediaSourceTestRunner) MediaPeriodId(com.google.android.exoplayer2.source.MediaSource.MediaPeriodId)

Example 7 with MediaSourceTestRunner

use of com.google.android.exoplayer2.testutil.MediaSourceTestRunner in project ExoPlayer by google.

the class ConcatenatingMediaSourceTest method removeUnpreparedChildSourceWithLazyPreparation.

@Test
public void removeUnpreparedChildSourceWithLazyPreparation() throws IOException {
    FakeMediaSource[] childSources = createMediaSources(/* count= */
    2);
    mediaSource = new ConcatenatingMediaSource(/* isAtomic= */
    false, /* useLazyPreparation= */
    true, new DefaultShuffleOrder(0), childSources);
    testRunner = new MediaSourceTestRunner(mediaSource, /* allocator= */
    null);
    testRunner.prepareSource();
    // Check that removal doesn't throw even though the child sources are unprepared.
    mediaSource.removeMediaSource(0);
}
Also used : MediaSourceTestRunner(com.google.android.exoplayer2.testutil.MediaSourceTestRunner) FakeMediaSource(com.google.android.exoplayer2.testutil.FakeMediaSource) DefaultShuffleOrder(com.google.android.exoplayer2.source.ShuffleOrder.DefaultShuffleOrder) Test(org.junit.Test)

Example 8 with MediaSourceTestRunner

use of com.google.android.exoplayer2.testutil.MediaSourceTestRunner in project ExoPlayer by google.

the class ConcatenatingMediaSourceTest method atomicTimelineWindowOrder.

@Test
public void atomicTimelineWindowOrder() throws IOException {
    // Release default test runner with non-atomic media source and replace with new test runner.
    testRunner.release();
    ConcatenatingMediaSource mediaSource = new ConcatenatingMediaSource(/* isAtomic= */
    true, new FakeShuffleOrder(0));
    testRunner = new MediaSourceTestRunner(mediaSource, null);
    mediaSource.addMediaSources(Arrays.asList(createMediaSources(3)));
    Timeline timeline = testRunner.prepareSource();
    TimelineAsserts.assertWindowTags(timeline, 111, 222, 333);
    TimelineAsserts.assertPeriodCounts(timeline, 1, 2, 3);
    TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_OFF, /* shuffleModeEnabled= */
    false, C.INDEX_UNSET, 0, 1);
    TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_OFF, /* shuffleModeEnabled= */
    true, C.INDEX_UNSET, 0, 1);
    TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ONE, /* shuffleModeEnabled= */
    false, 2, 0, 1);
    TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ONE, /* shuffleModeEnabled= */
    true, 2, 0, 1);
    TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ALL, /* shuffleModeEnabled= */
    false, 2, 0, 1);
    TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ALL, /* shuffleModeEnabled= */
    true, 2, 0, 1);
    TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_OFF, /* shuffleModeEnabled= */
    false, 1, 2, C.INDEX_UNSET);
    TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_OFF, /* shuffleModeEnabled= */
    true, 1, 2, C.INDEX_UNSET);
    TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ONE, /* shuffleModeEnabled= */
    false, 1, 2, 0);
    TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ONE, /* shuffleModeEnabled= */
    true, 1, 2, 0);
    TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ALL, /* shuffleModeEnabled= */
    false, 1, 2, 0);
    TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ALL, /* shuffleModeEnabled= */
    true, 1, 2, 0);
    assertThat(timeline.getFirstWindowIndex(/* shuffleModeEnabled= */
    false)).isEqualTo(0);
    assertThat(timeline.getFirstWindowIndex(/* shuffleModeEnabled= */
    true)).isEqualTo(0);
    assertThat(timeline.getLastWindowIndex(/* shuffleModeEnabled= */
    false)).isEqualTo(2);
    assertThat(timeline.getLastWindowIndex(/* shuffleModeEnabled= */
    true)).isEqualTo(2);
}
Also used : Timeline(com.google.android.exoplayer2.Timeline) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) MediaSourceTestRunner(com.google.android.exoplayer2.testutil.MediaSourceTestRunner) FakeShuffleOrder(com.google.android.exoplayer2.testutil.FakeShuffleOrder) Test(org.junit.Test)

Example 9 with MediaSourceTestRunner

use of com.google.android.exoplayer2.testutil.MediaSourceTestRunner in project ExoPlayer by google.

the class ConcatenatingMediaSourceTest method setUp.

@Before
public void setUp() throws Exception {
    mediaSource = new ConcatenatingMediaSource(/* isAtomic= */
    false, new FakeShuffleOrder(0));
    testRunner = new MediaSourceTestRunner(mediaSource, null);
}
Also used : MediaSourceTestRunner(com.google.android.exoplayer2.testutil.MediaSourceTestRunner) FakeShuffleOrder(com.google.android.exoplayer2.testutil.FakeShuffleOrder) Before(org.junit.Before)

Example 10 with MediaSourceTestRunner

use of com.google.android.exoplayer2.testutil.MediaSourceTestRunner in project ExoPlayer by google.

the class LoopingMediaSourceTest method getLoopingTimeline.

/**
 * Wraps the specified timeline in a {@link LoopingMediaSource} and returns the looping timeline.
 */
private static Timeline getLoopingTimeline(Timeline timeline, int loopCount) throws IOException {
    FakeMediaSource fakeMediaSource = new FakeMediaSource(timeline);
    LoopingMediaSource mediaSource = new LoopingMediaSource(fakeMediaSource, loopCount);
    MediaSourceTestRunner testRunner = new MediaSourceTestRunner(mediaSource, null);
    try {
        Timeline loopingTimeline = testRunner.prepareSource();
        testRunner.releaseSource();
        fakeMediaSource.assertReleased();
        return loopingTimeline;
    } finally {
        testRunner.release();
    }
}
Also used : Timeline(com.google.android.exoplayer2.Timeline) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) MediaSourceTestRunner(com.google.android.exoplayer2.testutil.MediaSourceTestRunner) FakeMediaSource(com.google.android.exoplayer2.testutil.FakeMediaSource)

Aggregations

MediaSourceTestRunner (com.google.android.exoplayer2.testutil.MediaSourceTestRunner)11 FakeMediaSource (com.google.android.exoplayer2.testutil.FakeMediaSource)8 FakeTimeline (com.google.android.exoplayer2.testutil.FakeTimeline)7 Timeline (com.google.android.exoplayer2.Timeline)6 Test (org.junit.Test)6 DefaultShuffleOrder (com.google.android.exoplayer2.source.ShuffleOrder.DefaultShuffleOrder)4 MediaPeriodId (com.google.android.exoplayer2.source.MediaSource.MediaPeriodId)3 FakeShuffleOrder (com.google.android.exoplayer2.testutil.FakeShuffleOrder)2 PlaceholderTimeline (com.google.android.exoplayer2.source.MaskingMediaSource.PlaceholderTimeline)1 Before (org.junit.Before)1