From 475ea19ae7a859dcc2f1e20f0ce83fe44ba459dc Mon Sep 17 00:00:00 2001 From: olly Date: Mon, 6 Nov 2017 03:37:16 -0800 Subject: [PATCH] Simplify ContentDataSourceTest ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=174685374 --- .../upstream/ContentDataSourceTest.java | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/library/core/src/androidTest/java/com/google/android/exoplayer2/upstream/ContentDataSourceTest.java b/library/core/src/androidTest/java/com/google/android/exoplayer2/upstream/ContentDataSourceTest.java index 2b70c83ca5..6a85483dd1 100644 --- a/library/core/src/androidTest/java/com/google/android/exoplayer2/upstream/ContentDataSourceTest.java +++ b/library/core/src/androidTest/java/com/google/android/exoplayer2/upstream/ContentDataSourceTest.java @@ -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(); }