Skip to content

Commit 9ffb8f7

Browse files
brettchabotcopybara-androidxtest
authored andcommitted
Add PlatformTestStorage get*Uri methods.
And remove the existing static TestStorage methods. PiperOrigin-RevId: 617882692
1 parent f202cdf commit 9ffb8f7

File tree

10 files changed

+33
-35
lines changed

10 files changed

+33
-35
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public void clickActionTestingOfTestFlowOutput() throws IOException {
8787
assertThat(testFlowVisualizer.getLastActionIndexAndIncrement()).isEqualTo(2);
8888
InputStream outputGalleryFile =
8989
TestStorageUtil.getInputStream(
90-
PlatformTestStorageRegistry.getInstance().getOutputFileUri2("output_gallery.html"),
90+
PlatformTestStorageRegistry.getInstance().getOutputFileUri("output_gallery.html"),
9191
InstrumentationRegistry.getInstrumentation().getTargetContext().getContentResolver());
9292
int size = outputGalleryFile.available();
9393
byte[] directFileContents = new byte[size];
@@ -129,8 +129,7 @@ public void testFlowVisualizerIfFeatureIsOffShowBreakage() {
129129
FileNotFoundException.class,
130130
() ->
131131
TestStorageUtil.getInputStream(
132-
PlatformTestStorageRegistry.getInstance()
133-
.getOutputFileUri2("output_gallery.html"),
132+
PlatformTestStorageRegistry.getInstance().getOutputFileUri("output_gallery.html"),
134133
InstrumentationRegistry.getInstrumentation()
135134
.getTargetContext()
136135
.getContentResolver()));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public void screenshotSaved() throws IOException {
116116
}
117117

118118
private Bitmap readBitmapFromTestStorage(String pathName) throws IOException {
119-
Uri outputFileUri = PlatformTestStorageRegistry.getInstance().getOutputFileUri2(pathName);
119+
Uri outputFileUri = PlatformTestStorageRegistry.getInstance().getOutputFileUri(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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void testFlowVisualizerEnsureCorrectOutputForSingleDummyAction() throws I
6969
testFlowVisualizer.visualize();
7070
InputStream outputGalleryFile =
7171
TestStorageUtil.getInputStream(
72-
PlatformTestStorageRegistry.getInstance().getOutputFileUri2("output_gallery.html"),
72+
PlatformTestStorageRegistry.getInstance().getOutputFileUri("output_gallery.html"),
7373
InstrumentationRegistry.getInstrumentation().getTargetContext().getContentResolver());
7474
int size = outputGalleryFile.available();
7575
byte[] directFileContents = new byte[size];

runner/android_junit_runner/javatests/androidx/test/internal/runner/RunnerArgsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -759,12 +759,12 @@ public OutputStream openInternalOutputFile(String pathname) {
759759
}
760760

761761
@Override
762-
public Uri getInputFileUri2(String pathname) {
762+
public Uri getInputFileUri(String pathname) {
763763
throw new UnsupportedOperationException();
764764
}
765765

766766
@Override
767-
public Uri getOutputFileUri2(String pathname) {
767+
public Uri getOutputFileUri(String pathname) {
768768
throw new UnsupportedOperationException();
769769
}
770770

runner/monitor/java/androidx/test/platform/io/FileTestStorage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,12 @@ public OutputStream openInternalOutputFile(String pathname) throws FileNotFoundE
152152
}
153153

154154
@Override
155-
public Uri getInputFileUri2(@NonNull String pathname) {
155+
public Uri getInputFileUri(@NonNull String pathname) {
156156
throw new UnsupportedOperationException();
157157
}
158158

159159
@Override
160-
public Uri getOutputFileUri2(@NonNull String pathname) {
160+
public Uri getOutputFileUri(@NonNull String pathname) {
161161
File outputFile = new File(pathname);
162162
if (!outputFile.isAbsolute()) {
163163
outputFile = new File(outputDirCalculator.getOutputDir(), pathname);

runner/monitor/java/androidx/test/platform/io/PlatformTestStorage.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,15 @@ public interface PlatformTestStorage {
129129
* @return a content Uri to the test file dependency.
130130
* <p>Note: temporary API - will be renamed to getInputFileUri in future
131131
*/
132-
Uri getInputFileUri2(@NonNull String pathname);
132+
Uri getInputFileUri(@NonNull String pathname);
133+
134+
/**
135+
* @deprecated use getInputFileUri instead
136+
*/
137+
@Deprecated
138+
default Uri getInputFileUri2(@NonNull String pathname) {
139+
return getInputFileUri(pathname);
140+
}
133141

134142
/**
135143
* Provides a Uri to a test output file.
@@ -146,7 +154,15 @@ public interface PlatformTestStorage {
146154
* "/path/to/my_output.txt", the file will end up at
147155
* "/sdcard/test_output_files/path/to/my_output.txt" on device.
148156
*/
149-
Uri getOutputFileUri2(@NonNull String pathname);
157+
Uri getOutputFileUri(@NonNull String pathname);
158+
159+
/**
160+
* @deprecated use getOutputFileUri instead
161+
*/
162+
@Deprecated
163+
default Uri getOutputFileUri2(@NonNull String pathname) {
164+
return getOutputFileUri(pathname);
165+
}
150166

151167
/**
152168
* Returns true if {@code pathname} corresponds to a file or directory that is in a directory

runner/monitor/java/androidx/test/platform/io/PlatformTestStorageRegistry.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ public OutputStream openInternalOutputFile(String pathname) {
118118
}
119119

120120
@Override
121-
public Uri getInputFileUri2(@NonNull String pathname) {
121+
public Uri getInputFileUri(@NonNull String pathname) {
122122
return null;
123123
}
124124

125125
@Override
126-
public Uri getOutputFileUri2(@NonNull String pathname) {
126+
public Uri getOutputFileUri(@NonNull String pathname) {
127127
return null;
128128
}
129129

services/storage/java/androidx/test/services/storage/TestStorage.java

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,6 @@ public TestStorage(@NonNull ContentResolver contentResolver) {
7676
this.contentResolver = contentResolver;
7777
}
7878

79-
/**
80-
* @deprecated call getInputFileUri2 instead
81-
*/
82-
@Deprecated
83-
public static Uri getInputFileUri(@NonNull String pathname) {
84-
checkNotNull(pathname);
85-
return HostedFile.buildUri(HostedFile.FileHost.TEST_FILE, pathname);
86-
}
87-
8879
/**
8980
* Provides a Uri to a test file dependency.
9081
*
@@ -100,7 +91,7 @@ public static Uri getInputFileUri(@NonNull String pathname) {
10091
* @return a content Uri to the test file dependency.
10192
*/
10293
@Override
103-
public Uri getInputFileUri2(@NonNull String pathname) {
94+
public Uri getInputFileUri(@NonNull String pathname) {
10495
checkNotNull(pathname);
10596
return HostedFile.buildUri(HostedFile.FileHost.TEST_FILE, pathname);
10697
}
@@ -119,16 +110,7 @@ public Uri getInputFileUri2(@NonNull String pathname) {
119110
* "/sdcard/test_output_files/path/to/my_output.txt" on device.
120111
*/
121112
@Override
122-
public Uri getOutputFileUri2(@NonNull String pathname) {
123-
checkNotNull(pathname);
124-
return HostedFile.buildUri(HostedFile.FileHost.OUTPUT, pathname);
125-
}
126-
127-
/**
128-
* @deprecated call getOutputFileUri2 instead
129-
*/
130-
@Deprecated
131-
public static Uri getOutputFileUri(@NonNull String pathname) {
113+
public Uri getOutputFileUri(@NonNull String pathname) {
132114
checkNotNull(pathname);
133115
return HostedFile.buildUri(HostedFile.FileHost.OUTPUT, pathname);
134116
}

services/storage/javatests/androidx/test/services/storage/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ axt_android_library_test(
1818
],
1919
deps = [
2020
"//core/java/androidx/test/core",
21+
"//runner/monitor/java/androidx/test:monitor",
2122
"//services/storage/java/androidx/test/services/storage",
2223
"//services/storage/java/androidx/test/services/storage/file",
2324
"@maven//:com_google_truth_truth",

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.getOutputFileUri2("path/to/file");
123+
Uri outputFileUri = testStorage.getOutputFileUri("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.getOutputFileUri2("path/to/file");
148+
Uri outputFileUri = testStorage.getOutputFileUri("path/to/file");
149149
try (InputStream input =
150150
TestStorageUtil.getInputStream(
151151
outputFileUri, getApplicationContext().getContentResolver())) {

0 commit comments

Comments
 (0)