Back to Exoplayer

DumpFileAsserts (ExoPlayer library)

docs/doc/reference/com/google/android/exoplayer2/testutil/DumpFileAsserts.html

latest8.6 KB
Original Source

Package com.google.android.exoplayer2.testutil

Class DumpFileAsserts


public classDumpFileAssertsextends[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")

Helper class to enable assertions based on golden-data dump files.

Allows the golden files to be easily updated with new data (see more info in the docs on DUMP_FILE_ACTION).

Compatible with Dumper.Dumpable but can also be used directly with Strings generated through different means.

Field Summary

Fields | Modifier and Type | Field | Description | | --- | --- | --- | | static String | DEFAULT_TEST_ASSET_DIRECTORY | The default test asset directory used if no other directory is specified. |

Method Summary

All Methods Static Methods Concrete Methods | Modifier and Type | Method | Description | | --- | --- | --- | | static void | assertOutput​(Context context, Dumper.Dumpable actual, String dumpFile) | Asserts that the dump output of actual is equal to the contents of dumpFile in the DEFAULT_TEST_ASSET_DIRECTORY. | | static void | assertOutput​(Context context, Dumper.Dumpable actual, String assetDirectory, String dumpFile) | Asserts that the dump output of actual is equal to the contents of dumpFile in the assetDirectory. | | static void | assertOutput​(Context context, String actual, String dumpFile) | Asserts that actual is equal to the contents of dumpFile in the DEFAULT_TEST_ASSET_DIRECTORY. | | static void | assertOutput​(Context context, String actual, String assetDirectory, String dumpFile) | Asserts that actual is equal to the contents of dumpFile in assetDirectory. |

- 

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

- 

DEFAULT_TEST_ASSET_DIRECTORY

public static final[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")DEFAULT_TEST_ASSET_DIRECTORY

The default test asset directory used if no other directory is specified. See Also:Constant Field Values

Method Detail

- 

assertOutput

public static void assertOutput​([Context](https://developer.android.com/reference/android/content/Context.html "class or interface in android.content")context,[Dumper.Dumpable](Dumper.Dumpable.html "interface in com.google.android.exoplayer2.testutil")actual,[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")dumpFile)
                         throws[IOException](https://developer.android.com/reference/java/io/IOException.html "class or interface in java.io")

Asserts that the dump output of actual is equal to the contents of dumpFile in the DEFAULT_TEST_ASSET_DIRECTORY.

If the assertion fails because of an intended change in the output or a new dump file needs to be created, set DUMP_FILE_ACTION to WRITE_TO_LOCAL for local tests and to WRITE_TO_DEVICE for instrumentation tests, and run the test again. Instead of assertion, actual will be written to dumpFile. For instrumentation tests, this new dump file needs to be copied to the project asset folder manually.

Parameters:context - A context.actual - The actual data.dumpFile - The file path of the dump file in the assets directory.Throws:IOException

- 

assertOutput

public static void assertOutput​([Context](https://developer.android.com/reference/android/content/Context.html "class or interface in android.content")context,[Dumper.Dumpable](Dumper.Dumpable.html "interface in com.google.android.exoplayer2.testutil")actual,[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")assetDirectory,[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")dumpFile)
                         throws[IOException](https://developer.android.com/reference/java/io/IOException.html "class or interface in java.io")

Asserts that the dump output of actual is equal to the contents of dumpFile in the assetDirectory.

If the assertion fails because of an intended change in the output or a new dump file needs to be created, set DUMP_FILE_ACTION to WRITE_TO_LOCAL for local tests and to WRITE_TO_DEVICE for instrumentation tests, and run the test again. Instead of assertion, actual will be written to dumpFile. For instrumentation tests, this new dump file needs to be copied to the project asset folder manually.

Parameters:context - A context.actual - The actual data.assetDirectory - The directory of the assets relative to the project working directory. Only used when DUMP_FILE_ACTION is set to WRITE_TO_LOCAL.dumpFile - The file path of the dump file in the assets directory.Throws:IOException

- 

assertOutput

public static void assertOutput​([Context](https://developer.android.com/reference/android/content/Context.html "class or interface in android.content")context,[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")actual,[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")dumpFile)
                         throws[IOException](https://developer.android.com/reference/java/io/IOException.html "class or interface in java.io")

Asserts that actual is equal to the contents of dumpFile in the DEFAULT_TEST_ASSET_DIRECTORY.

If the assertion fails because of an intended change in the output or a new dump file needs to be created, set DUMP_FILE_ACTION to WRITE_TO_LOCAL for local tests and to WRITE_TO_DEVICE for instrumentation tests, and run the test again. Instead of assertion, actual will be written to dumpFile. For instrumentation tests, this new dump file needs to be copied to the project asset folder manually.

Parameters:context - A context.actual - The actual data.dumpFile - The file path of the dump file in the assets directory.Throws:IOException

- 

assertOutput

public static void assertOutput​([Context](https://developer.android.com/reference/android/content/Context.html "class or interface in android.content")context,[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")actual,[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")assetDirectory,[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")dumpFile)
                         throws[IOException](https://developer.android.com/reference/java/io/IOException.html "class or interface in java.io")

Asserts that actual is equal to the contents of dumpFile in assetDirectory.

If the assertion fails because of an intended change in the output or a new dump file needs to be created, set DUMP_FILE_ACTION to WRITE_TO_LOCAL for local tests and to WRITE_TO_DEVICE for instrumentation tests, and run the test again. Instead of assertion, actual will be written to dumpFile. For instrumentation tests, this new dump file needs to be copied to the project asset folder manually.

Parameters:context - A context.actual - The actual data.assetDirectory - The directory of the assets relative to the project working directory. Only used when DUMP_FILE_ACTION is set to WRITE_TO_LOCAL.dumpFile - The file path of the dump file in the assets directory.Throws:IOException