mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Simplify ContentDataSourceTest
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=174685374
This commit is contained in:
parent
54a2a69b05
commit
475ea19ae7
@ -23,7 +23,6 @@ import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.test.InstrumentationTestCase;
|
||||
import android.test.MoreAsserts;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.testutil.TestUtil;
|
||||
import java.io.FileNotFoundException;
|
||||
@ -38,9 +37,6 @@ public final class ContentDataSourceTest extends InstrumentationTestCase {
|
||||
private static final String AUTHORITY = "com.google.android.exoplayer2.core.test";
|
||||
private static final String DATA_PATH = "binary/1024_incrementing_bytes.mp3";
|
||||
|
||||
private static final int TEST_DATA_OFFSET = 1;
|
||||
private static final int TEST_DATA_LENGTH = 1023;
|
||||
|
||||
public void testReadValidUri() throws Exception {
|
||||
ContentDataSource dataSource = new ContentDataSource(getInstrumentation().getContext());
|
||||
Uri contentUri = new Uri.Builder()
|
||||
@ -77,15 +73,11 @@ public final class ContentDataSourceTest extends InstrumentationTestCase {
|
||||
.authority(AUTHORITY)
|
||||
.path(DATA_PATH).build();
|
||||
try {
|
||||
DataSpec dataSpec = new DataSpec(contentUri, TEST_DATA_OFFSET, C.LENGTH_UNSET, null);
|
||||
long length = dataSource.open(dataSpec);
|
||||
assertEquals(TEST_DATA_LENGTH, length);
|
||||
byte[] expectedData = Arrays.copyOfRange(
|
||||
TestUtil.getByteArray(getInstrumentation(), DATA_PATH), TEST_DATA_OFFSET,
|
||||
TEST_DATA_OFFSET + TEST_DATA_LENGTH);
|
||||
byte[] readData = TestUtil.readToEnd(dataSource);
|
||||
MoreAsserts.assertEquals(expectedData, readData);
|
||||
assertEquals(C.RESULT_END_OF_INPUT, dataSource.read(new byte[1], 0, 1));
|
||||
int testOffset = 1;
|
||||
DataSpec dataSpec = new DataSpec(contentUri, testOffset, C.LENGTH_UNSET, null);
|
||||
byte[] completeData = TestUtil.getByteArray(getInstrumentation(), DATA_PATH);
|
||||
byte[] expectedData = Arrays.copyOfRange(completeData, testOffset, completeData.length);
|
||||
TestUtil.assertDataSourceContent(dataSource, dataSpec, expectedData);
|
||||
} finally {
|
||||
dataSource.close();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user