diff options
author | 2017-12-08 10:52:11 -0800 | |
---|---|---|
committer | 2017-12-08 10:54:13 -0800 | |
commit | 8817ba85138a19225b567b56145d1cda08d4a3c4 (patch) | |
tree | 68a81b8fa5507db58f66f068fd7260398ade4720 /src/test/java/com/google | |
parent | 367f704e71f352b404df38161f4c367b9ff506c9 (diff) |
Stop filtering resources in analysis in aapt2 builds
aapt2 always gets the complete, unfiltered resources, and then filters them in
execution. Save time by not uselessly filtering in analysis.
RELNOTES: none
PiperOrigin-RevId: 178397137
Diffstat (limited to 'src/test/java/com/google')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryTest.java | 38 |
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 |