use of com.google.android.exoplayer2.testutil.FakeDataSource in project ExoPlayer by google.
the class DefaultExtractorInputTest method buildDataSource.
private static FakeDataSource buildDataSource() throws Exception {
FakeDataSource.Builder builder = new FakeDataSource.Builder();
builder.appendReadData(Arrays.copyOfRange(TEST_DATA, 0, 3));
builder.appendReadData(Arrays.copyOfRange(TEST_DATA, 3, 6));
builder.appendReadData(Arrays.copyOfRange(TEST_DATA, 6, 9));
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 testSkipFullyLarge.
public void testSkipFullyLarge() throws Exception {
// Tests skipping an amount of data that's larger than any internal scratch space.
int largeSkipSize = 1024 * 1024;
FakeDataSource.Builder builder = new FakeDataSource.Builder();
builder.appendReadData(new byte[largeSkipSize]);
FakeDataSource testDataSource = builder.build();
testDataSource.open(new DataSpec(Uri.parse(TEST_URI)));
DefaultExtractorInput input = new DefaultExtractorInput(testDataSource, 0, C.LENGTH_UNSET);
input.skipFully(largeSkipSize);
assertEquals(largeSkipSize, input.getPosition());
// Check that we fail with EOFException we skip again.
try {
input.skipFully(1);
fail();
} catch (EOFException e) {
// Expected.
}
}
use of com.google.android.exoplayer2.testutil.FakeDataSource in project ExoPlayer by google.
the class DefaultExtractorInputTest method testSkip.
public void testSkip() throws Exception {
FakeDataSource testDataSource = buildDataSource();
DefaultExtractorInput input = new DefaultExtractorInput(testDataSource, 0, C.LENGTH_UNSET);
// We expect to perform three skips of three bytes, as setup in buildTestDataSource.
for (int i = 0; i < 3; i++) {
assertEquals(3, input.skip(TEST_DATA.length));
}
// Check we're now indicated that the end of input is reached.
int expectedEndOfInput = input.skip(TEST_DATA.length);
assertEquals(C.RESULT_END_OF_INPUT, expectedEndOfInput);
}
use of com.google.android.exoplayer2.testutil.FakeDataSource in project ExoPlayer by google.
the class DefaultExtractorInputTest method buildFailingDataSource.
private static FakeDataSource buildFailingDataSource() throws Exception {
FakeDataSource.Builder builder = new FakeDataSource.Builder();
builder.appendReadData(Arrays.copyOfRange(TEST_DATA, 0, 6));
builder.appendReadError(new IOException());
builder.appendReadData(Arrays.copyOfRange(TEST_DATA, 6, 9));
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 testLargeSkip.
public void testLargeSkip() throws Exception {
FakeDataSource testDataSource = buildLargeDataSource();
DefaultExtractorInput input = new DefaultExtractorInput(testDataSource, 0, C.LENGTH_UNSET);
// Check that skipping the entire data source succeeds.
int bytesToSkip = LARGE_TEST_DATA_LENGTH;
while (bytesToSkip > 0) {
bytesToSkip -= input.skip(bytesToSkip);
}
}
Aggregations