aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java
diff options
context:
space:
mode:
authorGravatar dannark <dannark@google.com>2018-02-22 18:29:57 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-02-22 18:31:57 -0800
commitda51eb327c39b64357faa85ce5c884d51a58c003 (patch)
tree9464719321f4128c64711b8390ab684f21df66fe /src/test/java
parent00c317b1677ee817c4534497e1e0f88b2ae0a40d (diff)
Enable ability to pass the resource apk to Robolectric so that it can consume binary resources.
This functionality is guarded by a flag, --experimental_android_local_test_binary_resources whose default value is false. If the flag is set to true, Bazel will generate the .ap_ and add the path to the .ap_ to the test_config.properties file. Bazel will still generate and pass the raw resources to Robolectric in both cases and so the cue to Robolectric that binary resources should be used is the presence of the path to the .ap_ in the test_config.properties file. RELNOTES: None PiperOrigin-RevId: 186708941
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/android/AndroidLocalTestTest.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidLocalTestTest.java b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidLocalTestTest.java
index 34583b7dea..9095676700 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidLocalTestTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidLocalTestTest.java
@@ -130,6 +130,37 @@ public abstract class AndroidLocalTestTest extends AbstractAndroidLocalTestTestB
MoreAsserts.assertContainsSublist(args, "--packageForR", "custom.pkg");
}
+ @Test
+ public void testBinaryResources() throws Exception {
+ scratch.file(
+ "java/test/BUILD",
+ "load('//java/bar:foo.bzl', 'extra_deps')",
+ "android_local_test(name = 'dummyTest',",
+ " srcs = ['test.java'],",
+ " deps = extra_deps)");
+ useConfiguration("--experimental_android_local_test_binary_resources");
+ ConfiguredTarget target = getConfiguredTarget("//java/test:dummyTest");
+ Iterable<Artifact> runfilesArtifacts = collectRunfiles(target);
+ Artifact resourceApk =
+ ActionsTestUtil.getFirstArtifactEndingWith(runfilesArtifacts, "dummyTest.ap_");
+ assertThat(resourceApk).isNotNull();
+ }
+
+ @Test
+ public void testNoBinaryResources() throws Exception {
+ scratch.file(
+ "java/test/BUILD",
+ "load('//java/bar:foo.bzl', 'extra_deps')",
+ "android_local_test(name = 'dummyTest',",
+ " srcs = ['test.java'],",
+ " deps = extra_deps)");
+ ConfiguredTarget target = getConfiguredTarget("//java/test:dummyTest");
+ Iterable<Artifact> runfilesArtifacts = collectRunfiles(target);
+ Artifact resourceApk =
+ ActionsTestUtil.getFirstArtifactEndingWith(runfilesArtifacts, "dummyTest.ap_");
+ assertThat(resourceApk).isNull();
+ }
+
@Override
protected String getRuleName() {
return "android_local_test";