{% 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 @NonNull void |
addOutputProperties(Adds the given properties. |
abstract @NonNull String |
getInputArg(@NonNull String argName)Returns the value of a given argument name. |
abstract @NonNull Map<@NonNull String, @NonNull String> |
Returns the name/value map of all test arguments or an empty map if no arguments are defined. |
abstract @NonNull Map<@NonNull String, @NonNull Serializable> |
Returns a map of all the output test properties. |
abstract @NonNull InputStream |
openInputFile(@NonNull String pathname)Provides an InputStream to a test file dependency. |
abstract @NonNull InputStream |
openInternalInputFile(@NonNull String pathname)Provides an InputStream to an internal file used by the testing infrastructure. |
abstract @NonNull OutputStream |
openInternalOutputFile(@NonNull String pathname)Provides an OutputStream to an internal file used by the testing infrastructure. |
abstract @NonNull OutputStream |
openOutputFile(@NonNull String pathname)Provides an OutputStream to a test output file. |
abstract @NonNull OutputStream |
openOutputFile(@NonNull String pathname, @NonNull boolean append)Provides an OutputStream to a test output file. |
@NonNull
public abstract void addOutputProperties(
@NonNull Map<@NonNull String, @NonNull 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.
@NonNull
public abstract String getInputArg(@NonNull String argName)
Returns the value of a given argument name.
@NonNull
public abstract Map<@NonNull String, @NonNull String> getInputArgs()
Returns the name/value map of all test arguments or an empty map if no arguments are defined.
@NonNull
public abstract Map<@NonNull String, @NonNull Serializable> getOutputProperties()
Returns a map of all the output test properties. If no properties exist, an empty map will be returned.
@NonNull
public abstract InputStream openInputFile(@NonNull String pathname)
Provides an InputStream to a test file dependency.
| Returns | |
|---|---|
InputStream |
an InputStream to the given test file. |
@NonNull
public abstract InputStream openInternalInputFile(@NonNull String pathname)
Provides an InputStream to an internal file used by the testing infrastructure.
| Returns | |
|---|---|
InputStream |
an InputStream to the given test file. |
@NonNull
public abstract OutputStream openInternalOutputFile(@NonNull String pathname)
Provides an OutputStream to an internal file used by the testing infrastructure.
| Returns | |
|---|---|
OutputStream |
an OutputStream to the given output file. |
@NonNull
public abstract OutputStream openOutputFile(@NonNull String pathname)
Provides an OutputStream to a test output file.
| Returns | |
|---|---|
OutputStream |
an OutputStream to the given output file. |
@NonNull
public abstract OutputStream openOutputFile(@NonNull String pathname, @NonNull boolean append)
Provides an OutputStream to a test output file.
| Parameters | |
|---|---|
@NonNull String pathname |
path to the test output file. Should not be null. |
@NonNull 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. |