AAPT2: inferred style parent processing
Change-Id: I8fbc4feef16b6039cf4c526fcfb767dc75a9c131
diff --git a/tools/aapt2/ResourceParser_test.cpp b/tools/aapt2/ResourceParser_test.cpp
index 00be3bd..3d8a2f0 100644
--- a/tools/aapt2/ResourceParser_test.cpp
+++ b/tools/aapt2/ResourceParser_test.cpp
@@ -355,6 +355,28 @@
style->entries[0].key.name);
}
+TEST_F(ResourceParserTest, ParseStyleWithInferredParent) {
+ std::string input = "<style name=\"foo.bar\"/>";
+ ASSERT_TRUE(testParse(input));
+
+ const Style* style = findResource<Style>(ResourceName{
+ u"android", ResourceType::kStyle, u"foo.bar" });
+ ASSERT_NE(style, nullptr);
+ EXPECT_EQ(style->parent.name, (ResourceName{ u"android", ResourceType::kStyle, u"foo" }));
+ EXPECT_TRUE(style->parentInferred);
+}
+
+TEST_F(ResourceParserTest, ParseStyleWithInferredParentOverridenByEmptyParentAttribute) {
+ std::string input = "<style name=\"foo.bar\" parent=\"\"/>";
+ ASSERT_TRUE(testParse(input));
+
+ const Style* style = findResource<Style>(ResourceName{
+ u"android", ResourceType::kStyle, u"foo.bar" });
+ ASSERT_NE(style, nullptr);
+ EXPECT_FALSE(style->parent.name.isValid());
+ EXPECT_FALSE(style->parentInferred);
+}
+
TEST_F(ResourceParserTest, ParseAutoGeneratedIdReference) {
std::string input = "<string name=\"foo\">@+id/bar</string>";
ASSERT_TRUE(testParse(input));