Test overriding resource type in RawResourceDataSource

I couldn't work out a good way to set up a test environment with
an asset in a different package, so I'm not adding a test for the
package overriding.

PiperOrigin-RevId: 573843326
This commit is contained in:
ibaker 2023-10-16 09:53:31 -07:00 committed by Copybara-Service
parent fe1144487a
commit 681eadeb85
2 changed files with 12 additions and 1 deletions

View File

@ -31,6 +31,7 @@ public final class RawResourceDataSourceContractTest extends DataSourceContractT
private static final byte[] RESOURCE_1_DATA = Util.getUtf8Bytes("resource1 abc\n");
private static final byte[] RESOURCE_2_DATA = Util.getUtf8Bytes("resource2 abcdef\n");
private static final byte[] FONT_DATA = Util.getUtf8Bytes("test font data\n");
@Override
protected DataSource createDataSource() {
@ -58,7 +59,7 @@ public final class RawResourceDataSourceContractTest extends DataSourceContractT
.build(),
// Additional resources using different URI schemes.
new TestResource.Builder()
.setName("android.resource:// with package, type, and name")
.setName("android.resource:// with package, 'raw' type, and name")
.setUri(
Uri.parse(
"android.resource://"
@ -66,6 +67,15 @@ public final class RawResourceDataSourceContractTest extends DataSourceContractT
+ "/raw/resource1"))
.setExpectedBytes(RESOURCE_1_DATA)
.build(),
new TestResource.Builder()
.setName("android.resource:// with package, 'font' type, and name")
.setUri(
Uri.parse(
"android.resource://"
+ ApplicationProvider.getApplicationContext().getPackageName()
+ "/font/test_font"))
.setExpectedBytes(FONT_DATA)
.build(),
new TestResource.Builder()
.setName("android.resource:// with type and name only")
.setUri(Uri.parse("android.resource:///raw/resource1"))

View File

@ -0,0 +1 @@
test font data