Search in sources :

Example 31 with FakeDataSet

use of androidx.media3.test.utils.FakeDataSet in project media by androidx.

the class DashDownloaderTest method downloadRepresentationInSmallParts.

@Test
public void downloadRepresentationInSmallParts() throws Exception {
    FakeDataSet fakeDataSet = new FakeDataSet().setData(TEST_MPD_URI, TEST_MPD).setRandomData("audio_init_data", 10).newData("audio_segment_1").appendReadData(TestUtil.buildTestData(10)).appendReadData(TestUtil.buildTestData(10)).appendReadData(TestUtil.buildTestData(10)).endData().setRandomData("audio_segment_2", 5).setRandomData("audio_segment_3", 6);
    DashDownloader dashDownloader = getDashDownloader(fakeDataSet, new StreamKey(0, 0, 0));
    dashDownloader.download(progressListener);
    assertCachedData(cache, new RequestSet(fakeDataSet).useBoundedDataSpecFor("audio_init_data"));
}
Also used : RequestSet(androidx.media3.test.utils.CacheAsserts.RequestSet) FakeDataSet(androidx.media3.test.utils.FakeDataSet) StreamKey(androidx.media3.common.StreamKey) Test(org.junit.Test)

Example 32 with FakeDataSet

use of androidx.media3.test.utils.FakeDataSet in project media by androidx.

the class DashDownloaderTest method downloadAllRepresentations.

@Test
public void downloadAllRepresentations() throws Exception {
    FakeDataSet 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).setRandomData("period_2_segment_1", 1).setRandomData("period_2_segment_2", 2).setRandomData("period_2_segment_3", 3);
    DashDownloader dashDownloader = getDashDownloader(fakeDataSet);
    dashDownloader.download(progressListener);
    assertCachedData(cache, new RequestSet(fakeDataSet).useBoundedDataSpecFor("audio_init_data"));
}
Also used : RequestSet(androidx.media3.test.utils.CacheAsserts.RequestSet) FakeDataSet(androidx.media3.test.utils.FakeDataSet) Test(org.junit.Test)

Example 33 with FakeDataSet

use of androidx.media3.test.utils.FakeDataSet in project media by androidx.

the class HlsDownloaderTest method downloadEncMediaPlaylist.

@Test
public void downloadEncMediaPlaylist() throws Exception {
    fakeDataSet = new FakeDataSet().setData(ENC_MEDIA_PLAYLIST_URI, ENC_MEDIA_PLAYLIST_DATA).setRandomData("enc.key", 8).setRandomData("enc2.key", 9).setRandomData("fileSequence0.ts", 10).setRandomData("fileSequence1.ts", 11).setRandomData("fileSequence2.ts", 12);
    HlsDownloader downloader = getHlsDownloader(ENC_MEDIA_PLAYLIST_URI, getKeys());
    downloader.download(progressListener);
    assertCachedData(cache, fakeDataSet);
}
Also used : FakeDataSet(androidx.media3.test.utils.FakeDataSet) Test(org.junit.Test)

Example 34 with FakeDataSet

use of androidx.media3.test.utils.FakeDataSet in project media by androidx.

the class HlsDownloaderTest method setUp.

@Before
public void setUp() throws Exception {
    tempFolder = Util.createTempDirectory(ApplicationProvider.getApplicationContext(), "ExoPlayerTest");
    cache = new SimpleCache(tempFolder, new NoOpCacheEvictor(), TestUtil.getInMemoryDatabaseProvider());
    progressListener = new ProgressListener();
    fakeDataSet = new FakeDataSet().setData(MULTIVARIANT_PLAYLIST_URI, MULTIVARIANT_PLAYLIST_DATA).setData(MEDIA_PLAYLIST_1_URI, MEDIA_PLAYLIST_DATA).setRandomData(MEDIA_PLAYLIST_1_DIR + "fileSequence0.ts", 10).setRandomData(MEDIA_PLAYLIST_1_DIR + "fileSequence1.ts", 11).setRandomData(MEDIA_PLAYLIST_1_DIR + "fileSequence2.ts", 12).setData(MEDIA_PLAYLIST_2_URI, MEDIA_PLAYLIST_DATA).setRandomData(MEDIA_PLAYLIST_2_DIR + "fileSequence0.ts", 13).setRandomData(MEDIA_PLAYLIST_2_DIR + "fileSequence1.ts", 14).setRandomData(MEDIA_PLAYLIST_2_DIR + "fileSequence2.ts", 15);
}
Also used : SimpleCache(androidx.media3.datasource.cache.SimpleCache) NoOpCacheEvictor(androidx.media3.datasource.cache.NoOpCacheEvictor) FakeDataSet(androidx.media3.test.utils.FakeDataSet) Before(org.junit.Before)

Aggregations

Test (org.junit.Test)29 FakeDataSet (androidx.media3.test.utils.FakeDataSet)23 DataSpec (androidx.media3.datasource.DataSpec)16 FakeDataSource (androidx.media3.test.utils.FakeDataSource)14 StreamKey (androidx.media3.common.StreamKey)11 Uri (android.net.Uri)6 IOException (java.io.IOException)6 RequestSet (androidx.media3.test.utils.CacheAsserts.RequestSet)5 CacheDataSource (androidx.media3.datasource.cache.CacheDataSource)4 DataSource (androidx.media3.datasource.DataSource)3 NoOpCacheEvictor (androidx.media3.datasource.cache.NoOpCacheEvictor)3 SimpleCache (androidx.media3.datasource.cache.SimpleCache)3 Before (org.junit.Before)3 MediaItem (androidx.media3.common.MediaItem)2 DefaultDownloadIndex (androidx.media3.exoplayer.offline.DefaultDownloadIndex)2 DefaultDownloaderFactory (androidx.media3.exoplayer.offline.DefaultDownloaderFactory)2 DownloadManager (androidx.media3.exoplayer.offline.DownloadManager)2 DummyMainThread (androidx.media3.test.utils.DummyMainThread)2 FailOnCloseDataSink (androidx.media3.test.utils.FailOnCloseDataSink)2 TestDownloadManagerListener (androidx.media3.test.utils.robolectric.TestDownloadManagerListener)2