Search in sources :

Example 11 with FakeShuffleOrder

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

the class ExoPlayerTest method restartAfterEmptyTimelineWithShuffleModeEnabledUsesCorrectFirstPeriod.

@Test
public void restartAfterEmptyTimelineWithShuffleModeEnabledUsesCorrectFirstPeriod() throws Exception {
    ConcatenatingMediaSource concatenatingMediaSource = new ConcatenatingMediaSource(/* isAtomic= */
    false, new FakeShuffleOrder(0));
    AtomicInteger mediaItemIndexAfterAddingSources = new AtomicInteger();
    ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG).setShuffleModeEnabled(true).waitForPlaybackState(Player.STATE_ENDED).executeRunnable(() -> concatenatingMediaSource.addMediaSources(ImmutableList.of(new FakeMediaSource(), new FakeMediaSource()))).waitForTimelineChanged().executeRunnable(new PlayerRunnable() {

        @Override
        public void run(ExoPlayer player) {
            mediaItemIndexAfterAddingSources.set(player.getCurrentMediaItemIndex());
        }
    }).build();
    new ExoPlayerTestRunner.Builder(context).setMediaSources(concatenatingMediaSource).setActionSchedule(actionSchedule).build().start().blockUntilActionScheduleFinished(TIMEOUT_MS).blockUntilEnded(TIMEOUT_MS);
    assertThat(mediaItemIndexAfterAddingSources.get()).isEqualTo(1);
}
Also used : FakeMediaSource(com.google.android.exoplayer2.testutil.FakeMediaSource) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ActionSchedule(com.google.android.exoplayer2.testutil.ActionSchedule) PlayerRunnable(com.google.android.exoplayer2.testutil.ActionSchedule.PlayerRunnable) TestExoPlayerBuilder(com.google.android.exoplayer2.testutil.TestExoPlayerBuilder) ConcatenatingMediaSource(com.google.android.exoplayer2.source.ConcatenatingMediaSource) FakeShuffleOrder(com.google.android.exoplayer2.testutil.FakeShuffleOrder) Test(org.junit.Test)

Example 12 with FakeShuffleOrder

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

the class ExoPlayerTest method resetMediaSourcesWithPositionResetAndShufflingUsesFirstPeriod.

@Test
public void resetMediaSourcesWithPositionResetAndShufflingUsesFirstPeriod() throws Exception {
    Timeline fakeTimeline = new FakeTimeline(new TimelineWindowDefinition(/* isSeekable= */
    true, /* isDynamic= */
    false, /* durationUs= */
    100000));
    ConcatenatingMediaSource firstMediaSource = new ConcatenatingMediaSource(/* isAtomic= */
    false, new FakeShuffleOrder(/* length= */
    2), new FakeMediaSource(fakeTimeline, ExoPlayerTestRunner.VIDEO_FORMAT), new FakeMediaSource(fakeTimeline, ExoPlayerTestRunner.VIDEO_FORMAT));
    ConcatenatingMediaSource secondMediaSource = new ConcatenatingMediaSource(/* isAtomic= */
    false, new FakeShuffleOrder(/* length= */
    2), new FakeMediaSource(fakeTimeline, ExoPlayerTestRunner.VIDEO_FORMAT), new FakeMediaSource(fakeTimeline, ExoPlayerTestRunner.VIDEO_FORMAT));
    ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG).pause().waitForPlaybackState(Player.STATE_READY).setShuffleModeEnabled(true).setMediaSources(/* resetPosition= */
    true, secondMediaSource).play().waitForPositionDiscontinuity().build();
    ExoPlayerTestRunner testRunner = new ExoPlayerTestRunner.Builder(context).setMediaSources(firstMediaSource).setActionSchedule(actionSchedule).build().start().blockUntilActionScheduleFinished(TIMEOUT_MS).blockUntilEnded(TIMEOUT_MS);
    testRunner.assertPlayedPeriodIndices(0, 1, 0);
}
Also used : NoUidTimeline(com.google.android.exoplayer2.testutil.NoUidTimeline) SinglePeriodTimeline(com.google.android.exoplayer2.source.SinglePeriodTimeline) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) FakeMediaSource(com.google.android.exoplayer2.testutil.FakeMediaSource) ActionSchedule(com.google.android.exoplayer2.testutil.ActionSchedule) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) TestExoPlayerBuilder(com.google.android.exoplayer2.testutil.TestExoPlayerBuilder) TimelineWindowDefinition(com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition) ConcatenatingMediaSource(com.google.android.exoplayer2.source.ConcatenatingMediaSource) ExoPlayerTestRunner(com.google.android.exoplayer2.testutil.ExoPlayerTestRunner) FakeShuffleOrder(com.google.android.exoplayer2.testutil.FakeShuffleOrder) Test(org.junit.Test)

Example 13 with FakeShuffleOrder

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

the class MediaSourceListTest method addMediaSources_expectTimelineUsesCustomShuffleOrder.

@Test
public void addMediaSources_expectTimelineUsesCustomShuffleOrder() {
    Timeline timeline = mediaSourceList.addMediaSources(/* index= */
    0, createFakeHolders(), new FakeShuffleOrder(MEDIA_SOURCE_LIST_SIZE));
    assertTimelineUsesFakeShuffleOrder(timeline);
}
Also used : FakeShuffleOrder(com.google.android.exoplayer2.testutil.FakeShuffleOrder) Test(org.junit.Test)

Example 14 with FakeShuffleOrder

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

the class MediaSourceListTest method moveMediaSources_expectTimelineUsesCustomShuffleOrder.

@Test
public void moveMediaSources_expectTimelineUsesCustomShuffleOrder() {
    ShuffleOrder shuffleOrder = new ShuffleOrder.DefaultShuffleOrder(/* length= */
    MEDIA_SOURCE_LIST_SIZE);
    mediaSourceList.addMediaSources(/* index= */
    0, createFakeHolders(), shuffleOrder);
    Timeline timeline = mediaSourceList.moveMediaSource(/* currentIndex= */
    0, /* newIndex= */
    1, new FakeShuffleOrder(MEDIA_SOURCE_LIST_SIZE));
    assertTimelineUsesFakeShuffleOrder(timeline);
}
Also used : ShuffleOrder(com.google.android.exoplayer2.source.ShuffleOrder) FakeShuffleOrder(com.google.android.exoplayer2.testutil.FakeShuffleOrder) FakeShuffleOrder(com.google.android.exoplayer2.testutil.FakeShuffleOrder) Test(org.junit.Test)

Example 15 with FakeShuffleOrder

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

the class MediaSourceListTest method moveMediaSourceRange_expectTimelineUsesCustomShuffleOrder.

@Test
public void moveMediaSourceRange_expectTimelineUsesCustomShuffleOrder() {
    ShuffleOrder shuffleOrder = new ShuffleOrder.DefaultShuffleOrder(/* length= */
    MEDIA_SOURCE_LIST_SIZE);
    mediaSourceList.addMediaSources(/* index= */
    0, createFakeHolders(), shuffleOrder);
    Timeline timeline = mediaSourceList.moveMediaSourceRange(/* fromIndex= */
    0, /* toIndex= */
    2, /* newFromIndex= */
    2, new FakeShuffleOrder(MEDIA_SOURCE_LIST_SIZE));
    assertTimelineUsesFakeShuffleOrder(timeline);
}
Also used : ShuffleOrder(com.google.android.exoplayer2.source.ShuffleOrder) FakeShuffleOrder(com.google.android.exoplayer2.testutil.FakeShuffleOrder) FakeShuffleOrder(com.google.android.exoplayer2.testutil.FakeShuffleOrder) Test(org.junit.Test)

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