use of com.google.android.exoplayer2.testutil.FakeShuffleOrder in project ExoPlayer by google.
the class ExoPlayerTest method setShuffleModeEnabled_notifiesAvailableCommandsChanged.
@Test
public void setShuffleModeEnabled_notifiesAvailableCommandsChanged() {
Player.Commands commandsWithSeekToPreviousWindow = createWithDefaultCommands(COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM);
Player.Commands commandsWithSeekToNextWindow = createWithDefaultCommands(COMMAND_SEEK_TO_NEXT_MEDIA_ITEM, COMMAND_SEEK_TO_NEXT);
Player.Listener mockListener = mock(Player.Listener.class);
ExoPlayer player = new TestExoPlayerBuilder(context).build();
player.addListener(mockListener);
MediaSource mediaSource = new ConcatenatingMediaSource(false, new FakeShuffleOrder(/* length= */
2), new FakeMediaSource(), new FakeMediaSource());
player.addMediaSource(mediaSource);
verify(mockListener).onAvailableCommandsChanged(commandsWithSeekToNextWindow);
// Check that there were no other calls to onAvailableCommandsChanged.
verify(mockListener).onAvailableCommandsChanged(any());
player.setShuffleModeEnabled(true);
verify(mockListener).onAvailableCommandsChanged(commandsWithSeekToPreviousWindow);
verify(mockListener, times(2)).onAvailableCommandsChanged(any());
}
use of com.google.android.exoplayer2.testutil.FakeShuffleOrder in project ExoPlayer by google.
the class ConcatenatingMediaSourceTest method nestedTimeline.
@Test
public void nestedTimeline() throws IOException {
ConcatenatingMediaSource nestedSource1 = new ConcatenatingMediaSource(/* isAtomic= */
false, new FakeShuffleOrder(0));
ConcatenatingMediaSource nestedSource2 = new ConcatenatingMediaSource(/* isAtomic= */
true, new FakeShuffleOrder(0));
mediaSource.addMediaSource(nestedSource1);
mediaSource.addMediaSource(nestedSource2);
testRunner.prepareSource();
FakeMediaSource[] childSources = createMediaSources(4);
nestedSource1.addMediaSource(childSources[0]);
testRunner.assertTimelineChangeBlocking();
nestedSource1.addMediaSource(childSources[1]);
testRunner.assertTimelineChangeBlocking();
nestedSource2.addMediaSource(childSources[2]);
testRunner.assertTimelineChangeBlocking();
nestedSource2.addMediaSource(childSources[3]);
Timeline timeline = testRunner.assertTimelineChangeBlocking();
TimelineAsserts.assertWindowTags(timeline, 111, 222, 333, 444);
TimelineAsserts.assertPeriodCounts(timeline, 1, 2, 3, 4);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_OFF, /* shuffleModeEnabled= */
false, C.INDEX_UNSET, 0, 1, 2);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ONE, /* shuffleModeEnabled= */
false, 0, 1, 3, 2);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ALL, /* shuffleModeEnabled= */
false, 3, 0, 1, 2);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_OFF, /* shuffleModeEnabled= */
false, 1, 2, 3, C.INDEX_UNSET);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ONE, /* shuffleModeEnabled= */
false, 0, 1, 3, 2);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ALL, /* shuffleModeEnabled= */
false, 1, 2, 3, 0);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_OFF, /* shuffleModeEnabled= */
true, 1, 3, C.INDEX_UNSET, 2);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ONE, /* shuffleModeEnabled= */
true, 0, 1, 3, 2);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ALL, /* shuffleModeEnabled= */
true, 1, 3, 0, 2);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_OFF, /* shuffleModeEnabled= */
true, C.INDEX_UNSET, 0, 3, 1);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ONE, /* shuffleModeEnabled= */
true, 0, 1, 3, 2);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ALL, /* shuffleModeEnabled= */
true, 2, 0, 3, 1);
}
use of com.google.android.exoplayer2.testutil.FakeShuffleOrder 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.FakeShuffleOrder in project ExoPlayer by google.
the class MediaSourceListTest method removeMediaSourceRange_expectTimelineUsesCustomShuffleOrder.
@Test
public void removeMediaSourceRange_expectTimelineUsesCustomShuffleOrder() {
ShuffleOrder shuffleOrder = new ShuffleOrder.DefaultShuffleOrder(/* length= */
MEDIA_SOURCE_LIST_SIZE);
mediaSourceList.addMediaSources(/* index= */
0, createFakeHolders(), shuffleOrder);
Timeline timeline = mediaSourceList.removeMediaSourceRange(/* fromIndex= */
0, /* toIndex= */
2, new FakeShuffleOrder(/* length= */
2));
assertTimelineUsesFakeShuffleOrder(timeline);
}
use of com.google.android.exoplayer2.testutil.FakeShuffleOrder in project ExoPlayer by google.
the class ExoPlayerTest method sendMessagesNonLinearPeriodOrder.
@Test
public void sendMessagesNonLinearPeriodOrder() throws Exception {
Timeline fakeTimeline = new FakeTimeline();
MediaSource[] fakeMediaSources = { new FakeMediaSource(fakeTimeline, ExoPlayerTestRunner.VIDEO_FORMAT), new FakeMediaSource(fakeTimeline, ExoPlayerTestRunner.VIDEO_FORMAT), new FakeMediaSource(fakeTimeline, ExoPlayerTestRunner.VIDEO_FORMAT) };
ConcatenatingMediaSource mediaSource = new ConcatenatingMediaSource(false, new FakeShuffleOrder(3), fakeMediaSources);
PositionGrabbingMessageTarget target1 = new PositionGrabbingMessageTarget();
PositionGrabbingMessageTarget target2 = new PositionGrabbingMessageTarget();
PositionGrabbingMessageTarget target3 = new PositionGrabbingMessageTarget();
ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG).pause().waitForPlaybackState(Player.STATE_READY).sendMessage(target1, /* mediaItemIndex = */
0, /* positionMs= */
50).sendMessage(target2, /* mediaItemIndex = */
1, /* positionMs= */
50).sendMessage(target3, /* mediaItemIndex = */
2, /* positionMs= */
50).setShuffleModeEnabled(true).seek(/* mediaItemIndex= */
2, /* positionMs= */
0).play().build();
new ExoPlayerTestRunner.Builder(context).setMediaSources(mediaSource).setActionSchedule(actionSchedule).build().start().blockUntilEnded(TIMEOUT_MS);
assertThat(target1.mediaItemIndex).isEqualTo(0);
assertThat(target2.mediaItemIndex).isEqualTo(1);
assertThat(target3.mediaItemIndex).isEqualTo(2);
}
Aggregations