use of com.google.android.exoplayer2.testutil.DummyMainThread in project ExoPlayer by google.
the class ConcatenatingMediaSourceTest method customCallbackBeforePreparationMove.
@Test
public void customCallbackBeforePreparationMove() throws Exception {
CountDownLatch runnableInvoked = new CountDownLatch(1);
DummyMainThread testThread = new DummyMainThread();
testThread.runOnMainThread(() -> {
mediaSource.addMediaSources(Arrays.asList(new MediaSource[] { createFakeMediaSource(), createFakeMediaSource() }));
mediaSource.moveMediaSource(/* currentIndex= */
1, /* newIndex= */
0, Util.createHandlerForCurrentLooper(), runnableInvoked::countDown);
});
runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, MILLISECONDS);
testThread.release();
assertThat(runnableInvoked.getCount()).isEqualTo(0);
}
use of com.google.android.exoplayer2.testutil.DummyMainThread in project ExoPlayer by google.
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();
}
}
use of com.google.android.exoplayer2.testutil.DummyMainThread in project ExoPlayer by google.
the class ConcatenatingMediaSourceTest method customCallbackBeforePreparationAddMultiple.
@Test
public void customCallbackBeforePreparationAddMultiple() throws Exception {
CountDownLatch runnableInvoked = new CountDownLatch(1);
DummyMainThread testThread = new DummyMainThread();
testThread.runOnMainThread(() -> mediaSource.addMediaSources(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 com.google.android.exoplayer2.testutil.DummyMainThread in project ExoPlayer by google.
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 com.google.android.exoplayer2.testutil.DummyMainThread in project ExoPlayer by google.
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();
}
Aggregations