use of androidx.media3.test.utils.MediaSourceTestRunner in project media by androidx.
the class ConcatenatingMediaSourceTest method childSourceIsPreparedWithLazyPreparationAfterPeriodCreation.
@Test
public void childSourceIsPreparedWithLazyPreparationAfterPeriodCreation() throws IOException {
FakeMediaSource[] childSources = createMediaSources(/* count= */
2);
mediaSource = new ConcatenatingMediaSource(/* isAtomic= */
false, /* useLazyPreparation= */
true, new DefaultShuffleOrder(0), childSources);
testRunner = new MediaSourceTestRunner(mediaSource, /* allocator= */
null);
Timeline timeline = testRunner.prepareSource();
testRunner.createPeriod(new MediaPeriodId(timeline.getUidOfPeriod(/* periodIndex= */
0), /* windowSequenceNumber= */
0));
assertThat(childSources[0].isPrepared()).isTrue();
assertThat(childSources[1].isPrepared()).isFalse();
}
use of androidx.media3.test.utils.MediaSourceTestRunner in project media by androidx.
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 androidx.media3.test.utils.MediaSourceTestRunner in project media by androidx.
the class ConcatenatingMediaSourceTest method childSourceWithLazyPreparationOnlyPreparesSourceOnce.
@Test
public void childSourceWithLazyPreparationOnlyPreparesSourceOnce() throws IOException {
FakeMediaSource[] childSources = createMediaSources(/* count= */
2);
mediaSource = new ConcatenatingMediaSource(/* isAtomic= */
false, /* useLazyPreparation= */
true, new DefaultShuffleOrder(0), childSources);
testRunner = new MediaSourceTestRunner(mediaSource, /* allocator= */
null);
Timeline timeline = testRunner.prepareSource();
// The lazy preparation must only be triggered once, even if we create multiple periods from
// the media source. FakeMediaSource.prepareSource asserts that it's not called twice, so
// creating two periods shouldn't throw.
MediaPeriodId mediaPeriodId = new MediaPeriodId(timeline.getUidOfPeriod(/* periodIndex= */
0), /* windowSequenceNumber= */
0);
testRunner.createPeriod(mediaPeriodId);
testRunner.createPeriod(mediaPeriodId);
}
use of androidx.media3.test.utils.MediaSourceTestRunner in project media by androidx.
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();
}
}
use of androidx.media3.test.utils.MediaSourceTestRunner in project media by androidx.
the class LoopingMediaSourceTest method testMediaPeriodCreation.
/**
* Wraps the specified timeline in a {@link LoopingMediaSource} and asserts that all periods of
* the looping timeline can be created and prepared.
*/
private static void testMediaPeriodCreation(Timeline timeline, int loopCount) throws Exception {
FakeMediaSource fakeMediaSource = new FakeMediaSource(timeline);
LoopingMediaSource mediaSource = new LoopingMediaSource(fakeMediaSource, loopCount);
MediaSourceTestRunner testRunner = new MediaSourceTestRunner(mediaSource, null);
try {
testRunner.prepareSource();
testRunner.assertPrepareAndReleaseAllPeriods();
testRunner.releaseSource();
} finally {
testRunner.release();
}
}
Aggregations