use of androidx.media3.test.utils.DummyMainThread in project media by androidx.
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 androidx.media3.test.utils.DummyMainThread in project media by androidx.
the class ConcatenatingMediaSourceTest method customCallbackAfterPreparationRemove.
@Test
public void customCallbackAfterPreparationRemove() throws Exception {
DummyMainThread testThread = new DummyMainThread();
try {
testRunner.prepareSource();
testThread.runOnMainThread(() -> mediaSource.addMediaSource(createFakeMediaSource()));
testRunner.assertTimelineChangeBlocking();
final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner);
testThread.runOnMainThread(() -> mediaSource.removeMediaSource(/* index */
0, Util.createHandlerForCurrentLooper(), timelineGrabber));
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
assertThat(timeline.getWindowCount()).isEqualTo(0);
} finally {
testThread.release();
}
}
use of androidx.media3.test.utils.DummyMainThread in project media by androidx.
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 androidx.media3.test.utils.DummyMainThread in project media by androidx.
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 androidx.media3.test.utils.DummyMainThread in project media by androidx.
the class DownloadManagerDashTest method setUp.
@Before
public void setUp() throws Exception {
ShadowLog.stream = System.out;
testThread = new DummyMainThread();
Context context = ApplicationProvider.getApplicationContext();
tempFolder = Util.createTempDirectory(context, "ExoPlayerTest");
File cacheFolder = new File(tempFolder, "cache");
cacheFolder.mkdir();
cache = new SimpleCache(cacheFolder, new NoOpCacheEvictor(), TestUtil.getInMemoryDatabaseProvider());
MockitoAnnotations.initMocks(this);
fakeDataSet = new FakeDataSet().setData(TEST_MPD_URI, TEST_MPD).setRandomData("audio_init_data", 10).setRandomData("audio_segment_1", 4).setRandomData("audio_segment_2", 5).setRandomData("audio_segment_3", 6).setRandomData("text_segment_1", 1).setRandomData("text_segment_2", 2).setRandomData("text_segment_3", 3);
fakeStreamKey1 = new StreamKey(0, 0, 0);
fakeStreamKey2 = new StreamKey(0, 1, 0);
downloadIndex = new DefaultDownloadIndex(TestUtil.getInMemoryDatabaseProvider());
createDownloadManager();
}
Aggregations