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();
}
}
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);
}
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);
}
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);
}
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();
}
}
Aggregations