Search in sources :

Example 6 with FakeShuffleOrder

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

the class MediaPeriodQueueTest method setupTimeline.

private void setupTimeline(Timeline timeline) {
    fakeMediaSource = new FakeMediaSource(timeline);
    MediaSourceList.MediaSourceHolder mediaSourceHolder = new MediaSourceList.MediaSourceHolder(fakeMediaSource, /* useLazyPreparation= */
    false);
    mediaSourceList.setMediaSources(ImmutableList.of(mediaSourceHolder), new FakeShuffleOrder(/* length= */
    1));
    mediaSourceHolder.mediaSource.prepareSource(mock(MediaSourceCaller.class), /* mediaTransferListener */
    null, PlayerId.UNSET);
    Timeline playlistTimeline = mediaSourceList.createTimeline();
    firstPeriodUid = playlistTimeline.getUidOfPeriod(/* periodIndex= */
    0);
    playbackInfo = new PlaybackInfo(playlistTimeline, mediaPeriodQueue.resolveMediaPeriodIdForAds(playlistTimeline, firstPeriodUid, /* positionUs= */
    0), /* requestedContentPositionUs= */
    C.TIME_UNSET, /* discontinuityStartPositionUs= */
    0, Player.STATE_READY, /* playbackError= */
    null, /* isLoading= */
    false, /* trackGroups= */
    null, /* trackSelectorResult= */
    null, /* staticMetadata= */
    ImmutableList.of(), /* loadingMediaPeriodId= */
    null, /* playWhenReady= */
    false, Player.PLAYBACK_SUPPRESSION_REASON_NONE, /* playbackParameters= */
    PlaybackParameters.DEFAULT, /* bufferedPositionUs= */
    0, /* totalBufferedDurationUs= */
    0, /* positionUs= */
    0, /* offloadSchedulingEnabled= */
    false, /* sleepingForOffload= */
    false);
}
Also used : MediaSourceCaller(com.google.android.exoplayer2.source.MediaSource.MediaSourceCaller) SinglePeriodTimeline(com.google.android.exoplayer2.source.SinglePeriodTimeline) SinglePeriodAdTimeline(com.google.android.exoplayer2.source.ads.SinglePeriodAdTimeline) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) FakeMediaSource(com.google.android.exoplayer2.testutil.FakeMediaSource) FakeShuffleOrder(com.google.android.exoplayer2.testutil.FakeShuffleOrder)

Example 7 with FakeShuffleOrder

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

the class MediaSourceListTest method setMediaSources_expectTimelineUsesCustomShuffleOrder.

@Test
public void setMediaSources_expectTimelineUsesCustomShuffleOrder() {
    Timeline timeline = mediaSourceList.setMediaSources(createFakeHolders(), new FakeShuffleOrder(/* length=*/
    4));
    assertTimelineUsesFakeShuffleOrder(timeline);
}
Also used : FakeShuffleOrder(com.google.android.exoplayer2.testutil.FakeShuffleOrder) Test(org.junit.Test)

Example 8 with FakeShuffleOrder

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

the class ExoPlayerTest method setShuffleOrder_keepsCurrentPosition.

@Test
public void setShuffleOrder_keepsCurrentPosition() throws Exception {
    AtomicLong positionAfterSetShuffleOrder = new AtomicLong(C.TIME_UNSET);
    ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG).playUntilPosition(0, 5000).setShuffleOrder(new FakeShuffleOrder(/* length= */
    1)).executeRunnable(new PlayerRunnable() {

        @Override
        public void run(ExoPlayer player) {
            positionAfterSetShuffleOrder.set(player.getCurrentPosition());
        }
    }).play().build();
    new ExoPlayerTestRunner.Builder(context).setActionSchedule(actionSchedule).build().start().blockUntilEnded(TIMEOUT_MS);
    assertThat(positionAfterSetShuffleOrder.get()).isAtLeast(5000);
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) ActionSchedule(com.google.android.exoplayer2.testutil.ActionSchedule) PlayerRunnable(com.google.android.exoplayer2.testutil.ActionSchedule.PlayerRunnable) TestExoPlayerBuilder(com.google.android.exoplayer2.testutil.TestExoPlayerBuilder) FakeShuffleOrder(com.google.android.exoplayer2.testutil.FakeShuffleOrder) Test(org.junit.Test)

Example 9 with FakeShuffleOrder

use of com.google.android.exoplayer2.testutil.FakeShuffleOrder 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 10 with FakeShuffleOrder

use of com.google.android.exoplayer2.testutil.FakeShuffleOrder 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)

Aggregations

Test (org.junit.Test)16 FakeShuffleOrder (com.google.android.exoplayer2.testutil.FakeShuffleOrder)15 FakeTimeline (com.google.android.exoplayer2.testutil.FakeTimeline)9 FakeMediaSource (com.google.android.exoplayer2.testutil.FakeMediaSource)7 Timeline (com.google.android.exoplayer2.Timeline)5 ConcatenatingMediaSource (com.google.android.exoplayer2.source.ConcatenatingMediaSource)5 ActionSchedule (com.google.android.exoplayer2.testutil.ActionSchedule)5 TestExoPlayerBuilder (com.google.android.exoplayer2.testutil.TestExoPlayerBuilder)5 SinglePeriodTimeline (com.google.android.exoplayer2.source.SinglePeriodTimeline)4 ClippingMediaSource (com.google.android.exoplayer2.source.ClippingMediaSource)3 CompositeMediaSource (com.google.android.exoplayer2.source.CompositeMediaSource)3 MaskingMediaSource (com.google.android.exoplayer2.source.MaskingMediaSource)3 MediaSource (com.google.android.exoplayer2.source.MediaSource)3 ShuffleOrder (com.google.android.exoplayer2.source.ShuffleOrder)3 ServerSideAdInsertionMediaSource (com.google.android.exoplayer2.source.ads.ServerSideAdInsertionMediaSource)3 ExoPlayerTestRunner (com.google.android.exoplayer2.testutil.ExoPlayerTestRunner)3 FakeAdaptiveMediaSource (com.google.android.exoplayer2.testutil.FakeAdaptiveMediaSource)3 NoUidTimeline (com.google.android.exoplayer2.testutil.NoUidTimeline)3 PlayerRunnable (com.google.android.exoplayer2.testutil.ActionSchedule.PlayerRunnable)2 MediaSourceTestRunner (com.google.android.exoplayer2.testutil.MediaSourceTestRunner)2