aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com/google')
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryTest.java38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryTest.java b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryTest.java
index c1df324407..7cdd63005e 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryTest.java
@@ -1258,6 +1258,44 @@ public class AndroidBinaryTest extends AndroidBuildViewTestCase {
assertThat(resourceArguments(directResources)).contains("hdpi,xhdpi");
}
+ /** Test that resources are not filtered in analysis under aapt2. */
+ @Test
+ public void testFilteredResourcesFilteringAapt2() throws Exception {
+ List<String> resources =
+ ImmutableList.of("res/values/foo.xml", "res/values-en/foo.xml", "res/values-fr/foo.xml");
+ String dir = "java/r/android";
+
+ mockAndroidSdkWithAapt2();
+
+ useConfiguration(
+ "--android_sdk=//sdk:sdk",
+ "--experimental_android_resource_filtering_method",
+ "filter_in_analysis");
+
+ ConfiguredTarget binary =
+ scratchConfiguredTarget(
+ dir,
+ "r",
+ "android_binary(name = 'r',",
+ " manifest = 'AndroidManifest.xml',",
+ " resource_configuration_filters = ['', 'en, es, '],",
+ " aapt_version = 'aapt2',",
+ " densities = ['hdpi, , ', 'xhdpi'],",
+ " resource_files = ['" + Joiner.on("', '").join(resources) + "'])");
+ ResourceContainer directResources = getResourceContainer(binary, /* transitive= */ false);
+
+ // Validate that the AndroidResourceProvider for this binary contains all values.
+ assertThat(resourceContentsPaths(dir, directResources)).containsExactlyElementsIn(resources);
+
+ // Validate that the input to resource processing contains all values.
+ assertThat(resourceInputPaths(dir, directResources)).containsAllIn(resources);
+
+ // Validate that the filters are correctly passed to the resource processing action
+ // This includes trimming whitespace and ignoring empty filters.
+ assertThat(resourceArguments(directResources)).contains("en,es");
+ assertThat(resourceArguments(directResources)).contains("hdpi,xhdpi");
+ }
+
@Test
public void testFilteredResourcesFilteringNotSpecified() throws Exception {
// TODO(asteinb): Once prefiltering is run by default, remove this test and remove the