use of com.google.android.exoplayer2.extractor.DefaultExtractorInput 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.extractor.DefaultExtractorInput 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.extractor.DefaultExtractorInput 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());
}
use of com.google.android.exoplayer2.extractor.DefaultExtractorInput 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.extractor.DefaultExtractorInput 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);
}
Aggregations