Class DataSourceContractTest
- java.lang.Object
-
- com.google.android.exoplayer2.testutil.DataSourceContractTest
-
@RequiresApi(19) public abstract class DataSourceContractTest extends Object
A collection of contract tests forDataSourceimplementations.Subclasses should only include the logic necessary to construct the DataSource and allow it to successfully read data. They shouldn't include any new
@Testmethods - implementation-specific tests should be in a separate class.Most implementations should pass all these tests. If necessary, subclasses can disable tests by overriding the
@Testmethod with a no-op implementation. It's recommended (but not required) to also annotate this@Ignoreso that JUnit correctly reports the test as skipped/ignored instead of passing.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDataSourceContractTest.FakeTransferListenerATransferListenerthat only keeps track of the transferred bytes.static classDataSourceContractTest.TestResourceInformation about a resource that can be used to test theDataSourceinstance.
-
Field Summary
Fields Modifier and Type Field Description AdditionalFailureInfoadditionalFailureInfo
-
Constructor Summary
Constructors Constructor Description DataSourceContractTest()
-
Method Summary
-
-
-
Field Detail
-
additionalFailureInfo
public final AdditionalFailureInfo additionalFailureInfo
-
-
Method Detail
-
createDataSource
protected abstract DataSource createDataSource() throws Exception
Creates and returns an instance of theDataSource.- Throws:
Exception
-
getTransferListenerDataSource
@Nullable protected DataSource getTransferListenerDataSource()
Returns theDataSourcethat will be included in theTransferListenercallbacks for theDataSourcemost recently created bycreateDataSource(). If it's the sameDataSourcethennullcan be returned.
-
unboundedReadsAreIndefinite
protected boolean unboundedReadsAreIndefinite()
Returns whether theDataSourcewill continue reading indefinitely for unboundedDataSpecs.
-
getTestResources
protected abstract ImmutableList<DataSourceContractTest.TestResource> getTestResources() throws Exception
ReturnsDataSourceContractTest.TestResourceinstances.Each resource will be used to exercise the
DataSourceinstance, allowing different behaviours to be tested.If multiple resources are returned, it's recommended to disambiguate them using
DataSourceContractTest.TestResource.Builder.setName(String).- Throws:
Exception
-
getNotFoundUri
protected abstract Uri getNotFoundUri()
Returns aUrithat doesn't resolve.This is used to test how a
DataSourcehandles nonexistent data.
-
unboundedDataSpec_readUntilEnd
public void unboundedDataSpec_readUntilEnd() throws Exception- Throws:
Exception
-
dataSpecWithPosition_readUntilEnd
public void dataSpecWithPosition_readUntilEnd() throws Exception- Throws:
Exception
-
dataSpecWithLength_readExpectedRange
public void dataSpecWithLength_readExpectedRange() throws Exception- Throws:
Exception
-
dataSpecWithPositionAndLength_readExpectedRange
public void dataSpecWithPositionAndLength_readExpectedRange() throws Exception- Throws:
Exception
-
dataSpecWithPositionAtEnd_readsZeroBytes
public void dataSpecWithPositionAtEnd_readsZeroBytes() throws Exception- Throws:
Exception
-
dataSpecWithPositionAtEndAndLength_readsZeroBytes
public void dataSpecWithPositionAtEndAndLength_readsZeroBytes() throws Exception- Throws:
Exception
-
dataSpecWithPositionOutOfRange_throwsPositionOutOfRangeException
public void dataSpecWithPositionOutOfRange_throwsPositionOutOfRangeException() throws Exception- Throws:
Exception
-
dataSpecWithEndPositionOutOfRange_readsToEnd
public void dataSpecWithEndPositionOutOfRange_readsToEnd() throws Exception- Throws:
Exception
-
unboundedDataSpecWithGzipFlag_readUntilEnd
public void unboundedDataSpecWithGzipFlag_readUntilEnd() throws ExceptionDataSpec.FLAG_ALLOW_GZIPshould either be ignored byDataSourceimplementations, or correctly handled (i.e. the data is decompressed before being returned fromDataReader.read(byte[], int, int)).- Throws:
Exception
-
uriSchemeIsCaseInsensitive
public void uriSchemeIsCaseInsensitive() throws Exception- Throws:
Exception
-
transferListenerCallbacks
public void transferListenerCallbacks() throws Exception- Throws:
Exception
-
resourceNotFound_transferListenerCallbacks
public void resourceNotFound_transferListenerCallbacks() throws Exception- Throws:
Exception
-
getUri_returnsNonNullValueOnlyWhileOpen
public void getUri_returnsNonNullValueOnlyWhileOpen() throws Exception- Throws:
Exception
-
getUri_resourceNotFound_returnsNullIfNotOpened
public void getUri_resourceNotFound_returnsNullIfNotOpened() throws Exception- Throws:
Exception
-
getResponseHeaders_noNullKeysOrValues
public void getResponseHeaders_noNullKeysOrValues() throws Exception- Throws:
Exception
-
getResponseHeaders_caseInsensitive
public void getResponseHeaders_caseInsensitive() throws Exception- Throws:
Exception
-
getResponseHeaders_isEmptyWhileNotOpen
public void getResponseHeaders_isEmptyWhileNotOpen() throws Exception- Throws:
Exception
-
-