use of com.google.android.exoplayer2.testutil.FakeDataSet in project ExoPlayer by google.
the class CacheWriterTest method cacheSetOffsetAndLength.
@Test
public void cacheSetOffsetAndLength() throws Exception {
FakeDataSet fakeDataSet = new FakeDataSet().setRandomData("test_data", 100);
FakeDataSource dataSource = new FakeDataSource(fakeDataSet);
Uri testUri = Uri.parse("test_data");
DataSpec dataSpec = new DataSpec(testUri, /* position= */
10, /* length= */
20);
CachingCounters counters = new CachingCounters();
CacheWriter cacheWriter = new CacheWriter(new CacheDataSource(cache, dataSource), dataSpec, /* temporaryBuffer= */
null, counters);
cacheWriter.cache();
counters.assertValues(0, 20, 20);
counters.reset();
cacheWriter = new CacheWriter(new CacheDataSource(cache, dataSource), new DataSpec(testUri), /* temporaryBuffer= */
null, counters);
cacheWriter.cache();
counters.assertValues(20, 80, 100);
assertCachedData(cache, fakeDataSet);
}
use of com.google.android.exoplayer2.testutil.FakeDataSet in project ExoPlayer by google.
the class CacheWriterTest method cache.
@Test
public void cache() throws Exception {
FakeDataSet fakeDataSet = new FakeDataSet().setRandomData("test_data", 100);
FakeDataSource dataSource = new FakeDataSource(fakeDataSet);
CachingCounters counters = new CachingCounters();
CacheWriter cacheWriter = new CacheWriter(new CacheDataSource(cache, dataSource), new DataSpec(Uri.parse("test_data")), /* temporaryBuffer= */
null, counters);
cacheWriter.cache();
counters.assertValues(0, 100, 100);
assertCachedData(cache, fakeDataSet);
}
use of com.google.android.exoplayer2.testutil.FakeDataSet in project ExoPlayer by google.
the class CacheWriterTest method cachePolling.
@Test
public void cachePolling() throws Exception {
final CachingCounters counters = new CachingCounters();
FakeDataSet fakeDataSet = new FakeDataSet().newData("test_data").appendReadData(TestUtil.buildTestData(100)).appendReadAction(() -> counters.assertValues(0, 100, 300)).appendReadData(TestUtil.buildTestData(100)).appendReadAction(() -> counters.assertValues(0, 200, 300)).appendReadData(TestUtil.buildTestData(100)).endData();
FakeDataSource dataSource = new FakeDataSource(fakeDataSet);
CacheWriter cacheWriter = new CacheWriter(new CacheDataSource(cache, dataSource), new DataSpec(Uri.parse("test_data")), /* temporaryBuffer= */
null, counters);
cacheWriter.cache();
counters.assertValues(0, 300, 300);
assertCachedData(cache, fakeDataSet);
}
use of com.google.android.exoplayer2.testutil.FakeDataSet in project ExoPlayer by google.
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);
}
Aggregations