use of androidx.media3.test.utils.DummyMainThread in project media by androidx.
the class ConcatenatingMediaSourceTest method customCallbackBeforePreparationAddSingle.
@Test
public void customCallbackBeforePreparationAddSingle() throws Exception {
CountDownLatch runnableInvoked = new CountDownLatch(1);
DummyMainThread testThread = new DummyMainThread();
testThread.runOnMainThread(() -> mediaSource.addMediaSource(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 customCallbackAfterPreparationAddSingleWithIndex.
@Test
public void customCallbackAfterPreparationAddSingleWithIndex() throws Exception {
DummyMainThread testThread = new DummyMainThread();
try {
testRunner.prepareSource();
final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner);
testThread.runOnMainThread(() -> mediaSource.addMediaSource(/* index */
0, createFakeMediaSource(), Util.createHandlerForCurrentLooper(), timelineGrabber));
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
assertThat(timeline.getWindowCount()).isEqualTo(1);
} finally {
testThread.release();
}
}
use of androidx.media3.test.utils.DummyMainThread in project media by androidx.
the class ConcatenatingMediaSourceTest method customCallbackAfterPreparationSetShuffleOrder.
@Test
public void customCallbackAfterPreparationSetShuffleOrder() throws Exception {
DummyMainThread testThread = new DummyMainThread();
try {
mediaSource.addMediaSources(Arrays.asList(createFakeMediaSource(), createFakeMediaSource(), createFakeMediaSource()));
testRunner.prepareSource();
TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner);
testThread.runOnMainThread(() -> mediaSource.setShuffleOrder(new ShuffleOrder.UnshuffledShuffleOrder(/* length= */
3), Util.createHandlerForCurrentLooper(), timelineGrabber));
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
assertThat(timeline.getFirstWindowIndex(/* shuffleModeEnabled= */
true)).isEqualTo(0);
} finally {
testThread.release();
}
}
use of androidx.media3.test.utils.DummyMainThread in project media by androidx.
the class ConcatenatingMediaSourceTest method customCallbackBeforePreparationAddMultipleWithIndex.
@Test
public void customCallbackBeforePreparationAddMultipleWithIndex() throws Exception {
CountDownLatch runnableInvoked = new CountDownLatch(1);
DummyMainThread testThread = new DummyMainThread();
testThread.runOnMainThread(() -> mediaSource.addMediaSources(/* index */
0, Arrays.asList(new MediaSource[] { createFakeMediaSource(), 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 customCallbackAfterPreparationAddMultipleWithIndex.
@Test
public void customCallbackAfterPreparationAddMultipleWithIndex() throws Exception {
DummyMainThread testThread = new DummyMainThread();
try {
testRunner.prepareSource();
final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner);
testThread.runOnMainThread(() -> mediaSource.addMediaSources(/* index */
0, Arrays.asList(new MediaSource[] { createFakeMediaSource(), createFakeMediaSource() }), Util.createHandlerForCurrentLooper(), timelineGrabber));
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
assertThat(timeline.getWindowCount()).isEqualTo(2);
} finally {
testThread.release();
}
}
Aggregations