Skip to content

Commit de63a74

Browse files
brettchabotcopybara-androidxtest
authored andcommitted
Migrate calls to TestStorage.get*Uri methods to PlatformTestStorageRegistry.getInstance().get*Uri2.
This is the first of two changes to upstream the static TestStorage.get*Uri methods into the PlatformTestStorage interface instead. PiperOrigin-RevId: 615481559
1 parent 137df13 commit de63a74

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

espresso/core/javatests/androidx/test/espresso/action/EspressoActionsWithTestFlowTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import androidx.test.filters.LargeTest;
3131
import androidx.test.platform.app.InstrumentationRegistry;
3232
import androidx.test.platform.io.PlatformTestStorageRegistry;
33-
import androidx.test.services.storage.TestStorage;
3433
import androidx.test.services.storage.internal.TestStorageUtil;
3534
import androidx.test.ui.app.LargeViewActivity;
3635
import androidx.test.ui.app.R;
@@ -88,7 +87,7 @@ public void clickActionTestingOfTestFlowOutput() throws IOException {
8887
assertThat(testFlowVisualizer.getLastActionIndexAndIncrement()).isEqualTo(2);
8988
InputStream outputGalleryFile =
9089
TestStorageUtil.getInputStream(
91-
TestStorage.getOutputFileUri("output_gallery.html"),
90+
PlatformTestStorageRegistry.getInstance().getOutputFileUri2("output_gallery.html"),
9291
InstrumentationRegistry.getInstrumentation().getTargetContext().getContentResolver());
9392
int size = outputGalleryFile.available();
9493
byte[] directFileContents = new byte[size];
@@ -130,7 +129,8 @@ public void testFlowVisualizerIfFeatureIsOffShowBreakage() {
130129
FileNotFoundException.class,
131130
() ->
132131
TestStorageUtil.getInputStream(
133-
TestStorage.getOutputFileUri("output_gallery.html"),
132+
PlatformTestStorageRegistry.getInstance()
133+
.getOutputFileUri2("output_gallery.html"),
134134
InstrumentationRegistry.getInstrumentation()
135135
.getTargetContext()
136136
.getContentResolver()));

espresso/core/javatests/androidx/test/espresso/base/DefaultFailureHandlerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import androidx.test.ext.junit.rules.ActivityScenarioRule;
4040
import androidx.test.ext.junit.runners.AndroidJUnit4;
4141
import androidx.test.filters.LargeTest;
42-
import androidx.test.services.storage.TestStorage;
42+
import androidx.test.platform.io.PlatformTestStorageRegistry;
4343
import androidx.test.services.storage.internal.TestStorageUtil;
4444
import androidx.test.ui.app.MainActivity;
4545
import java.io.IOException;
@@ -116,7 +116,7 @@ public void screenshotSaved() throws IOException {
116116
}
117117

118118
private Bitmap readBitmapFromTestStorage(String pathName) throws IOException {
119-
Uri outputFileUri = TestStorage.getOutputFileUri(pathName);
119+
Uri outputFileUri = PlatformTestStorageRegistry.getInstance().getOutputFileUri2(pathName);
120120
try (InputStream input =
121121
TestStorageUtil.getInputStream(
122122
outputFileUri, getApplicationContext().getContentResolver())) {

espresso/core/javatests/androidx/test/espresso/internal/data/TestFlowVisualizerTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import androidx.test.platform.app.InstrumentationRegistry;
2727
import androidx.test.platform.io.PlatformTestStorage;
2828
import androidx.test.platform.io.PlatformTestStorageRegistry;
29-
import androidx.test.services.storage.TestStorage;
3029
import androidx.test.services.storage.internal.TestStorageUtil;
3130
import java.io.IOException;
3231
import java.io.InputStream;
@@ -70,7 +69,7 @@ public void testFlowVisualizerEnsureCorrectOutputForSingleDummyAction() throws I
7069
testFlowVisualizer.visualize();
7170
InputStream outputGalleryFile =
7271
TestStorageUtil.getInputStream(
73-
TestStorage.getOutputFileUri("output_gallery.html"),
72+
PlatformTestStorageRegistry.getInstance().getOutputFileUri2("output_gallery.html"),
7473
InstrumentationRegistry.getInstrumentation().getTargetContext().getContentResolver());
7574
int size = outputGalleryFile.available();
7675
byte[] directFileContents = new byte[size];

services/storage/javatests/androidx/test/services/storage/TestStorageTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public void readWriteOverwriteReadFile() throws IOException {
120120
}
121121

122122
StringBuilder contents = new StringBuilder();
123-
Uri outputFileUri = TestStorage.getOutputFileUri("path/to/file");
123+
Uri outputFileUri = testStorage.getOutputFileUri2("path/to/file");
124124
try (InputStream input =
125125
TestStorageUtil.getInputStream(
126126
outputFileUri, getApplicationContext().getContentResolver())) {
@@ -145,7 +145,7 @@ public void writeFileInAppendMode() throws IOException {
145145
}
146146

147147
byte[] data = new byte[11];
148-
Uri outputFileUri = TestStorage.getOutputFileUri("path/to/file");
148+
Uri outputFileUri = testStorage.getOutputFileUri2("path/to/file");
149149
try (InputStream input =
150150
TestStorageUtil.getInputStream(
151151
outputFileUri, getApplicationContext().getContentResolver())) {

0 commit comments

Comments
 (0)