{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}
interface PlatformTestStorage
FileTestStorage |
A class that reads/writes the runner data using the raw file system. |
An interface represents on-device I/O operations in an Android test.
This is a low level API, typically used by higher level test frameworks. It is generally not recommended for direct use by most tests.
Use a concrete implementation class of this interface if you need to read/write files in your tests. For example, in an Android Instrumentation test, use
androidx.test.services.storage.TestStorage when the test services is installed on the device.
This API is experimental and is subject to change or removal in future releases.
Public methods |
|
|---|---|
abstract void |
addOutputProperties(Map<String, Serializable> properties)Adds the given properties. |
abstract String |
getInputArg(String argName)Returns the value of a given argument name. |
abstract Map<String, String> |
Returns the name/value map of all test arguments or an empty map if no arguments are defined. |
abstract Map<String, Serializable> |
Returns a map of all the output test properties. |
abstract InputStream |
openInputFile(String pathname)Provides an InputStream to a test file dependency. |
abstract InputStream |
openInternalInputFile(String pathname)Provides an InputStream to an internal file used by the testing infrastructure. |
abstract OutputStream |
openInternalOutputFile(String pathname)Provides an OutputStream to an internal file used by the testing infrastructure. |
abstract OutputStream |
openOutputFile(String pathname)Provides an OutputStream to a test output file. |
abstract OutputStream |
openOutputFile(String pathname, boolean append)Provides an OutputStream to a test output file. |
abstract void addOutputProperties(Map<String, Serializable> properties)
Adds the given properties.
Adding a property with the same name would append new values and overwrite the old values if keys already exist.
abstract String getInputArg(String argName)
Returns the value of a given argument name.
| Parameters | |
|---|---|
String argName |
the argument name. Should not be null. |
abstract Map<String, String> getInputArgs()
Returns the name/value map of all test arguments or an empty map if no arguments are defined.
abstract Map<String, Serializable> getOutputProperties()
Returns a map of all the output test properties. If no properties exist, an empty map will be returned.
abstract InputStream openInputFile(String pathname)
Provides an InputStream to a test file dependency.
| Parameters | |
|---|---|
String pathname |
path to the test file dependency. Should not be null. |
| Returns | |
|---|---|
InputStream |
an InputStream to the given test file. |
| Throws | |
|---|---|
java.io.IOException java.io.IOException |
|
abstract InputStream openInternalInputFile(String pathname)
Provides an InputStream to an internal file used by the testing infrastructure.
| Parameters | |
|---|---|
String pathname |
path to the internal file. Should not be null. |
| Returns | |
|---|---|
InputStream |
an InputStream to the given test file. |
| Throws | |
|---|---|
java.io.IOException java.io.IOException |
|
abstract OutputStream openInternalOutputFile(String pathname)
Provides an OutputStream to an internal file used by the testing infrastructure.
| Parameters | |
|---|---|
String pathname |
path to the internal file. Should not be null. |
| Returns | |
|---|---|
OutputStream |
an OutputStream to the given output file. |
| Throws | |
|---|---|
java.io.IOException java.io.IOException |
|
abstract OutputStream openOutputFile(String pathname)
Provides an OutputStream to a test output file.
| Parameters | |
|---|---|
String pathname |
path to the test output file. Should not be null. |
| Returns | |
|---|---|
OutputStream |
an OutputStream to the given output file. |
| Throws | |
|---|---|
java.io.IOException java.io.IOException |
|
abstract OutputStream openOutputFile(String pathname, boolean append)
Provides an OutputStream to a test output file.
| Parameters | |
|---|---|
String pathname |
path to the test output file. Should not be null. |
boolean append |
if true, then the lines will be added to the end of the file rather than overwriting. |
| Returns | |
|---|---|
OutputStream |
an OutputStream to the given output file. |
| Throws | |
|---|---|
java.io.IOException java.io.IOException |
|