From b7b3a15855916a0d2be0aeeb1850dfb8d493a41c Mon Sep 17 00:00:00 2001 From: olly Date: Fri, 13 Dec 2019 16:51:06 +0000 Subject: [PATCH] Make it easier to update extractor test dump files PiperOrigin-RevId: 285407744 --- .../exoplayer2/testutil/FakeExtractorOutput.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeExtractorOutput.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeExtractorOutput.java index 4022a0ccc1..0e12bc31dd 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeExtractorOutput.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeExtractorOutput.java @@ -32,9 +32,11 @@ import java.io.PrintWriter; public final class FakeExtractorOutput implements ExtractorOutput, Dumper.Dumpable { /** - * If true, makes {@link #assertOutput(Context, String)} method write dump result to {@code - * /sdcard/Android/data/apk_package/ + dumpfile} file instead of comparing it with an existing - * file. + * If true, makes {@link #assertOutput(Context, String)} method write the output to the dump file, + * rather than validating that the output matches what the dump file already contains. + * + *

Enabling this option works when tests are run in Android Studio. It may not work when the + * tests are run in another environment. */ private static final boolean WRITE_DUMP = false; @@ -107,8 +109,8 @@ public final class FakeExtractorOutput implements ExtractorOutput, Dumper.Dumpab String actual = new Dumper().add(this).toString(); if (WRITE_DUMP) { - File directory = context.getExternalFilesDir(null); - File file = new File(directory, dumpFile); + File file = new File(System.getProperty("user.dir"), "src/test/assets"); + file = new File(file, dumpFile); file.getParentFile().mkdirs(); PrintWriter out = new PrintWriter(file); out.print(actual);