Skip to content

Commit

Permalink
Test overriding resource type in RawResourceDataSource
Browse files Browse the repository at this point in the history
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
  • Loading branch information
icbaker authored and copybara-github committed Oct 16, 2023
1 parent fe11444 commit 681eade
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -58,14 +59,23 @@ protected ImmutableList<TestResource> getTestResources() {
.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://"
+ ApplicationProvider.getApplicationContext().getPackageName()
+ "/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"))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test font data

0 comments on commit 681eade

Please sign in to comment.