AAPT: Filtering resource fix

Previously, when filtering resources from an APK using
-c option, if one qualifier matched, we would keep the resource.
However, in the case of something like

-c fr-FR,sw360dp

and with a resource in the APK like so

drawable-fr-FR-sw600dp-v13

we would want this resource to be excluded, as it does not
match the sw360dp qualifier (must be less than or equal to it).

This CL fixed the behavior of the filter to require that all
defined qualifier axis be matched.

Bug:17142358
Change-Id: Ie48f3d516a0e610abc7ba8a7ced4eb3ab52534d4
diff --git a/tools/aapt/tests/ResourceFilter_test.cpp b/tools/aapt/tests/ResourceFilter_test.cpp
index b55379e..bbc2e02 100644
--- a/tools/aapt/tests/ResourceFilter_test.cpp
+++ b/tools/aapt/tests/ResourceFilter_test.cpp
@@ -75,6 +75,17 @@
     EXPECT_TRUE(filter.match(config));
 }
 
+TEST(WeakResourceFilterTest, MatchesConfigWithOneMatchingAxis) {
+    WeakResourceFilter filter;
+    ASSERT_EQ(NO_ERROR, filter.parse(String8("fr_FR,sw360dp,normal,en_US")));
+
+    ConfigDescription config;
+    config.language[0] = 'e';
+    config.language[1] = 'n';
+
+    EXPECT_TRUE(filter.match(config));
+}
+
 TEST(WeakResourceFilterTest, DoesNotMatchConfigWithDifferentValueAxis) {
     WeakResourceFilter filter;
     ASSERT_EQ(NO_ERROR, filter.parse(String8("fr")));
@@ -86,6 +97,32 @@
     EXPECT_FALSE(filter.match(config));
 }
 
+TEST(WeakResourceFilterTest, DoesNotMatchWhenOneQualifierIsExplicitlyNotMatched) {
+    WeakResourceFilter filter;
+    ASSERT_EQ(NO_ERROR, filter.parse(String8("fr_FR,en_US,normal,large,xxhdpi,sw320dp")));
+
+    ConfigDescription config;
+    config.language[0] = 'f';
+    config.language[1] = 'r';
+    config.smallestScreenWidthDp = 600;
+    config.version = 13;
+
+    EXPECT_FALSE(filter.match(config));
+}
+
+TEST(WeakResourceFilterTest, MatchesSmallestWidthWhenSmaller) {
+    WeakResourceFilter filter;
+    ASSERT_EQ(NO_ERROR, filter.parse(String8("sw600dp")));
+
+    ConfigDescription config;
+    config.language[0] = 'f';
+    config.language[1] = 'r';
+    config.smallestScreenWidthDp = 320;
+    config.version = 13;
+
+    EXPECT_TRUE(filter.match(config));
+}
+
 TEST(WeakResourceFilterTest, MatchesConfigWithSameLanguageButNoRegionSpecified) {
     WeakResourceFilter filter;
     ASSERT_EQ(NO_ERROR, filter.parse(String8("de-rDE")));