Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
04af8e60
authored
Feb 06, 2020
by
kimvde
Committed by
kim-vde
Feb 11, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add the possibility to specify the dump files path in ExtractorAsserts
PiperOrigin-RevId: 293554489
parent
79a3bad4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
28 deletions
testutils/src/main/java/com/google/android/exoplayer2/testutil/ExtractorAsserts.java
testutils/src/main/java/com/google/android/exoplayer2/testutil/ExtractorAsserts.java
View file @
04af8e60
...
@@ -87,13 +87,7 @@ public final class ExtractorAsserts {
...
@@ -87,13 +87,7 @@ public final class ExtractorAsserts {
*/
*/
public
static
void
assertBehavior
(
ExtractorFactory
factory
,
String
file
)
public
static
void
assertBehavior
(
ExtractorFactory
factory
,
String
file
)
throws
IOException
,
InterruptedException
{
throws
IOException
,
InterruptedException
{
// Check behavior prior to initialization.
assertBehavior
(
factory
,
file
,
ApplicationProvider
.
getApplicationContext
());
Extractor
extractor
=
factory
.
create
();
extractor
.
seek
(
0
,
0
);
extractor
.
release
();
// Assert output.
byte
[]
fileData
=
TestUtil
.
getByteArray
(
ApplicationProvider
.
getApplicationContext
(),
file
);
assertOutput
(
factory
,
file
,
fileData
,
ApplicationProvider
.
getApplicationContext
());
}
}
/**
/**
...
@@ -115,13 +109,37 @@ public final class ExtractorAsserts {
...
@@ -115,13 +109,37 @@ public final class ExtractorAsserts {
*/
*/
public
static
void
assertBehavior
(
ExtractorFactory
factory
,
String
file
,
Context
context
)
public
static
void
assertBehavior
(
ExtractorFactory
factory
,
String
file
,
Context
context
)
throws
IOException
,
InterruptedException
{
throws
IOException
,
InterruptedException
{
assertBehavior
(
factory
,
file
,
context
,
file
);
}
/**
* Asserts that an extractor behaves correctly given valid input data:
*
* <ul>
* <li>Calls {@link Extractor#seek(long, long)} and {@link Extractor#release()} without calling
* {@link Extractor#init(ExtractorOutput)} to check these calls do not fail.
* <li>Calls {@link #assertOutput(Extractor, String, byte[], Context, boolean, boolean, boolean,
* boolean)} with all possible combinations of "simulate" parameters.
* </ul>
*
* @param factory An {@link ExtractorFactory} which creates instances of the {@link Extractor}
* class which is to be tested.
* @param file The path to the input sample.
* @param context To be used to load the sample file.
* @param dumpFilesPrefix The dump files prefix appended to the dump files path.
* @throws IOException If reading from the input fails.
* @throws InterruptedException If interrupted while reading from the input.
*/
public
static
void
assertBehavior
(
ExtractorFactory
factory
,
String
file
,
Context
context
,
String
dumpFilesPrefix
)
throws
IOException
,
InterruptedException
{
// Check behavior prior to initialization.
// Check behavior prior to initialization.
Extractor
extractor
=
factory
.
create
();
Extractor
extractor
=
factory
.
create
();
extractor
.
seek
(
0
,
0
);
extractor
.
seek
(
0
,
0
);
extractor
.
release
();
extractor
.
release
();
// Assert output.
// Assert output.
byte
[]
fileData
=
TestUtil
.
getByteArray
(
context
,
file
);
byte
[]
fileData
=
TestUtil
.
getByteArray
(
context
,
file
);
assertOutput
(
factory
,
file
,
fileData
,
context
);
assertOutput
(
factory
,
dumpFilesPrefix
,
fileData
,
context
);
}
}
/**
/**
...
@@ -132,24 +150,24 @@ public final class ExtractorAsserts {
...
@@ -132,24 +150,24 @@ public final class ExtractorAsserts {
*
*
* @param factory An {@link ExtractorFactory} which creates instances of the {@link Extractor}
* @param factory An {@link ExtractorFactory} which creates instances of the {@link Extractor}
* class which is to be tested.
* class which is to be tested.
* @param
file The path to the input sample
.
* @param
dumpFilesPrefix The dump files prefix appended to the dump files path
.
* @param data Content of the input file.
* @param data Content of the input file.
* @param context To be used to load the sample file.
* @param context To be used to load the sample file.
* @throws IOException If reading from the input fails.
* @throws IOException If reading from the input fails.
* @throws InterruptedException If interrupted while reading from the input.
* @throws InterruptedException If interrupted while reading from the input.
*/
*/
public
static
void
assertOutput
(
public
static
void
assertOutput
(
ExtractorFactory
factory
,
String
file
,
byte
[]
data
,
Context
context
)
ExtractorFactory
factory
,
String
dumpFilesPrefix
,
byte
[]
data
,
Context
context
)
throws
IOException
,
InterruptedException
{
throws
IOException
,
InterruptedException
{
assertOutput
(
factory
.
create
(),
file
,
data
,
context
,
true
,
false
,
false
,
false
);
assertOutput
(
factory
.
create
(),
dumpFilesPrefix
,
data
,
context
,
true
,
false
,
false
,
false
);
assertOutput
(
factory
.
create
(),
file
,
data
,
context
,
true
,
false
,
false
,
true
);
assertOutput
(
factory
.
create
(),
dumpFilesPrefix
,
data
,
context
,
true
,
false
,
false
,
true
);
assertOutput
(
factory
.
create
(),
file
,
data
,
context
,
true
,
false
,
true
,
false
);
assertOutput
(
factory
.
create
(),
dumpFilesPrefix
,
data
,
context
,
true
,
false
,
true
,
false
);
assertOutput
(
factory
.
create
(),
file
,
data
,
context
,
true
,
false
,
true
,
true
);
assertOutput
(
factory
.
create
(),
dumpFilesPrefix
,
data
,
context
,
true
,
false
,
true
,
true
);
assertOutput
(
factory
.
create
(),
file
,
data
,
context
,
true
,
true
,
false
,
false
);
assertOutput
(
factory
.
create
(),
dumpFilesPrefix
,
data
,
context
,
true
,
true
,
false
,
false
);
assertOutput
(
factory
.
create
(),
file
,
data
,
context
,
true
,
true
,
false
,
true
);
assertOutput
(
factory
.
create
(),
dumpFilesPrefix
,
data
,
context
,
true
,
true
,
false
,
true
);
assertOutput
(
factory
.
create
(),
file
,
data
,
context
,
true
,
true
,
true
,
false
);
assertOutput
(
factory
.
create
(),
dumpFilesPrefix
,
data
,
context
,
true
,
true
,
true
,
false
);
assertOutput
(
factory
.
create
(),
file
,
data
,
context
,
true
,
true
,
true
,
true
);
assertOutput
(
factory
.
create
(),
dumpFilesPrefix
,
data
,
context
,
true
,
true
,
true
,
true
);
assertOutput
(
factory
.
create
(),
file
,
data
,
context
,
false
,
false
,
false
,
false
);
assertOutput
(
factory
.
create
(),
dumpFilesPrefix
,
data
,
context
,
false
,
false
,
false
,
false
);
}
}
/**
/**
...
@@ -159,7 +177,7 @@ public final class ExtractorAsserts {
...
@@ -159,7 +177,7 @@ public final class ExtractorAsserts {
* #UNKNOWN_LENGTH_EXTENSION}" exists, it's preferred.
* #UNKNOWN_LENGTH_EXTENSION}" exists, it's preferred.
*
*
* @param extractor The {@link Extractor} to be tested.
* @param extractor The {@link Extractor} to be tested.
* @param
file The path to the input sample
.
* @param
dumpFilesPrefix The dump files prefix appended to the dump files path
.
* @param data Content of the input file.
* @param data Content of the input file.
* @param context To be used to load the sample file.
* @param context To be used to load the sample file.
* @param sniffFirst Whether to sniff the data by calling {@link Extractor#sniff(ExtractorInput)}
* @param sniffFirst Whether to sniff the data by calling {@link Extractor#sniff(ExtractorInput)}
...
@@ -173,7 +191,7 @@ public final class ExtractorAsserts {
...
@@ -173,7 +191,7 @@ public final class ExtractorAsserts {
*/
*/
public
static
FakeExtractorOutput
assertOutput
(
public
static
FakeExtractorOutput
assertOutput
(
Extractor
extractor
,
Extractor
extractor
,
String
file
,
String
dumpFilesPrefix
,
byte
[]
data
,
byte
[]
data
,
Context
context
,
Context
context
,
boolean
sniffFirst
,
boolean
sniffFirst
,
...
@@ -192,20 +210,20 @@ public final class ExtractorAsserts {
...
@@ -192,20 +210,20 @@ public final class ExtractorAsserts {
}
}
FakeExtractorOutput
extractorOutput
=
consumeTestData
(
extractor
,
input
,
0
,
true
);
FakeExtractorOutput
extractorOutput
=
consumeTestData
(
extractor
,
input
,
0
,
true
);
if
(
simulateUnknownLength
&&
assetExists
(
context
,
file
+
UNKNOWN_LENGTH_EXTENSION
))
{
if
(
simulateUnknownLength
&&
assetExists
(
context
,
dumpFilesPrefix
+
UNKNOWN_LENGTH_EXTENSION
))
{
extractorOutput
.
assertOutput
(
context
,
file
+
UNKNOWN_LENGTH_EXTENSION
);
extractorOutput
.
assertOutput
(
context
,
dumpFilesPrefix
+
UNKNOWN_LENGTH_EXTENSION
);
}
else
{
}
else
{
extractorOutput
.
assertOutput
(
context
,
file
+
".0"
+
DUMP_EXTENSION
);
extractorOutput
.
assertOutput
(
context
,
dumpFilesPrefix
+
".0"
+
DUMP_EXTENSION
);
}
}
// Seeking to (timeUs=0, position=0) should always work, and cause the same data to be output.
// Seeking to (timeUs=0, position=0) should always work, and cause the same data to be output.
extractorOutput
.
clearTrackOutputs
();
extractorOutput
.
clearTrackOutputs
();
input
.
reset
();
input
.
reset
();
consumeTestData
(
extractor
,
input
,
/* timeUs= */
0
,
extractorOutput
,
false
);
consumeTestData
(
extractor
,
input
,
/* timeUs= */
0
,
extractorOutput
,
false
);
if
(
simulateUnknownLength
&&
assetExists
(
context
,
file
+
UNKNOWN_LENGTH_EXTENSION
))
{
if
(
simulateUnknownLength
&&
assetExists
(
context
,
dumpFilesPrefix
+
UNKNOWN_LENGTH_EXTENSION
))
{
extractorOutput
.
assertOutput
(
context
,
file
+
UNKNOWN_LENGTH_EXTENSION
);
extractorOutput
.
assertOutput
(
context
,
dumpFilesPrefix
+
UNKNOWN_LENGTH_EXTENSION
);
}
else
{
}
else
{
extractorOutput
.
assertOutput
(
context
,
file
+
".0"
+
DUMP_EXTENSION
);
extractorOutput
.
assertOutput
(
context
,
dumpFilesPrefix
+
".0"
+
DUMP_EXTENSION
);
}
}
// If the SeekMap is seekable, test seeking in the stream.
// If the SeekMap is seekable, test seeking in the stream.
...
@@ -219,7 +237,7 @@ public final class ExtractorAsserts {
...
@@ -219,7 +237,7 @@ public final class ExtractorAsserts {
input
.
reset
();
input
.
reset
();
input
.
setPosition
((
int
)
position
);
input
.
setPosition
((
int
)
position
);
consumeTestData
(
extractor
,
input
,
timeUs
,
extractorOutput
,
false
);
consumeTestData
(
extractor
,
input
,
timeUs
,
extractorOutput
,
false
);
extractorOutput
.
assertOutput
(
context
,
file
+
'.'
+
j
+
DUMP_EXTENSION
);
extractorOutput
.
assertOutput
(
context
,
dumpFilesPrefix
+
'.'
+
j
+
DUMP_EXTENSION
);
if
(
durationUs
==
C
.
TIME_UNSET
)
{
if
(
durationUs
==
C
.
TIME_UNSET
)
{
break
;
break
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment