use of com.google.android.exoplayer2.testutil.DummyMainThread in project ExoPlayer by google.
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 com.google.android.exoplayer2.testutil.DummyMainThread in project ExoPlayer by google.
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 com.google.android.exoplayer2.testutil.DummyMainThread in project ExoPlayer by google.
the class ConcatenatingMediaSourceTest method customCallbackAfterPreparationAddSingle.
@Test
public void customCallbackAfterPreparationAddSingle() throws Exception {
DummyMainThread testThread = new DummyMainThread();
try {
testRunner.prepareSource();
final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner);
testThread.runOnMainThread(() -> mediaSource.addMediaSource(createFakeMediaSource(), Util.createHandlerForCurrentLooper(), timelineGrabber));
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
assertThat(timeline.getWindowCount()).isEqualTo(1);
} finally {
testThread.release();
}
}
use of com.google.android.exoplayer2.testutil.DummyMainThread in project ExoPlayer by google.
the class ConcatenatingMediaSourceTest method customCallbackIsCalledAfterRelease.
@Test
public void customCallbackIsCalledAfterRelease() throws Exception {
DummyMainThread testThread = new DummyMainThread();
CountDownLatch callbackCalledCondition = new CountDownLatch(1);
try {
testThread.runOnMainThread(() -> {
MediaSourceCaller caller = mock(MediaSourceCaller.class);
mediaSource.addMediaSources(Arrays.asList(createMediaSources(2)));
mediaSource.prepareSource(caller, /* mediaTransferListener= */
null, PlayerId.UNSET);
mediaSource.moveMediaSource(/* currentIndex= */
0, /* newIndex= */
1, Util.createHandlerForCurrentLooper(), callbackCalledCondition::countDown);
mediaSource.releaseSource(caller);
});
assertThat(callbackCalledCondition.await(MediaSourceTestRunner.TIMEOUT_MS, MILLISECONDS)).isTrue();
} finally {
testThread.release();
}
}
use of com.google.android.exoplayer2.testutil.DummyMainThread in project ExoPlayer by google.
the class StreamVolumeManagerTest method setUp.
@Before
public void setUp() {
Context context = ApplicationProvider.getApplicationContext();
audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
testListener = new TestListener();
testThread = new DummyMainThread();
testThread.runOnMainThread(() -> streamVolumeManager = new StreamVolumeManager(context, new Handler(Looper.myLooper()), testListener));
}
Aggregations