use of com.google.android.exoplayer2.testutil.FakeDataSource in project ExoPlayer by google.
the class CacheDataSourceTest method createCacheDataSource.
private CacheDataSource createCacheDataSource(boolean setReadException, boolean simulateUnknownLength, @CacheDataSource.Flags int flags, CacheDataSink cacheWriteDataSink) {
FakeDataSource.Builder builder = new FakeDataSource.Builder();
if (setReadException) {
builder.appendReadError(new IOException("Shouldn't read from upstream"));
}
FakeDataSource upstream = builder.setSimulateUnknownLength(simulateUnknownLength).appendReadData(TEST_DATA).build();
return new CacheDataSource(simpleCache, upstream, new FileDataSource(), cacheWriteDataSink, flags, null);
}
use of com.google.android.exoplayer2.testutil.FakeDataSource in project ExoPlayer by google.
the class DefaultExtractorInputTest method testSkipFullyWithFailingDataSource.
public void testSkipFullyWithFailingDataSource() throws Exception {
FakeDataSource testDataSource = buildFailingDataSource();
DefaultExtractorInput input = new DefaultExtractorInput(testDataSource, 0, C.LENGTH_UNSET);
try {
input.skipFully(TEST_DATA.length);
fail();
} catch (IOException e) {
// Expected.
}
// The position should not have advanced.
assertEquals(0, input.getPosition());
}
use of com.google.android.exoplayer2.testutil.FakeDataSource in project ExoPlayer by google.
the class DefaultExtractorInputTest method testReadFullyWithFailingDataSource.
public void testReadFullyWithFailingDataSource() throws Exception {
FakeDataSource testDataSource = buildFailingDataSource();
DefaultExtractorInput input = new DefaultExtractorInput(testDataSource, 0, C.LENGTH_UNSET);
try {
byte[] target = new byte[TEST_DATA.length];
input.readFully(target, 0, TEST_DATA.length);
fail();
} catch (IOException e) {
// Expected.
}
// The position should not have advanced.
assertEquals(0, input.getPosition());
}
use of com.google.android.exoplayer2.testutil.FakeDataSource in project ExoPlayer by google.
the class DefaultExtractorInputTest method buildLargeDataSource.
private static FakeDataSource buildLargeDataSource() throws Exception {
FakeDataSource.Builder builder = new FakeDataSource.Builder();
builder.appendReadData(new byte[LARGE_TEST_DATA_LENGTH]);
FakeDataSource testDataSource = builder.build();
testDataSource.open(new DataSpec(Uri.parse(TEST_URI)));
return testDataSource;
}
use of com.google.android.exoplayer2.testutil.FakeDataSource in project ExoPlayer by google.
the class DefaultExtractorInputTest method testInitialPosition.
public void testInitialPosition() throws Exception {
FakeDataSource testDataSource = buildDataSource();
DefaultExtractorInput input = new DefaultExtractorInput(testDataSource, 123, C.LENGTH_UNSET);
assertEquals(123, input.getPosition());
}
Aggregations