use of com.google.android.exoplayer2.upstream.DataSpec in project ExoPlayer by google.
the class DataSourceInputStreamTest method buildTestInputStream.
private static DataSourceInputStream buildTestInputStream() {
FakeDataSource fakeDataSource = new FakeDataSource();
fakeDataSource.getDataSet().newDefaultData().appendReadData(Arrays.copyOfRange(TEST_DATA, 0, 5)).appendReadData(Arrays.copyOfRange(TEST_DATA, 5, 10)).appendReadData(Arrays.copyOfRange(TEST_DATA, 10, 15)).appendReadData(Arrays.copyOfRange(TEST_DATA, 15, TEST_DATA.length));
return new DataSourceInputStream(fakeDataSource, new DataSpec(Uri.EMPTY));
}
use of com.google.android.exoplayer2.upstream.DataSpec in project ExoPlayer by google.
the class CacheKeyFactoryTest method default_dataSpecWithKey_returnsKey.
@Test
public void default_dataSpecWithKey_returnsKey() {
Uri testUri = Uri.parse("test");
String key = "key";
DataSpec dataSpec = new DataSpec.Builder().setUri(testUri).setKey(key).build();
assertThat(DEFAULT.buildCacheKey(dataSpec)).isEqualTo(key);
}
use of com.google.android.exoplayer2.upstream.DataSpec in project ExoPlayer by google.
the class CacheKeyFactoryTest method default_dataSpecWithoutKey_returnsUri.
@Test
public void default_dataSpecWithoutKey_returnsUri() {
Uri testUri = Uri.parse("test");
DataSpec dataSpec = new DataSpec.Builder().setUri(testUri).build();
assertThat(DEFAULT.buildCacheKey(dataSpec)).isEqualTo(testUri.toString());
}
use of com.google.android.exoplayer2.upstream.DataSpec in project ExoPlayer by google.
the class CacheDataSourceTest method setUp.
@Before
public void setUp() throws Exception {
testDataUri = Uri.parse("https://www.test.com/data");
httpRequestHeaders = new HashMap<>();
httpRequestHeaders.put("Test-key", "Test-val");
unboundedDataSpec = buildDataSpec(/* unbounded= */
true, /* key= */
null);
boundedDataSpec = buildDataSpec(/* unbounded= */
false, /* key= */
null);
unboundedDataSpecWithKey = buildDataSpec(/* unbounded= */
true, DATASPEC_KEY);
boundedDataSpecWithKey = buildDataSpec(/* unbounded= */
false, DATASPEC_KEY);
defaultCacheKey = CacheKeyFactory.DEFAULT.buildCacheKey(unboundedDataSpec);
customCacheKey = "customKey." + defaultCacheKey;
cacheKeyFactory = dataSpec -> customCacheKey;
tempFolder = Util.createTempDirectory(ApplicationProvider.getApplicationContext(), "ExoPlayerTest");
cache = new SimpleCache(tempFolder, new NoOpCacheEvictor(), TestUtil.getInMemoryDatabaseProvider());
upstreamDataSource = new FakeDataSource();
}
use of com.google.android.exoplayer2.upstream.DataSpec in project ExoPlayer by google.
the class CacheDataSourceTest method propagatesHttpHeadersUpstream.
@Test
public void propagatesHttpHeadersUpstream() throws Exception {
CacheDataSource cacheDataSource = createCacheDataSource(/* setReadException= */
false, /* unknownLength= */
false);
DataSpec dataSpec = buildDataSpec(/* position= */
2, /* length= */
5);
cacheDataSource.open(dataSpec);
DataSpec[] upstreamDataSpecs = upstreamDataSource.getAndClearOpenedDataSpecs();
assertThat(upstreamDataSpecs).hasLength(1);
assertThat(upstreamDataSpecs[0].httpRequestHeaders).isEqualTo(this.httpRequestHeaders);
}
Aggregations