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
9937744f
authored
Apr 17, 2020
by
ibaker
Committed by
Oliver Woodman
Apr 20, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Improve the error message when an extractor dump file is not found
PiperOrigin-RevId: 307078446
parent
7ea83d71
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
9 deletions
testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeExtractorOutput.java
testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeExtractorOutput.java
View file @
9937744f
...
...
@@ -27,6 +27,7 @@ import com.google.android.exoplayer2.extractor.ExtractorOutput;
import
com.google.android.exoplayer2.extractor.SeekMap
;
import
com.google.android.exoplayer2.util.Assertions
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.lang.annotation.Documented
;
...
...
@@ -34,11 +35,14 @@ import java.lang.annotation.Retention;
import
java.lang.annotation.RetentionPolicy
;
import
org.checkerframework.checker.nullness.qual.MonotonicNonNull
;
/**
* A fake {@link ExtractorOutput}.
*/
/** A fake {@link ExtractorOutput}. */
public
final
class
FakeExtractorOutput
implements
ExtractorOutput
,
Dumper
.
Dumpable
{
private
static
final
String
DUMP_UPDATE_INSTRUCTIONS
=
"To update the dump file, change FakeExtractorOutput#DUMP_FILE_ACTION to WRITE_TO_LOCAL (for"
+
" Robolectric tests) or WRITE_TO_DEVICE (for instrumentation tests) and re-run the"
+
" test."
;
/**
* Possible actions to take with the dumps generated from this {@code FakeExtractorOutput} in
* {@link #assertOutput(Context, String)}.
...
...
@@ -128,13 +132,15 @@ public final class FakeExtractorOutput implements ExtractorOutput, Dumper.Dumpab
String
actual
=
new
Dumper
().
add
(
this
).
toString
();
if
(
DUMP_FILE_ACTION
==
COMPARE_WITH_EXISTING
)
{
String
expected
=
TestUtil
.
getString
(
context
,
dumpFile
);
String
expected
;
try
{
expected
=
TestUtil
.
getString
(
context
,
dumpFile
);
}
catch
(
FileNotFoundException
e
)
{
throw
new
IOException
(
"Dump file not found. "
+
DUMP_UPDATE_INSTRUCTIONS
,
e
);
}
assertWithMessage
(
"Extractor output doesn't match golden file: %s\n"
+
"To update the golden, change FakeExtractorOutput#DUMP_FILE_ACTION to"
+
" WRITE_TO_LOCAL (for Robolectric tests) or WRITE_TO_DEVICE (for"
+
" instrumentation tests) and re-run the test."
,
dumpFile
)
"Extractor output doesn't match dump file: %s\n%s"
,
dumpFile
,
DUMP_UPDATE_INSTRUCTIONS
)
.
that
(
actual
)
.
isEqualTo
(
expected
);
}
else
{
...
...
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