summaryrefslogtreecommitdiff
path: root/tools/aapt2/ResourceParser_test.cpp
diff options
context:
space:
mode:
authorRyan Mitchell <rtmitchell@google.com>2018-04-25 15:00:50 -0700
committerRyan Mitchell <rtmitchell@google.com>2018-05-01 11:11:55 -0700
commiteaf77e1d3a6ad4995ddd92a429802cffbf0f0209 (patch)
tree17a7b20a176b55367acf6655c0f77cc998b48864 /tools/aapt2/ResourceParser_test.cpp
parentdc34eb605520a7f4f9401c4569a2573171111e9d (diff)
AAPT2: Fixed id parsing error
A previous change, editied the logic for parsing ids to allow for ids to reference other ids. This change though caused a regression that made ids in the form '<id name="name" />' cease to parse. This changes fixes that regression. Bug: 78513618 Test: Updated tests in ResourceParser_test.cpp Change-Id: I3608bb764464e951a50910be55e199c6ec575d09
Diffstat (limited to 'tools/aapt2/ResourceParser_test.cpp')
-rw-r--r--tools/aapt2/ResourceParser_test.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/tools/aapt2/ResourceParser_test.cpp b/tools/aapt2/ResourceParser_test.cpp
index c12b9fac5704..41b4041efb7a 100644
--- a/tools/aapt2/ResourceParser_test.cpp
+++ b/tools/aapt2/ResourceParser_test.cpp
@@ -944,20 +944,30 @@ TEST_F(ResourceParserTest, ParseIdItem) {
ASSERT_THAT(test::GetValue<Id>(&table_, "id/bar"), NotNull());
ASSERT_THAT(test::GetValue<Id>(&table_, "id/baz"), NotNull());
+ input = R"(
+ <id name="foo2">@id/bar</id>
+ <id name="bar2"/>
+ <id name="baz2"></id>)";
+ ASSERT_TRUE(TestParse(input));
+
+ ASSERT_THAT(test::GetValue<Reference>(&table_, "id/foo2"), NotNull());
+ ASSERT_THAT(test::GetValue<Id>(&table_, "id/bar2"), NotNull());
+ ASSERT_THAT(test::GetValue<Id>(&table_, "id/baz2"), NotNull());
+
// Reject attribute references
- input = R"(<item name="foo2" type="id">?attr/bar"</item>)";
+ input = R"(<item name="foo3" type="id">?attr/bar"</item>)";
ASSERT_FALSE(TestParse(input));
// Reject non-references
- input = R"(<item name="foo3" type="id">0x7f010001</item>)";
+ input = R"(<item name="foo4" type="id">0x7f010001</item>)";
ASSERT_FALSE(TestParse(input));
- input = R"(<item name="foo4" type="id">@drawable/my_image</item>)";
+ input = R"(<item name="foo5" type="id">@drawable/my_image</item>)";
ASSERT_FALSE(TestParse(input));
- input = R"(<item name="foo5" type="id"><string name="biz"></string></item>)";
+ input = R"(<item name="foo6" type="id"><string name="biz"></string></item>)";
ASSERT_FALSE(TestParse(input));
// Ids that reference other resource ids cannot be public
- input = R"(<public name="foo6" type="id">@id/bar6</item>)";
+ input = R"(<public name="foo7" type="id">@id/bar7</item>)";
ASSERT_FALSE(TestParse(input));
}