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.net.Uri;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.test.InstrumentationTestCase;
|
import android.test.InstrumentationTestCase;
|
||||||
import android.test.MoreAsserts;
|
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.testutil.TestUtil;
|
import com.google.android.exoplayer2.testutil.TestUtil;
|
||||||
import java.io.FileNotFoundException;
|
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 AUTHORITY = "com.google.android.exoplayer2.core.test";
|
||||||
private static final String DATA_PATH = "binary/1024_incrementing_bytes.mp3";
|
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 {
|
public void testReadValidUri() throws Exception {
|
||||||
ContentDataSource dataSource = new ContentDataSource(getInstrumentation().getContext());
|
ContentDataSource dataSource = new ContentDataSource(getInstrumentation().getContext());
|
||||||
Uri contentUri = new Uri.Builder()
|
Uri contentUri = new Uri.Builder()
|
||||||
@ -77,15 +73,11 @@ public final class ContentDataSourceTest extends InstrumentationTestCase {
|
|||||||
.authority(AUTHORITY)
|
.authority(AUTHORITY)
|
||||||
.path(DATA_PATH).build();
|
.path(DATA_PATH).build();
|
||||||
try {
|
try {
|
||||||
DataSpec dataSpec = new DataSpec(contentUri, TEST_DATA_OFFSET, C.LENGTH_UNSET, null);
|
int testOffset = 1;
|
||||||
long length = dataSource.open(dataSpec);
|
DataSpec dataSpec = new DataSpec(contentUri, testOffset, C.LENGTH_UNSET, null);
|
||||||
assertEquals(TEST_DATA_LENGTH, length);
|
byte[] completeData = TestUtil.getByteArray(getInstrumentation(), DATA_PATH);
|
||||||
byte[] expectedData = Arrays.copyOfRange(
|
byte[] expectedData = Arrays.copyOfRange(completeData, testOffset, completeData.length);
|
||||||
TestUtil.getByteArray(getInstrumentation(), DATA_PATH), TEST_DATA_OFFSET,
|
TestUtil.assertDataSourceContent(dataSource, dataSpec, expectedData);
|
||||||
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));
|
|
||||||
} finally {
|
} finally {
|
||||||
dataSource.close();
|
dataSource.close();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user