diff options
Diffstat (limited to 'tools/aapt2/ResourceParser_test.cpp')
-rw-r--r-- | tools/aapt2/ResourceParser_test.cpp | 193 |
1 files changed, 113 insertions, 80 deletions
diff --git a/tools/aapt2/ResourceParser_test.cpp b/tools/aapt2/ResourceParser_test.cpp index 3450de9078bb..e097740966f6 100644 --- a/tools/aapt2/ResourceParser_test.cpp +++ b/tools/aapt2/ResourceParser_test.cpp @@ -18,10 +18,9 @@ #include "ResourceTable.h" #include "ResourceUtils.h" #include "ResourceValues.h" -#include "test/Context.h" +#include "test/Test.h" #include "xml/XmlPullParser.h" -#include <gtest/gtest.h> #include <sstream> #include <string> @@ -69,18 +68,18 @@ TEST_F(ResourceParserTest, ParseQuotedString) { std::string input = "<string name=\"foo\"> \" hey there \" </string>"; ASSERT_TRUE(testParse(input)); - String* str = test::getValue<String>(&mTable, u"@string/foo"); + String* str = test::getValue<String>(&mTable, "string/foo"); ASSERT_NE(nullptr, str); - EXPECT_EQ(std::u16string(u" hey there "), *str->value); + EXPECT_EQ(std::string(" hey there "), *str->value); } TEST_F(ResourceParserTest, ParseEscapedString) { std::string input = "<string name=\"foo\">\\?123</string>"; ASSERT_TRUE(testParse(input)); - String* str = test::getValue<String>(&mTable, u"@string/foo"); + String* str = test::getValue<String>(&mTable, "string/foo"); ASSERT_NE(nullptr, str); - EXPECT_EQ(std::u16string(u"?123"), *str->value); + EXPECT_EQ(std::string("?123"), *str->value); } TEST_F(ResourceParserTest, ParseFormattedString) { @@ -91,15 +90,49 @@ TEST_F(ResourceParserTest, ParseFormattedString) { ASSERT_TRUE(testParse(input)); } +TEST_F(ResourceParserTest, ParseStyledString) { + // Use a surrogate pair unicode point so that we can verify that the span indices + // use UTF-16 length and not UTF-18 length. + std::string input = "<string name=\"foo\">This is my aunt\u2019s <b>string</b></string>"; + ASSERT_TRUE(testParse(input)); + + StyledString* str = test::getValue<StyledString>(&mTable, "string/foo"); + ASSERT_NE(nullptr, str); + + const std::string expectedStr = "This is my aunt\u2019s string"; + EXPECT_EQ(expectedStr, *str->value->str); + EXPECT_EQ(1u, str->value->spans.size()); + + EXPECT_EQ(std::string("b"), *str->value->spans[0].name); + EXPECT_EQ(17u, str->value->spans[0].firstChar); + EXPECT_EQ(23u, str->value->spans[0].lastChar); +} + +TEST_F(ResourceParserTest, ParseStringWithWhitespace) { + std::string input = "<string name=\"foo\"> This is what I think </string>"; + ASSERT_TRUE(testParse(input)); + + String* str = test::getValue<String>(&mTable, "string/foo"); + ASSERT_NE(nullptr, str); + EXPECT_EQ(std::string("This is what I think"), *str->value); + + input = "<string name=\"foo2\">\" This is what I think \"</string>"; + ASSERT_TRUE(testParse(input)); + + str = test::getValue<String>(&mTable, "string/foo2"); + ASSERT_NE(nullptr, str); + EXPECT_EQ(std::string(" This is what I think "), *str->value); +} + TEST_F(ResourceParserTest, IgnoreXliffTags) { std::string input = "<string name=\"foo\" \n" " xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n" " There are <xliff:g id=\"count\">%1$d</xliff:g> apples</string>"; ASSERT_TRUE(testParse(input)); - String* str = test::getValue<String>(&mTable, u"@string/foo"); + String* str = test::getValue<String>(&mTable, "string/foo"); ASSERT_NE(nullptr, str); - EXPECT_EQ(StringPiece16(u"There are %1$d apples"), StringPiece16(*str->value)); + EXPECT_EQ(StringPiece("There are %1$d apples"), StringPiece(*str->value)); } TEST_F(ResourceParserTest, ParseNull) { @@ -110,7 +143,7 @@ TEST_F(ResourceParserTest, ParseNull) { // a non-existing value, and this causes problems in styles when trying to resolve // an attribute. Null values must be encoded as android::Res_value::TYPE_REFERENCE // with a data value of 0. - BinaryPrimitive* integer = test::getValue<BinaryPrimitive>(&mTable, u"@integer/foo"); + BinaryPrimitive* integer = test::getValue<BinaryPrimitive>(&mTable, "integer/foo"); ASSERT_NE(nullptr, integer); EXPECT_EQ(uint16_t(android::Res_value::TYPE_REFERENCE), integer->value.dataType); EXPECT_EQ(0u, integer->value.data); @@ -120,7 +153,7 @@ TEST_F(ResourceParserTest, ParseEmpty) { std::string input = "<integer name=\"foo\">@empty</integer>"; ASSERT_TRUE(testParse(input)); - BinaryPrimitive* integer = test::getValue<BinaryPrimitive>(&mTable, u"@integer/foo"); + BinaryPrimitive* integer = test::getValue<BinaryPrimitive>(&mTable, "integer/foo"); ASSERT_NE(nullptr, integer); EXPECT_EQ(uint16_t(android::Res_value::TYPE_NULL), integer->value.dataType); EXPECT_EQ(uint32_t(android::Res_value::DATA_NULL_EMPTY), integer->value.data); @@ -131,11 +164,11 @@ TEST_F(ResourceParserTest, ParseAttr) { "<attr name=\"bar\"/>"; ASSERT_TRUE(testParse(input)); - Attribute* attr = test::getValue<Attribute>(&mTable, u"@attr/foo"); + Attribute* attr = test::getValue<Attribute>(&mTable, "attr/foo"); ASSERT_NE(nullptr, attr); EXPECT_EQ(uint32_t(android::ResTable_map::TYPE_STRING), attr->typeMask); - attr = test::getValue<Attribute>(&mTable, u"@attr/bar"); + attr = test::getValue<Attribute>(&mTable, "attr/bar"); ASSERT_NE(nullptr, attr); EXPECT_EQ(uint32_t(android::ResTable_map::TYPE_ANY), attr->typeMask); } @@ -151,20 +184,20 @@ TEST_F(ResourceParserTest, ParseAttrAndDeclareStyleableUnderConfigButRecordAsNoC </declare-styleable>)EOF"; ASSERT_TRUE(testParse(input, watchConfig)); - EXPECT_EQ(nullptr, test::getValueForConfig<Attribute>(&mTable, u"@attr/foo", watchConfig)); - EXPECT_EQ(nullptr, test::getValueForConfig<Attribute>(&mTable, u"@attr/baz", watchConfig)); - EXPECT_EQ(nullptr, test::getValueForConfig<Styleable>(&mTable, u"@styleable/bar", watchConfig)); + EXPECT_EQ(nullptr, test::getValueForConfig<Attribute>(&mTable, "attr/foo", watchConfig)); + EXPECT_EQ(nullptr, test::getValueForConfig<Attribute>(&mTable, "attr/baz", watchConfig)); + EXPECT_EQ(nullptr, test::getValueForConfig<Styleable>(&mTable, "styleable/bar", watchConfig)); - EXPECT_NE(nullptr, test::getValue<Attribute>(&mTable, u"@attr/foo")); - EXPECT_NE(nullptr, test::getValue<Attribute>(&mTable, u"@attr/baz")); - EXPECT_NE(nullptr, test::getValue<Styleable>(&mTable, u"@styleable/bar")); + EXPECT_NE(nullptr, test::getValue<Attribute>(&mTable, "attr/foo")); + EXPECT_NE(nullptr, test::getValue<Attribute>(&mTable, "attr/baz")); + EXPECT_NE(nullptr, test::getValue<Styleable>(&mTable, "styleable/bar")); } TEST_F(ResourceParserTest, ParseAttrWithMinMax) { std::string input = "<attr name=\"foo\" min=\"10\" max=\"23\" format=\"integer\"/>"; ASSERT_TRUE(testParse(input)); - Attribute* attr = test::getValue<Attribute>(&mTable, u"@attr/foo"); + Attribute* attr = test::getValue<Attribute>(&mTable, "attr/foo"); ASSERT_NE(nullptr, attr); EXPECT_EQ(uint32_t(android::ResTable_map::TYPE_INTEGER), attr->typeMask); EXPECT_EQ(10, attr->minInt); @@ -183,7 +216,7 @@ TEST_F(ResourceParserTest, ParseUseAndDeclOfAttr) { "<attr name=\"foo\" format=\"string\"/>"; ASSERT_TRUE(testParse(input)); - Attribute* attr = test::getValue<Attribute>(&mTable, u"@attr/foo"); + Attribute* attr = test::getValue<Attribute>(&mTable, "attr/foo"); ASSERT_NE(nullptr, attr); EXPECT_EQ(uint32_t(android::ResTable_map::TYPE_STRING), attr->typeMask); } @@ -197,7 +230,7 @@ TEST_F(ResourceParserTest, ParseDoubleUseOfAttr) { "</declare-styleable>"; ASSERT_TRUE(testParse(input)); - Attribute* attr = test::getValue<Attribute>(&mTable, u"@attr/foo"); + Attribute* attr = test::getValue<Attribute>(&mTable, "attr/foo"); ASSERT_NE(nullptr, attr); EXPECT_EQ(uint32_t(android::ResTable_map::TYPE_BOOLEAN), attr->typeMask); } @@ -210,21 +243,21 @@ TEST_F(ResourceParserTest, ParseEnumAttr) { "</attr>"; ASSERT_TRUE(testParse(input)); - Attribute* enumAttr = test::getValue<Attribute>(&mTable, u"@attr/foo"); + Attribute* enumAttr = test::getValue<Attribute>(&mTable, "attr/foo"); ASSERT_NE(enumAttr, nullptr); EXPECT_EQ(enumAttr->typeMask, android::ResTable_map::TYPE_ENUM); ASSERT_EQ(enumAttr->symbols.size(), 3u); AAPT_ASSERT_TRUE(enumAttr->symbols[0].symbol.name); - EXPECT_EQ(enumAttr->symbols[0].symbol.name.value().entry, u"bar"); + EXPECT_EQ(enumAttr->symbols[0].symbol.name.value().entry, "bar"); EXPECT_EQ(enumAttr->symbols[0].value, 0u); AAPT_ASSERT_TRUE(enumAttr->symbols[1].symbol.name); - EXPECT_EQ(enumAttr->symbols[1].symbol.name.value().entry, u"bat"); + EXPECT_EQ(enumAttr->symbols[1].symbol.name.value().entry, "bat"); EXPECT_EQ(enumAttr->symbols[1].value, 1u); AAPT_ASSERT_TRUE(enumAttr->symbols[2].symbol.name); - EXPECT_EQ(enumAttr->symbols[2].symbol.name.value().entry, u"baz"); + EXPECT_EQ(enumAttr->symbols[2].symbol.name.value().entry, "baz"); EXPECT_EQ(enumAttr->symbols[2].value, 2u); } @@ -236,25 +269,25 @@ TEST_F(ResourceParserTest, ParseFlagAttr) { "</attr>"; ASSERT_TRUE(testParse(input)); - Attribute* flagAttr = test::getValue<Attribute>(&mTable, u"@attr/foo"); + Attribute* flagAttr = test::getValue<Attribute>(&mTable, "attr/foo"); ASSERT_NE(nullptr, flagAttr); EXPECT_EQ(flagAttr->typeMask, android::ResTable_map::TYPE_FLAGS); ASSERT_EQ(flagAttr->symbols.size(), 3u); AAPT_ASSERT_TRUE(flagAttr->symbols[0].symbol.name); - EXPECT_EQ(flagAttr->symbols[0].symbol.name.value().entry, u"bar"); + EXPECT_EQ(flagAttr->symbols[0].symbol.name.value().entry, "bar"); EXPECT_EQ(flagAttr->symbols[0].value, 0u); AAPT_ASSERT_TRUE(flagAttr->symbols[1].symbol.name); - EXPECT_EQ(flagAttr->symbols[1].symbol.name.value().entry, u"bat"); + EXPECT_EQ(flagAttr->symbols[1].symbol.name.value().entry, "bat"); EXPECT_EQ(flagAttr->symbols[1].value, 1u); AAPT_ASSERT_TRUE(flagAttr->symbols[2].symbol.name); - EXPECT_EQ(flagAttr->symbols[2].symbol.name.value().entry, u"baz"); + EXPECT_EQ(flagAttr->symbols[2].symbol.name.value().entry, "baz"); EXPECT_EQ(flagAttr->symbols[2].value, 2u); std::unique_ptr<BinaryPrimitive> flagValue = ResourceUtils::tryParseFlagSymbol(flagAttr, - u"baz|bat"); + "baz|bat"); ASSERT_NE(nullptr, flagValue); EXPECT_EQ(flagValue->value.data, 1u | 2u); } @@ -276,32 +309,32 @@ TEST_F(ResourceParserTest, ParseStyle) { "</style>"; ASSERT_TRUE(testParse(input)); - Style* style = test::getValue<Style>(&mTable, u"@style/foo"); + Style* style = test::getValue<Style>(&mTable, "style/foo"); ASSERT_NE(nullptr, style); AAPT_ASSERT_TRUE(style->parent); AAPT_ASSERT_TRUE(style->parent.value().name); - EXPECT_EQ(test::parseNameOrDie(u"@style/fu"), style->parent.value().name.value()); + EXPECT_EQ(test::parseNameOrDie("style/fu"), style->parent.value().name.value()); ASSERT_EQ(3u, style->entries.size()); AAPT_ASSERT_TRUE(style->entries[0].key.name); - EXPECT_EQ(test::parseNameOrDie(u"@attr/bar"), style->entries[0].key.name.value()); + EXPECT_EQ(test::parseNameOrDie("attr/bar"), style->entries[0].key.name.value()); AAPT_ASSERT_TRUE(style->entries[1].key.name); - EXPECT_EQ(test::parseNameOrDie(u"@attr/bat"), style->entries[1].key.name.value()); + EXPECT_EQ(test::parseNameOrDie("attr/bat"), style->entries[1].key.name.value()); AAPT_ASSERT_TRUE(style->entries[2].key.name); - EXPECT_EQ(test::parseNameOrDie(u"@attr/baz"), style->entries[2].key.name.value()); + EXPECT_EQ(test::parseNameOrDie("attr/baz"), style->entries[2].key.name.value()); } TEST_F(ResourceParserTest, ParseStyleWithShorthandParent) { std::string input = "<style name=\"foo\" parent=\"com.app:Theme\"/>"; ASSERT_TRUE(testParse(input)); - Style* style = test::getValue<Style>(&mTable, u"@style/foo"); + Style* style = test::getValue<Style>(&mTable, "style/foo"); ASSERT_NE(nullptr, style); AAPT_ASSERT_TRUE(style->parent); AAPT_ASSERT_TRUE(style->parent.value().name); - EXPECT_EQ(test::parseNameOrDie(u"@com.app:style/Theme"), style->parent.value().name.value()); + EXPECT_EQ(test::parseNameOrDie("com.app:style/Theme"), style->parent.value().name.value()); } TEST_F(ResourceParserTest, ParseStyleWithPackageAliasedParent) { @@ -309,11 +342,11 @@ TEST_F(ResourceParserTest, ParseStyleWithPackageAliasedParent) { " name=\"foo\" parent=\"app:Theme\"/>"; ASSERT_TRUE(testParse(input)); - Style* style = test::getValue<Style>(&mTable, u"@style/foo"); + Style* style = test::getValue<Style>(&mTable, "style/foo"); ASSERT_NE(nullptr, style); AAPT_ASSERT_TRUE(style->parent); AAPT_ASSERT_TRUE(style->parent.value().name); - EXPECT_EQ(test::parseNameOrDie(u"@android:style/Theme"), style->parent.value().name.value()); + EXPECT_EQ(test::parseNameOrDie("android:style/Theme"), style->parent.value().name.value()); } TEST_F(ResourceParserTest, ParseStyleWithPackageAliasedItems) { @@ -323,21 +356,21 @@ TEST_F(ResourceParserTest, ParseStyleWithPackageAliasedItems) { "</style>"; ASSERT_TRUE(testParse(input)); - Style* style = test::getValue<Style>(&mTable, u"@style/foo"); + Style* style = test::getValue<Style>(&mTable, "style/foo"); ASSERT_NE(nullptr, style); ASSERT_EQ(1u, style->entries.size()); - EXPECT_EQ(test::parseNameOrDie(u"@android:attr/bar"), style->entries[0].key.name.value()); + EXPECT_EQ(test::parseNameOrDie("android:attr/bar"), style->entries[0].key.name.value()); } TEST_F(ResourceParserTest, ParseStyleWithInferredParent) { std::string input = "<style name=\"foo.bar\"/>"; ASSERT_TRUE(testParse(input)); - Style* style = test::getValue<Style>(&mTable, u"@style/foo.bar"); + Style* style = test::getValue<Style>(&mTable, "style/foo.bar"); ASSERT_NE(nullptr, style); AAPT_ASSERT_TRUE(style->parent); AAPT_ASSERT_TRUE(style->parent.value().name); - EXPECT_EQ(style->parent.value().name.value(), test::parseNameOrDie(u"@style/foo")); + EXPECT_EQ(style->parent.value().name.value(), test::parseNameOrDie("style/foo")); EXPECT_TRUE(style->parentInferred); } @@ -345,7 +378,7 @@ TEST_F(ResourceParserTest, ParseStyleWithInferredParentOverridenByEmptyParentAtt std::string input = "<style name=\"foo.bar\" parent=\"\"/>"; ASSERT_TRUE(testParse(input)); - Style* style = test::getValue<Style>(&mTable, u"@style/foo.bar"); + Style* style = test::getValue<Style>(&mTable, "style/foo.bar"); ASSERT_NE(nullptr, style); AAPT_EXPECT_FALSE(style->parent); EXPECT_FALSE(style->parentInferred); @@ -355,7 +388,7 @@ TEST_F(ResourceParserTest, ParseStyleWithPrivateParentReference) { std::string input = R"EOF(<style name="foo" parent="*android:style/bar" />)EOF"; ASSERT_TRUE(testParse(input)); - Style* style = test::getValue<Style>(&mTable, u"@style/foo"); + Style* style = test::getValue<Style>(&mTable, "style/foo"); ASSERT_NE(nullptr, style); AAPT_ASSERT_TRUE(style->parent); EXPECT_TRUE(style->parent.value().privateReference); @@ -365,7 +398,7 @@ TEST_F(ResourceParserTest, ParseAutoGeneratedIdReference) { std::string input = "<string name=\"foo\">@+id/bar</string>"; ASSERT_TRUE(testParse(input)); - Id* id = test::getValue<Id>(&mTable, u"@id/bar"); + Id* id = test::getValue<Id>(&mTable, "id/bar"); ASSERT_NE(id, nullptr); } @@ -380,31 +413,31 @@ TEST_F(ResourceParserTest, ParseAttributesDeclareStyleable) { ASSERT_TRUE(testParse(input)); Maybe<ResourceTable::SearchResult> result = - mTable.findResource(test::parseNameOrDie(u"@styleable/foo")); + mTable.findResource(test::parseNameOrDie("styleable/foo")); AAPT_ASSERT_TRUE(result); EXPECT_EQ(SymbolState::kPublic, result.value().entry->symbolStatus.state); - Attribute* attr = test::getValue<Attribute>(&mTable, u"@attr/bar"); + Attribute* attr = test::getValue<Attribute>(&mTable, "attr/bar"); ASSERT_NE(attr, nullptr); EXPECT_TRUE(attr->isWeak()); - attr = test::getValue<Attribute>(&mTable, u"@attr/bat"); + attr = test::getValue<Attribute>(&mTable, "attr/bat"); ASSERT_NE(attr, nullptr); EXPECT_TRUE(attr->isWeak()); - attr = test::getValue<Attribute>(&mTable, u"@attr/baz"); + attr = test::getValue<Attribute>(&mTable, "attr/baz"); ASSERT_NE(attr, nullptr); EXPECT_TRUE(attr->isWeak()); EXPECT_EQ(1u, attr->symbols.size()); - EXPECT_NE(nullptr, test::getValue<Id>(&mTable, u"@id/foo")); + EXPECT_NE(nullptr, test::getValue<Id>(&mTable, "id/foo")); - Styleable* styleable = test::getValue<Styleable>(&mTable, u"@styleable/foo"); + Styleable* styleable = test::getValue<Styleable>(&mTable, "styleable/foo"); ASSERT_NE(styleable, nullptr); ASSERT_EQ(3u, styleable->entries.size()); - EXPECT_EQ(test::parseNameOrDie(u"@attr/bar"), styleable->entries[0].name.value()); - EXPECT_EQ(test::parseNameOrDie(u"@attr/bat"), styleable->entries[1].name.value()); + EXPECT_EQ(test::parseNameOrDie("attr/bar"), styleable->entries[0].name.value()); + EXPECT_EQ(test::parseNameOrDie("attr/bat"), styleable->entries[1].name.value()); } TEST_F(ResourceParserTest, ParsePrivateAttributesDeclareStyleable) { @@ -413,17 +446,17 @@ TEST_F(ResourceParserTest, ParsePrivateAttributesDeclareStyleable) { " <attr name=\"privAndroid:bat\" />\n" "</declare-styleable>"; ASSERT_TRUE(testParse(input)); - Styleable* styleable = test::getValue<Styleable>(&mTable, u"@styleable/foo"); + Styleable* styleable = test::getValue<Styleable>(&mTable, "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_EQ(std::string("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); + EXPECT_EQ(std::string("android"), styleable->entries[1].name.value().package); } TEST_F(ResourceParserTest, ParseArray) { @@ -434,7 +467,7 @@ TEST_F(ResourceParserTest, ParseArray) { "</array>"; ASSERT_TRUE(testParse(input)); - Array* array = test::getValue<Array>(&mTable, u"@array/foo"); + Array* array = test::getValue<Array>(&mTable, "array/foo"); ASSERT_NE(array, nullptr); ASSERT_EQ(3u, array->items.size()); @@ -448,7 +481,7 @@ TEST_F(ResourceParserTest, ParseStringArray) { " <item>\"Werk\"</item>\n" "</string-array>\n"; ASSERT_TRUE(testParse(input)); - EXPECT_NE(nullptr, test::getValue<Array>(&mTable, u"@array/foo")); + EXPECT_NE(nullptr, test::getValue<Array>(&mTable, "array/foo")); } TEST_F(ResourceParserTest, ParsePlural) { @@ -464,9 +497,9 @@ TEST_F(ResourceParserTest, ParseCommentsWithResource) { "<string name=\"foo\">Hi</string>"; ASSERT_TRUE(testParse(input)); - String* value = test::getValue<String>(&mTable, u"@string/foo"); + String* value = test::getValue<String>(&mTable, "string/foo"); ASSERT_NE(nullptr, value); - EXPECT_EQ(value->getComment(), u"This is a comment"); + EXPECT_EQ(value->getComment(), "This is a comment"); } TEST_F(ResourceParserTest, DoNotCombineMultipleComments) { @@ -476,9 +509,9 @@ TEST_F(ResourceParserTest, DoNotCombineMultipleComments) { ASSERT_TRUE(testParse(input)); - String* value = test::getValue<String>(&mTable, u"@string/foo"); + String* value = test::getValue<String>(&mTable, "string/foo"); ASSERT_NE(nullptr, value); - EXPECT_EQ(value->getComment(), u"Two"); + EXPECT_EQ(value->getComment(), "Two"); } TEST_F(ResourceParserTest, IgnoreCommentBeforeEndTag) { @@ -490,9 +523,9 @@ TEST_F(ResourceParserTest, IgnoreCommentBeforeEndTag) { ASSERT_TRUE(testParse(input)); - String* value = test::getValue<String>(&mTable, u"@string/foo"); + String* value = test::getValue<String>(&mTable, "string/foo"); ASSERT_NE(nullptr, value); - EXPECT_EQ(value->getComment(), u"One"); + EXPECT_EQ(value->getComment(), "One"); } TEST_F(ResourceParserTest, ParseNestedComments) { @@ -510,17 +543,17 @@ TEST_F(ResourceParserTest, ParseNestedComments) { </attr>)EOF"; ASSERT_TRUE(testParse(input)); - Styleable* styleable = test::getValue<Styleable>(&mTable, u"@styleable/foo"); + Styleable* styleable = test::getValue<Styleable>(&mTable, "styleable/foo"); ASSERT_NE(nullptr, styleable); ASSERT_EQ(1u, styleable->entries.size()); - EXPECT_EQ(StringPiece16(u"The name of the bar"), styleable->entries.front().getComment()); + EXPECT_EQ(StringPiece("The name of the bar"), styleable->entries.front().getComment()); - Attribute* attr = test::getValue<Attribute>(&mTable, u"@attr/foo"); + Attribute* attr = test::getValue<Attribute>(&mTable, "attr/foo"); ASSERT_NE(nullptr, attr); ASSERT_EQ(1u, attr->symbols.size()); - EXPECT_EQ(StringPiece16(u"The very first"), attr->symbols.front().symbol.getComment()); + EXPECT_EQ(StringPiece("The very first"), attr->symbols.front().symbol.getComment()); } /* @@ -531,7 +564,7 @@ TEST_F(ResourceParserTest, ParsePublicIdAsDefinition) { std::string input = "<public type=\"id\" name=\"foo\"/>"; ASSERT_TRUE(testParse(input)); - Id* id = test::getValue<Id>(&mTable, u"@id/foo"); + Id* id = test::getValue<Id>(&mTable, "id/foo"); ASSERT_NE(nullptr, id); } @@ -546,22 +579,22 @@ TEST_F(ResourceParserTest, KeepAllProducts) { )EOF"; ASSERT_TRUE(testParse(input)); - EXPECT_NE(nullptr, test::getValueForConfigAndProduct<String>(&mTable, u"@string/foo", + EXPECT_NE(nullptr, test::getValueForConfigAndProduct<String>(&mTable, "string/foo", ConfigDescription::defaultConfig(), "phone")); - EXPECT_NE(nullptr, test::getValueForConfigAndProduct<String>(&mTable, u"@string/foo", + EXPECT_NE(nullptr, test::getValueForConfigAndProduct<String>(&mTable, "string/foo", ConfigDescription::defaultConfig(), "no-sdcard")); - EXPECT_NE(nullptr, test::getValueForConfigAndProduct<String>(&mTable, u"@string/bar", + EXPECT_NE(nullptr, test::getValueForConfigAndProduct<String>(&mTable, "string/bar", ConfigDescription::defaultConfig(), "")); - EXPECT_NE(nullptr, test::getValueForConfigAndProduct<String>(&mTable, u"@string/baz", + EXPECT_NE(nullptr, test::getValueForConfigAndProduct<String>(&mTable, "string/baz", ConfigDescription::defaultConfig(), "")); - EXPECT_NE(nullptr, test::getValueForConfigAndProduct<String>(&mTable, u"@string/bit", + EXPECT_NE(nullptr, test::getValueForConfigAndProduct<String>(&mTable, "string/bit", ConfigDescription::defaultConfig(), "phablet")); - EXPECT_NE(nullptr, test::getValueForConfigAndProduct<String>(&mTable, u"@string/bot", + EXPECT_NE(nullptr, test::getValueForConfigAndProduct<String>(&mTable, "string/bot", ConfigDescription::defaultConfig(), "default")); } @@ -575,7 +608,7 @@ TEST_F(ResourceParserTest, AutoIncrementIdsInPublicGroup) { ASSERT_TRUE(testParse(input)); Maybe<ResourceTable::SearchResult> result = mTable.findResource( - test::parseNameOrDie(u"@attr/foo")); + test::parseNameOrDie("attr/foo")); AAPT_ASSERT_TRUE(result); AAPT_ASSERT_TRUE(result.value().package->id); @@ -586,7 +619,7 @@ TEST_F(ResourceParserTest, AutoIncrementIdsInPublicGroup) { result.value().entry->id.value()); EXPECT_EQ(ResourceId(0x01010040), actualId); - result = mTable.findResource(test::parseNameOrDie(u"@attr/bar")); + result = mTable.findResource(test::parseNameOrDie("attr/bar")); AAPT_ASSERT_TRUE(result); AAPT_ASSERT_TRUE(result.value().package->id); @@ -611,7 +644,7 @@ TEST_F(ResourceParserTest, AddResourcesElementShouldAddEntryWithUndefinedSymbol) ASSERT_TRUE(testParse(input)); Maybe<ResourceTable::SearchResult> result = mTable.findResource( - test::parseNameOrDie(u"@string/bar")); + test::parseNameOrDie("string/bar")); AAPT_ASSERT_TRUE(result); const ResourceEntry* entry = result.value().entry; ASSERT_NE(nullptr, entry); @@ -622,7 +655,7 @@ TEST_F(ResourceParserTest, ParseItemElementWithFormat) { std::string input = R"EOF(<item name="foo" type="integer" format="float">0.3</item>)EOF"; ASSERT_TRUE(testParse(input)); - BinaryPrimitive* val = test::getValue<BinaryPrimitive>(&mTable, u"@integer/foo"); + BinaryPrimitive* val = test::getValue<BinaryPrimitive>(&mTable, "integer/foo"); ASSERT_NE(nullptr, val); EXPECT_EQ(uint32_t(android::Res_value::TYPE_FLOAT), val->value.dataType); |