diff options
author | Adam Lesinski <adamlesinski@google.com> | 2015-11-16 17:35:44 -0800 |
---|---|---|
committer | Adam Lesinski <adamlesinski@google.com> | 2015-11-19 14:46:53 -0800 |
commit | 467f171315f9c2037fcd3eb5edcfabc40671bf7b (patch) | |
tree | 3b14762e3d9e42a660479d0d5722883b391f835b /tools/aapt2/ResourceParser_test.cpp | |
parent | abf83cbe4f63cd76043aab89cd0e08525560fea2 (diff) |
AAPT2: Fail compiling when private symbols are referenced
Also moved some XML specific stuff into its own directory,
and refactored ReferenceLinker a bit.
Change-Id: I912247a82023c1bbf72dc191fbdaf62858cbec0c
Diffstat (limited to 'tools/aapt2/ResourceParser_test.cpp')
-rw-r--r-- | tools/aapt2/ResourceParser_test.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/tools/aapt2/ResourceParser_test.cpp b/tools/aapt2/ResourceParser_test.cpp index b59eb95e7448..ab16424db709 100644 --- a/tools/aapt2/ResourceParser_test.cpp +++ b/tools/aapt2/ResourceParser_test.cpp @@ -18,9 +18,8 @@ #include "ResourceTable.h" #include "ResourceUtils.h" #include "ResourceValues.h" -#include "XmlPullParser.h" - #include "test/Context.h" +#include "xml/XmlPullParser.h" #include <gtest/gtest.h> #include <sstream> @@ -36,7 +35,7 @@ TEST(ResourceParserSingleTest, FailToParseWithNoRootResourcesElement) { input << "<attr name=\"foo\"/>" << std::endl; ResourceTable table; ResourceParser parser(context->getDiagnostics(), &table, Source{ "test" }, {}); - XmlPullParser xmlParser(input); + xml::XmlPullParser xmlParser(input); ASSERT_FALSE(parser.parse(&xmlParser)); } @@ -56,7 +55,7 @@ struct ResourceParserTest : public ::testing::Test { parserOptions.product = product; ResourceParser parser(mContext->getDiagnostics(), &mTable, Source{ "test" }, {}, parserOptions); - XmlPullParser xmlParser(input); + xml::XmlPullParser xmlParser(input); if (parser.parse(&xmlParser)) { return ::testing::AssertionSuccess(); } @@ -360,6 +359,25 @@ TEST_F(ResourceParserTest, ParseAttributesDeclareStyleable) { EXPECT_EQ(test::parseNameOrDie(u"@attr/bat"), styleable->entries[1].name.value()); } +TEST_F(ResourceParserTest, ParsePrivateAttributesDeclareStyleable) { + std::string input = "<declare-styleable name=\"foo\" xmlns:privAndroid=\"http://schemas.android.com/apk/prv/res/android\">\n" + " <attr name=\"*android:bar\" />\n" + " <attr name=\"privAndroid:bat\" />\n" + "</declare-styleable>"; + ASSERT_TRUE(testParse(input)); + Styleable* styleable = test::getValue<Styleable>(&mTable, u"@styleable/foo"); + ASSERT_NE(nullptr, styleable); + ASSERT_EQ(2u, styleable->entries.size()); + + EXPECT_TRUE(styleable->entries[0].privateReference); + AAPT_ASSERT_TRUE(styleable->entries[0].name); + EXPECT_EQ(std::u16string(u"android"), styleable->entries[0].name.value().package); + + EXPECT_TRUE(styleable->entries[1].privateReference); + AAPT_ASSERT_TRUE(styleable->entries[1].name); + EXPECT_EQ(std::u16string(u"android"), styleable->entries[1].name.value().package); +} + TEST_F(ResourceParserTest, ParseArray) { std::string input = "<array name=\"foo\">\n" " <item>@string/ref</item>\n" |