use of androidx.media3.test.utils.DummyMainThread in project media by androidx.
the class ConcatenatingMediaSourceTest method clear.
@Test
public void clear() throws Exception {
DummyMainThread testThread = new DummyMainThread();
final FakeMediaSource preparedChildSource = createFakeMediaSource();
final FakeMediaSource unpreparedChildSource = new FakeMediaSource(/* timeline= */
null);
testThread.runOnMainThread(() -> {
mediaSource.addMediaSource(preparedChildSource);
mediaSource.addMediaSource(unpreparedChildSource);
});
testRunner.prepareSource();
final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner);
testThread.runOnMainThread(() -> mediaSource.clear(Util.createHandlerForCurrentLooper(), timelineGrabber));
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
assertThat(timeline.isEmpty()).isTrue();
preparedChildSource.assertReleased();
unpreparedChildSource.assertReleased();
}
use of androidx.media3.test.utils.DummyMainThread in project media by androidx.
the class ConcatenatingMediaSourceTest method customCallbackAfterPreparationMove.
@Test
public void customCallbackAfterPreparationMove() throws Exception {
DummyMainThread testThread = new DummyMainThread();
try {
testRunner.prepareSource();
testThread.runOnMainThread(() -> mediaSource.addMediaSources(Arrays.asList(new MediaSource[] { createFakeMediaSource(), createFakeMediaSource() })));
testRunner.assertTimelineChangeBlocking();
final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner);
testThread.runOnMainThread(() -> mediaSource.moveMediaSource(/* currentIndex= */
1, /* newIndex= */
0, Util.createHandlerForCurrentLooper(), timelineGrabber));
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
assertThat(timeline.getWindowCount()).isEqualTo(2);
} finally {
testThread.release();
}
}
use of androidx.media3.test.utils.DummyMainThread in project media by androidx.
the class ConcatenatingMediaSourceTest method customCallbackBeforePreparationAddSingleWithIndex.
@Test
public void customCallbackBeforePreparationAddSingleWithIndex() throws Exception {
CountDownLatch runnableInvoked = new CountDownLatch(1);
DummyMainThread testThread = new DummyMainThread();
testThread.runOnMainThread(() -> mediaSource.addMediaSource(/* index */
0, createFakeMediaSource(), Util.createHandlerForCurrentLooper(), runnableInvoked::countDown));
runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, MILLISECONDS);
testThread.release();
assertThat(runnableInvoked.getCount()).isEqualTo(0);
}
use of androidx.media3.test.utils.DummyMainThread in project media by androidx.
the class ConcatenatingMediaSourceTest method customCallbackBeforePreparationRemove.
@Test
public void customCallbackBeforePreparationRemove() throws Exception {
CountDownLatch runnableInvoked = new CountDownLatch(1);
DummyMainThread testThread = new DummyMainThread();
testThread.runOnMainThread(() -> {
mediaSource.addMediaSource(createFakeMediaSource());
mediaSource.removeMediaSource(/* index */
0, Util.createHandlerForCurrentLooper(), runnableInvoked::countDown);
});
runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, MILLISECONDS);
testThread.release();
assertThat(runnableInvoked.getCount()).isEqualTo(0);
}
use of androidx.media3.test.utils.DummyMainThread in project media by androidx.
the class ConcatenatingMediaSourceTest method customCallbackBeforePreparationSetShuffleOrder.
@Test
public void customCallbackBeforePreparationSetShuffleOrder() throws Exception {
CountDownLatch runnableInvoked = new CountDownLatch(1);
DummyMainThread testThread = new DummyMainThread();
testThread.runOnMainThread(() -> mediaSource.setShuffleOrder(new ShuffleOrder.UnshuffledShuffleOrder(/* length= */
0), Util.createHandlerForCurrentLooper(), runnableInvoked::countDown));
runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, MILLISECONDS);
testThread.release();
assertThat(runnableInvoked.getCount()).isEqualTo(0);
}
Aggregations