Add RawResourceDataSource
test for android.resource:///id
URI
This is the documented format of this URI. The previous test was exercising an undocumented format. Support for the previous format is kept (and documented) because it seems to be relatively common (despite the package name not being needed or used). PiperOrigin-RevId: 573756190
This commit is contained in:
parent
58a63c82aa
commit
35121a2d3d
@ -78,12 +78,12 @@ public final class RawResourceDataSourceContractTest extends DataSourceContractT
|
||||
.build(),
|
||||
new TestResource.Builder()
|
||||
.setName("android.resource:// with ID")
|
||||
.setUri(
|
||||
Uri.parse(
|
||||
"android.resource://"
|
||||
+ ApplicationProvider.getApplicationContext().getPackageName()
|
||||
+ "/"
|
||||
+ R.raw.resource1))
|
||||
.setUri(Uri.parse("android.resource:///" + R.raw.resource1))
|
||||
.setExpectedBytes(RESOURCE_1_DATA)
|
||||
.build(),
|
||||
new TestResource.Builder()
|
||||
.setName("android.resource:// with (unused) package and ID")
|
||||
.setUri(Uri.parse("android.resource://unused.package.name/" + R.raw.resource1))
|
||||
.setExpectedBytes(RESOURCE_1_DATA)
|
||||
.build());
|
||||
}
|
||||
|
@ -51,6 +51,11 @@ import java.nio.channels.FileChannel;
|
||||
* efficient.
|
||||
* </ul>
|
||||
*
|
||||
* <p>URIs of the form {@code android.resource://package/id} are also supported, although the
|
||||
* package part is not needed and is not used. This support is due to this format being prevalent in
|
||||
* the ecosystem (including being <a href="https://stackoverflow.com/a/4896272">recommended on Stack
|
||||
* Overflow</a>).
|
||||
*
|
||||
* <p>{@link #buildRawResourceUri(int)} can be used to build supported {@link Uri}s.
|
||||
*/
|
||||
@UnstableApi
|
||||
|
Loading…
x
Reference in New Issue
Block a user