DO NOT MERGE: Fixed broken aapt2 tests
Some tests starting failing when
b435101ec8aa827375e837c4843f6444145e1f4c was merged. It seems on qt-dev
aapt2_host_unit_tests does not run while it does on master.
Bug: 131762014
Bug: 129146717
Test: aapt2_tests
Change-Id: I701b275989c908acb78190be0930785712cb5686
diff --git a/tools/aapt2/ResourceValues_test.cpp b/tools/aapt2/ResourceValues_test.cpp
index c4a1108..dbf5114 100644
--- a/tools/aapt2/ResourceValues_test.cpp
+++ b/tools/aapt2/ResourceValues_test.cpp
@@ -284,8 +284,58 @@
EXPECT_FALSE(attr_three.IsCompatibleWith(attr_one));
EXPECT_FALSE(attr_three.IsCompatibleWith(attr_two));
- EXPECT_FALSE(attr_three.IsCompatibleWith(attr_three));
+ EXPECT_TRUE(attr_three.IsCompatibleWith(attr_three));
EXPECT_FALSE(attr_three.IsCompatibleWith(attr_four));
+
+ EXPECT_FALSE(attr_four.IsCompatibleWith(attr_one));
+ EXPECT_FALSE(attr_four.IsCompatibleWith(attr_two));
+ EXPECT_FALSE(attr_four.IsCompatibleWith(attr_three));
+ EXPECT_TRUE(attr_four.IsCompatibleWith(attr_four));
+}
+
+TEST(ResourcesValuesTest, AttributeEnumIsCompatible) {
+ Attribute attr_one(TYPE_ENUM);
+ attr_one.symbols.push_back(
+ Attribute::Symbol{Reference(test::ParseNameOrDie("android:id/foo")), 0x01u});
+ attr_one.symbols.push_back(
+ Attribute::Symbol{Reference(test::ParseNameOrDie("android:id/bar")), 0x07u});
+
+ Attribute attr_two(TYPE_ENUM);
+ attr_two.symbols.push_back(
+ Attribute::Symbol{Reference(test::ParseNameOrDie("android:id/foo")), 0x01u});
+ attr_two.symbols.push_back(
+ Attribute::Symbol{Reference(test::ParseNameOrDie("android:id/bar")), 0x07u});
+ EXPECT_TRUE(attr_one.IsCompatibleWith(attr_two));
+}
+
+TEST(ResourcesValuesTest, DifferentAttributeEnumDifferentNameIsNotCompatible) {
+ Attribute attr_one(TYPE_ENUM);
+ attr_one.symbols.push_back(
+ Attribute::Symbol{Reference(test::ParseNameOrDie("android:id/foo")), 0x01u});
+ attr_one.symbols.push_back(
+ Attribute::Symbol{Reference(test::ParseNameOrDie("android:id/bar")), 0x07u});
+
+ Attribute attr_two(TYPE_ENUM);
+ attr_two.symbols.push_back(
+ Attribute::Symbol{Reference(test::ParseNameOrDie("android:id/foo")), 0x01u});
+ attr_one.symbols.push_back(
+ Attribute::Symbol{Reference(test::ParseNameOrDie("android:id/baz")), 0x07u});
+ EXPECT_FALSE(attr_one.IsCompatibleWith(attr_two));
+}
+
+TEST(ResourcesValuesTest, DifferentAttributeEnumDifferentValueIsNotCompatible) {
+ Attribute attr_one(TYPE_ENUM);
+ attr_one.symbols.push_back(
+ Attribute::Symbol{Reference(test::ParseNameOrDie("android:id/foo")), 0x01u});
+ attr_one.symbols.push_back(
+ Attribute::Symbol{Reference(test::ParseNameOrDie("android:id/bar")), 0x07u});
+
+ Attribute attr_two(TYPE_ENUM);
+ attr_two.symbols.push_back(
+ Attribute::Symbol{Reference(test::ParseNameOrDie("android:id/foo")), 0x01u});
+ attr_two.symbols.push_back(
+ Attribute::Symbol{Reference(test::ParseNameOrDie("android:id/bar")), 0x09u});
+ EXPECT_FALSE(attr_one.IsCompatibleWith(attr_two));
}
} // namespace aapt