Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "ResourceParser.h" |
| 18 | #include "ResourceTable.h" |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 19 | #include "ResourceUtils.h" |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 20 | #include "ResourceValues.h" |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 21 | #include "test/Context.h" |
Adam Lesinski | 467f171 | 2015-11-16 17:35:44 -0800 | [diff] [blame] | 22 | #include "xml/XmlPullParser.h" |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 23 | |
| 24 | #include <gtest/gtest.h> |
| 25 | #include <sstream> |
| 26 | #include <string> |
| 27 | |
| 28 | namespace aapt { |
| 29 | |
| 30 | constexpr const char* kXmlPreamble = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; |
| 31 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 32 | TEST(ResourceParserSingleTest, FailToParseWithNoRootResourcesElement) { |
| 33 | std::unique_ptr<IAaptContext> context = test::ContextBuilder().build(); |
| 34 | std::stringstream input(kXmlPreamble); |
| 35 | input << "<attr name=\"foo\"/>" << std::endl; |
| 36 | ResourceTable table; |
| 37 | ResourceParser parser(context->getDiagnostics(), &table, Source{ "test" }, {}); |
Adam Lesinski | 467f171 | 2015-11-16 17:35:44 -0800 | [diff] [blame] | 38 | xml::XmlPullParser xmlParser(input); |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 39 | ASSERT_FALSE(parser.parse(&xmlParser)); |
Adam Lesinski | 769de98 | 2015-04-10 19:43:55 -0700 | [diff] [blame] | 40 | } |
| 41 | |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 42 | struct ResourceParserTest : public ::testing::Test { |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 43 | ResourceTable mTable; |
| 44 | std::unique_ptr<IAaptContext> mContext; |
| 45 | |
| 46 | void SetUp() override { |
| 47 | mContext = test::ContextBuilder().build(); |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 48 | } |
| 49 | |
Adam Lesinski | 9ba47d8 | 2015-10-13 11:37:10 -0700 | [diff] [blame] | 50 | ::testing::AssertionResult testParse(const StringPiece& str, |
| 51 | Maybe<std::u16string> product = {}) { |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 52 | std::stringstream input(kXmlPreamble); |
Adam Lesinski | 24aad16 | 2015-04-24 19:19:30 -0700 | [diff] [blame] | 53 | input << "<resources>\n" << str << "\n</resources>" << std::endl; |
Adam Lesinski | 9f22204 | 2015-11-04 13:51:45 -0800 | [diff] [blame] | 54 | ResourceParserOptions parserOptions; |
| 55 | parserOptions.product = product; |
Adam Lesinski | 9ba47d8 | 2015-10-13 11:37:10 -0700 | [diff] [blame] | 56 | ResourceParser parser(mContext->getDiagnostics(), &mTable, Source{ "test" }, {}, |
Adam Lesinski | 9f22204 | 2015-11-04 13:51:45 -0800 | [diff] [blame] | 57 | parserOptions); |
Adam Lesinski | 467f171 | 2015-11-16 17:35:44 -0800 | [diff] [blame] | 58 | xml::XmlPullParser xmlParser(input); |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 59 | if (parser.parse(&xmlParser)) { |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 60 | return ::testing::AssertionSuccess(); |
| 61 | } |
| 62 | return ::testing::AssertionFailure(); |
| 63 | } |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 64 | }; |
| 65 | |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 66 | TEST_F(ResourceParserTest, ParseQuotedString) { |
Adam Lesinski | 24aad16 | 2015-04-24 19:19:30 -0700 | [diff] [blame] | 67 | std::string input = "<string name=\"foo\"> \" hey there \" </string>"; |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 68 | ASSERT_TRUE(testParse(input)); |
| 69 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 70 | String* str = test::getValue<String>(&mTable, u"@string/foo"); |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 71 | ASSERT_NE(nullptr, str); |
| 72 | EXPECT_EQ(std::u16string(u" hey there "), *str->value); |
| 73 | } |
| 74 | |
| 75 | TEST_F(ResourceParserTest, ParseEscapedString) { |
Adam Lesinski | 24aad16 | 2015-04-24 19:19:30 -0700 | [diff] [blame] | 76 | std::string input = "<string name=\"foo\">\\?123</string>"; |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 77 | ASSERT_TRUE(testParse(input)); |
| 78 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 79 | String* str = test::getValue<String>(&mTable, u"@string/foo"); |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 80 | ASSERT_NE(nullptr, str); |
| 81 | EXPECT_EQ(std::u16string(u"?123"), *str->value); |
| 82 | } |
| 83 | |
Adam Lesinski | 9f22204 | 2015-11-04 13:51:45 -0800 | [diff] [blame] | 84 | TEST_F(ResourceParserTest, ParseFormattedString) { |
| 85 | std::string input = "<string name=\"foo\">%d %s</string>"; |
| 86 | ASSERT_FALSE(testParse(input)); |
| 87 | |
| 88 | input = "<string name=\"foo\">%1$d %2$s</string>"; |
| 89 | ASSERT_TRUE(testParse(input)); |
| 90 | } |
| 91 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 92 | TEST_F(ResourceParserTest, IgnoreXliffTags) { |
| 93 | std::string input = "<string name=\"foo\" \n" |
| 94 | " xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n" |
| 95 | " There are <xliff:g id=\"count\">%1$d</xliff:g> apples</string>"; |
| 96 | ASSERT_TRUE(testParse(input)); |
| 97 | |
| 98 | String* str = test::getValue<String>(&mTable, u"@string/foo"); |
| 99 | ASSERT_NE(nullptr, str); |
| 100 | EXPECT_EQ(StringPiece16(u"There are %1$d apples"), StringPiece16(*str->value)); |
| 101 | } |
| 102 | |
Adam Lesinski | dfa5e07 | 2015-05-12 21:42:59 -0700 | [diff] [blame] | 103 | TEST_F(ResourceParserTest, ParseNull) { |
| 104 | std::string input = "<integer name=\"foo\">@null</integer>"; |
| 105 | ASSERT_TRUE(testParse(input)); |
| 106 | |
| 107 | // The Android runtime treats a value of android::Res_value::TYPE_NULL as |
| 108 | // a non-existing value, and this causes problems in styles when trying to resolve |
| 109 | // an attribute. Null values must be encoded as android::Res_value::TYPE_REFERENCE |
| 110 | // with a data value of 0. |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 111 | BinaryPrimitive* integer = test::getValue<BinaryPrimitive>(&mTable, u"@integer/foo"); |
Adam Lesinski | dfa5e07 | 2015-05-12 21:42:59 -0700 | [diff] [blame] | 112 | ASSERT_NE(nullptr, integer); |
| 113 | EXPECT_EQ(uint16_t(android::Res_value::TYPE_REFERENCE), integer->value.dataType); |
| 114 | EXPECT_EQ(0u, integer->value.data); |
| 115 | } |
| 116 | |
| 117 | TEST_F(ResourceParserTest, ParseEmpty) { |
| 118 | std::string input = "<integer name=\"foo\">@empty</integer>"; |
| 119 | ASSERT_TRUE(testParse(input)); |
| 120 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 121 | BinaryPrimitive* integer = test::getValue<BinaryPrimitive>(&mTable, u"@integer/foo"); |
Adam Lesinski | dfa5e07 | 2015-05-12 21:42:59 -0700 | [diff] [blame] | 122 | ASSERT_NE(nullptr, integer); |
| 123 | EXPECT_EQ(uint16_t(android::Res_value::TYPE_NULL), integer->value.dataType); |
| 124 | EXPECT_EQ(uint32_t(android::Res_value::DATA_NULL_EMPTY), integer->value.data); |
| 125 | } |
| 126 | |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 127 | TEST_F(ResourceParserTest, ParseAttr) { |
Adam Lesinski | 24aad16 | 2015-04-24 19:19:30 -0700 | [diff] [blame] | 128 | std::string input = "<attr name=\"foo\" format=\"string\"/>\n" |
| 129 | "<attr name=\"bar\"/>"; |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 130 | ASSERT_TRUE(testParse(input)); |
| 131 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 132 | Attribute* attr = test::getValue<Attribute>(&mTable, u"@attr/foo"); |
| 133 | ASSERT_NE(nullptr, attr); |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 134 | EXPECT_EQ(uint32_t(android::ResTable_map::TYPE_STRING), attr->typeMask); |
| 135 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 136 | attr = test::getValue<Attribute>(&mTable, u"@attr/bar"); |
| 137 | ASSERT_NE(nullptr, attr); |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 138 | EXPECT_EQ(uint32_t(android::ResTable_map::TYPE_ANY), attr->typeMask); |
| 139 | } |
| 140 | |
| 141 | TEST_F(ResourceParserTest, ParseUseAndDeclOfAttr) { |
Adam Lesinski | 24aad16 | 2015-04-24 19:19:30 -0700 | [diff] [blame] | 142 | std::string input = "<declare-styleable name=\"Styleable\">\n" |
| 143 | " <attr name=\"foo\" />\n" |
| 144 | "</declare-styleable>\n" |
| 145 | "<attr name=\"foo\" format=\"string\"/>"; |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 146 | ASSERT_TRUE(testParse(input)); |
| 147 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 148 | Attribute* attr = test::getValue<Attribute>(&mTable, u"@attr/foo"); |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 149 | ASSERT_NE(nullptr, attr); |
| 150 | EXPECT_EQ(uint32_t(android::ResTable_map::TYPE_STRING), attr->typeMask); |
| 151 | } |
| 152 | |
| 153 | TEST_F(ResourceParserTest, ParseDoubleUseOfAttr) { |
Adam Lesinski | 24aad16 | 2015-04-24 19:19:30 -0700 | [diff] [blame] | 154 | std::string input = "<declare-styleable name=\"Theme\">" |
| 155 | " <attr name=\"foo\" />\n" |
| 156 | "</declare-styleable>\n" |
| 157 | "<declare-styleable name=\"Window\">\n" |
| 158 | " <attr name=\"foo\" format=\"boolean\"/>\n" |
| 159 | "</declare-styleable>"; |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 160 | ASSERT_TRUE(testParse(input)); |
| 161 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 162 | Attribute* attr = test::getValue<Attribute>(&mTable, u"@attr/foo"); |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 163 | ASSERT_NE(nullptr, attr); |
| 164 | EXPECT_EQ(uint32_t(android::ResTable_map::TYPE_BOOLEAN), attr->typeMask); |
| 165 | } |
| 166 | |
| 167 | TEST_F(ResourceParserTest, ParseEnumAttr) { |
Adam Lesinski | 24aad16 | 2015-04-24 19:19:30 -0700 | [diff] [blame] | 168 | std::string input = "<attr name=\"foo\">\n" |
| 169 | " <enum name=\"bar\" value=\"0\"/>\n" |
| 170 | " <enum name=\"bat\" value=\"1\"/>\n" |
| 171 | " <enum name=\"baz\" value=\"2\"/>\n" |
| 172 | "</attr>"; |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 173 | ASSERT_TRUE(testParse(input)); |
| 174 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 175 | Attribute* enumAttr = test::getValue<Attribute>(&mTable, u"@attr/foo"); |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 176 | ASSERT_NE(enumAttr, nullptr); |
| 177 | EXPECT_EQ(enumAttr->typeMask, android::ResTable_map::TYPE_ENUM); |
| 178 | ASSERT_EQ(enumAttr->symbols.size(), 3u); |
| 179 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 180 | AAPT_ASSERT_TRUE(enumAttr->symbols[0].symbol.name); |
| 181 | EXPECT_EQ(enumAttr->symbols[0].symbol.name.value().entry, u"bar"); |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 182 | EXPECT_EQ(enumAttr->symbols[0].value, 0u); |
| 183 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 184 | AAPT_ASSERT_TRUE(enumAttr->symbols[1].symbol.name); |
| 185 | EXPECT_EQ(enumAttr->symbols[1].symbol.name.value().entry, u"bat"); |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 186 | EXPECT_EQ(enumAttr->symbols[1].value, 1u); |
| 187 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 188 | AAPT_ASSERT_TRUE(enumAttr->symbols[2].symbol.name); |
| 189 | EXPECT_EQ(enumAttr->symbols[2].symbol.name.value().entry, u"baz"); |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 190 | EXPECT_EQ(enumAttr->symbols[2].value, 2u); |
| 191 | } |
| 192 | |
| 193 | TEST_F(ResourceParserTest, ParseFlagAttr) { |
Adam Lesinski | 24aad16 | 2015-04-24 19:19:30 -0700 | [diff] [blame] | 194 | std::string input = "<attr name=\"foo\">\n" |
| 195 | " <flag name=\"bar\" value=\"0\"/>\n" |
| 196 | " <flag name=\"bat\" value=\"1\"/>\n" |
| 197 | " <flag name=\"baz\" value=\"2\"/>\n" |
| 198 | "</attr>"; |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 199 | ASSERT_TRUE(testParse(input)); |
| 200 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 201 | Attribute* flagAttr = test::getValue<Attribute>(&mTable, u"@attr/foo"); |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 202 | ASSERT_NE(flagAttr, nullptr); |
| 203 | EXPECT_EQ(flagAttr->typeMask, android::ResTable_map::TYPE_FLAGS); |
| 204 | ASSERT_EQ(flagAttr->symbols.size(), 3u); |
| 205 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 206 | AAPT_ASSERT_TRUE(flagAttr->symbols[0].symbol.name); |
| 207 | EXPECT_EQ(flagAttr->symbols[0].symbol.name.value().entry, u"bar"); |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 208 | EXPECT_EQ(flagAttr->symbols[0].value, 0u); |
| 209 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 210 | AAPT_ASSERT_TRUE(flagAttr->symbols[1].symbol.name); |
| 211 | EXPECT_EQ(flagAttr->symbols[1].symbol.name.value().entry, u"bat"); |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 212 | EXPECT_EQ(flagAttr->symbols[1].value, 1u); |
| 213 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 214 | AAPT_ASSERT_TRUE(flagAttr->symbols[2].symbol.name); |
| 215 | EXPECT_EQ(flagAttr->symbols[2].symbol.name.value().entry, u"baz"); |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 216 | EXPECT_EQ(flagAttr->symbols[2].value, 2u); |
| 217 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 218 | std::unique_ptr<BinaryPrimitive> flagValue = ResourceUtils::tryParseFlagSymbol(flagAttr, |
| 219 | u"baz|bat"); |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 220 | ASSERT_NE(flagValue, nullptr); |
| 221 | EXPECT_EQ(flagValue->value.data, 1u | 2u); |
| 222 | } |
| 223 | |
| 224 | TEST_F(ResourceParserTest, FailToParseEnumAttrWithNonUniqueKeys) { |
Adam Lesinski | 24aad16 | 2015-04-24 19:19:30 -0700 | [diff] [blame] | 225 | std::string input = "<attr name=\"foo\">\n" |
| 226 | " <enum name=\"bar\" value=\"0\"/>\n" |
| 227 | " <enum name=\"bat\" value=\"1\"/>\n" |
| 228 | " <enum name=\"bat\" value=\"2\"/>\n" |
| 229 | "</attr>"; |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 230 | ASSERT_FALSE(testParse(input)); |
| 231 | } |
| 232 | |
| 233 | TEST_F(ResourceParserTest, ParseStyle) { |
Adam Lesinski | 24aad16 | 2015-04-24 19:19:30 -0700 | [diff] [blame] | 234 | std::string input = "<style name=\"foo\" parent=\"@style/fu\">\n" |
| 235 | " <item name=\"bar\">#ffffffff</item>\n" |
| 236 | " <item name=\"bat\">@string/hey</item>\n" |
| 237 | " <item name=\"baz\"><b>hey</b></item>\n" |
| 238 | "</style>"; |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 239 | ASSERT_TRUE(testParse(input)); |
| 240 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 241 | Style* style = test::getValue<Style>(&mTable, u"@style/foo"); |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 242 | ASSERT_NE(style, nullptr); |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 243 | AAPT_ASSERT_TRUE(style->parent); |
| 244 | AAPT_ASSERT_TRUE(style->parent.value().name); |
| 245 | EXPECT_EQ(test::parseNameOrDie(u"@style/fu"), style->parent.value().name.value()); |
| 246 | ASSERT_EQ(3u, style->entries.size()); |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 247 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 248 | AAPT_ASSERT_TRUE(style->entries[0].key.name); |
| 249 | EXPECT_EQ(test::parseNameOrDie(u"@attr/bar"), style->entries[0].key.name.value()); |
| 250 | |
| 251 | AAPT_ASSERT_TRUE(style->entries[1].key.name); |
| 252 | EXPECT_EQ(test::parseNameOrDie(u"@attr/bat"), style->entries[1].key.name.value()); |
| 253 | |
| 254 | AAPT_ASSERT_TRUE(style->entries[2].key.name); |
| 255 | EXPECT_EQ(test::parseNameOrDie(u"@attr/baz"), style->entries[2].key.name.value()); |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 256 | } |
| 257 | |
Adam Lesinski | 769de98 | 2015-04-10 19:43:55 -0700 | [diff] [blame] | 258 | TEST_F(ResourceParserTest, ParseStyleWithShorthandParent) { |
Adam Lesinski | 24aad16 | 2015-04-24 19:19:30 -0700 | [diff] [blame] | 259 | std::string input = "<style name=\"foo\" parent=\"com.app:Theme\"/>"; |
Adam Lesinski | 769de98 | 2015-04-10 19:43:55 -0700 | [diff] [blame] | 260 | ASSERT_TRUE(testParse(input)); |
| 261 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 262 | Style* style = test::getValue<Style>(&mTable, u"@style/foo"); |
Adam Lesinski | 769de98 | 2015-04-10 19:43:55 -0700 | [diff] [blame] | 263 | ASSERT_NE(style, nullptr); |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 264 | AAPT_ASSERT_TRUE(style->parent); |
| 265 | AAPT_ASSERT_TRUE(style->parent.value().name); |
| 266 | EXPECT_EQ(test::parseNameOrDie(u"@com.app:style/Theme"), style->parent.value().name.value()); |
Adam Lesinski | 769de98 | 2015-04-10 19:43:55 -0700 | [diff] [blame] | 267 | } |
| 268 | |
Adam Lesinski | 24aad16 | 2015-04-24 19:19:30 -0700 | [diff] [blame] | 269 | TEST_F(ResourceParserTest, ParseStyleWithPackageAliasedParent) { |
| 270 | std::string input = "<style xmlns:app=\"http://schemas.android.com/apk/res/android\"\n" |
| 271 | " name=\"foo\" parent=\"app:Theme\"/>"; |
| 272 | ASSERT_TRUE(testParse(input)); |
| 273 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 274 | Style* style = test::getValue<Style>(&mTable, u"@style/foo"); |
Adam Lesinski | 24aad16 | 2015-04-24 19:19:30 -0700 | [diff] [blame] | 275 | ASSERT_NE(style, nullptr); |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 276 | AAPT_ASSERT_TRUE(style->parent); |
| 277 | AAPT_ASSERT_TRUE(style->parent.value().name); |
| 278 | EXPECT_EQ(test::parseNameOrDie(u"@android:style/Theme"), style->parent.value().name.value()); |
Adam Lesinski | 24aad16 | 2015-04-24 19:19:30 -0700 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | TEST_F(ResourceParserTest, ParseStyleWithPackageAliasedItems) { |
| 282 | std::string input = |
| 283 | "<style xmlns:app=\"http://schemas.android.com/apk/res/android\" name=\"foo\">\n" |
| 284 | " <item name=\"app:bar\">0</item>\n" |
| 285 | "</style>"; |
| 286 | ASSERT_TRUE(testParse(input)); |
| 287 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 288 | Style* style = test::getValue<Style>(&mTable, u"@style/foo"); |
Adam Lesinski | 24aad16 | 2015-04-24 19:19:30 -0700 | [diff] [blame] | 289 | ASSERT_NE(style, nullptr); |
| 290 | ASSERT_EQ(1u, style->entries.size()); |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 291 | EXPECT_EQ(test::parseNameOrDie(u"@android:attr/bar"), style->entries[0].key.name.value()); |
Adam Lesinski | 24aad16 | 2015-04-24 19:19:30 -0700 | [diff] [blame] | 292 | } |
| 293 | |
Adam Lesinski | bdaa092 | 2015-05-08 20:16:23 -0700 | [diff] [blame] | 294 | TEST_F(ResourceParserTest, ParseStyleWithInferredParent) { |
| 295 | std::string input = "<style name=\"foo.bar\"/>"; |
| 296 | ASSERT_TRUE(testParse(input)); |
| 297 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 298 | Style* style = test::getValue<Style>(&mTable, u"@style/foo.bar"); |
Adam Lesinski | bdaa092 | 2015-05-08 20:16:23 -0700 | [diff] [blame] | 299 | ASSERT_NE(style, nullptr); |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 300 | AAPT_ASSERT_TRUE(style->parent); |
| 301 | AAPT_ASSERT_TRUE(style->parent.value().name); |
| 302 | EXPECT_EQ(style->parent.value().name.value(), test::parseNameOrDie(u"@style/foo")); |
Adam Lesinski | bdaa092 | 2015-05-08 20:16:23 -0700 | [diff] [blame] | 303 | EXPECT_TRUE(style->parentInferred); |
| 304 | } |
| 305 | |
| 306 | TEST_F(ResourceParserTest, ParseStyleWithInferredParentOverridenByEmptyParentAttribute) { |
| 307 | std::string input = "<style name=\"foo.bar\" parent=\"\"/>"; |
| 308 | ASSERT_TRUE(testParse(input)); |
| 309 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 310 | Style* style = test::getValue<Style>(&mTable, u"@style/foo.bar"); |
Adam Lesinski | bdaa092 | 2015-05-08 20:16:23 -0700 | [diff] [blame] | 311 | ASSERT_NE(style, nullptr); |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 312 | AAPT_EXPECT_FALSE(style->parent); |
Adam Lesinski | bdaa092 | 2015-05-08 20:16:23 -0700 | [diff] [blame] | 313 | EXPECT_FALSE(style->parentInferred); |
| 314 | } |
| 315 | |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 316 | TEST_F(ResourceParserTest, ParseAutoGeneratedIdReference) { |
Adam Lesinski | 24aad16 | 2015-04-24 19:19:30 -0700 | [diff] [blame] | 317 | std::string input = "<string name=\"foo\">@+id/bar</string>"; |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 318 | ASSERT_TRUE(testParse(input)); |
| 319 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 320 | Id* id = test::getValue<Id>(&mTable, u"@id/bar"); |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 321 | ASSERT_NE(id, nullptr); |
| 322 | } |
| 323 | |
| 324 | TEST_F(ResourceParserTest, ParseAttributesDeclareStyleable) { |
Adam Lesinski | 24aad16 | 2015-04-24 19:19:30 -0700 | [diff] [blame] | 325 | std::string input = "<declare-styleable name=\"foo\">\n" |
| 326 | " <attr name=\"bar\" />\n" |
| 327 | " <attr name=\"bat\" format=\"string|reference\"/>\n" |
Adam Lesinski | 9ba47d8 | 2015-10-13 11:37:10 -0700 | [diff] [blame] | 328 | " <attr name=\"baz\">\n" |
| 329 | " <enum name=\"foo\" value=\"1\"/>\n" |
| 330 | " </attr>\n" |
Adam Lesinski | 24aad16 | 2015-04-24 19:19:30 -0700 | [diff] [blame] | 331 | "</declare-styleable>"; |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 332 | ASSERT_TRUE(testParse(input)); |
| 333 | |
Adam Lesinski | 9f22204 | 2015-11-04 13:51:45 -0800 | [diff] [blame] | 334 | Maybe<ResourceTable::SearchResult> result = |
| 335 | mTable.findResource(test::parseNameOrDie(u"@styleable/foo")); |
| 336 | AAPT_ASSERT_TRUE(result); |
| 337 | EXPECT_EQ(SymbolState::kPublic, result.value().entry->symbolStatus.state); |
| 338 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 339 | Attribute* attr = test::getValue<Attribute>(&mTable, u"@attr/bar"); |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 340 | ASSERT_NE(attr, nullptr); |
| 341 | EXPECT_TRUE(attr->isWeak()); |
| 342 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 343 | attr = test::getValue<Attribute>(&mTable, u"@attr/bat"); |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 344 | ASSERT_NE(attr, nullptr); |
| 345 | EXPECT_TRUE(attr->isWeak()); |
| 346 | |
Adam Lesinski | 9ba47d8 | 2015-10-13 11:37:10 -0700 | [diff] [blame] | 347 | attr = test::getValue<Attribute>(&mTable, u"@attr/baz"); |
| 348 | ASSERT_NE(attr, nullptr); |
| 349 | EXPECT_TRUE(attr->isWeak()); |
| 350 | EXPECT_EQ(1u, attr->symbols.size()); |
| 351 | |
| 352 | EXPECT_NE(nullptr, test::getValue<Id>(&mTable, u"@id/foo")); |
| 353 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 354 | Styleable* styleable = test::getValue<Styleable>(&mTable, u"@styleable/foo"); |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 355 | ASSERT_NE(styleable, nullptr); |
Adam Lesinski | 9ba47d8 | 2015-10-13 11:37:10 -0700 | [diff] [blame] | 356 | ASSERT_EQ(3u, styleable->entries.size()); |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 357 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 358 | EXPECT_EQ(test::parseNameOrDie(u"@attr/bar"), styleable->entries[0].name.value()); |
| 359 | EXPECT_EQ(test::parseNameOrDie(u"@attr/bat"), styleable->entries[1].name.value()); |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 360 | } |
| 361 | |
Adam Lesinski | 467f171 | 2015-11-16 17:35:44 -0800 | [diff] [blame] | 362 | TEST_F(ResourceParserTest, ParsePrivateAttributesDeclareStyleable) { |
| 363 | std::string input = "<declare-styleable name=\"foo\" xmlns:privAndroid=\"http://schemas.android.com/apk/prv/res/android\">\n" |
| 364 | " <attr name=\"*android:bar\" />\n" |
| 365 | " <attr name=\"privAndroid:bat\" />\n" |
| 366 | "</declare-styleable>"; |
| 367 | ASSERT_TRUE(testParse(input)); |
| 368 | Styleable* styleable = test::getValue<Styleable>(&mTable, u"@styleable/foo"); |
| 369 | ASSERT_NE(nullptr, styleable); |
| 370 | ASSERT_EQ(2u, styleable->entries.size()); |
| 371 | |
| 372 | EXPECT_TRUE(styleable->entries[0].privateReference); |
| 373 | AAPT_ASSERT_TRUE(styleable->entries[0].name); |
| 374 | EXPECT_EQ(std::u16string(u"android"), styleable->entries[0].name.value().package); |
| 375 | |
| 376 | EXPECT_TRUE(styleable->entries[1].privateReference); |
| 377 | AAPT_ASSERT_TRUE(styleable->entries[1].name); |
| 378 | EXPECT_EQ(std::u16string(u"android"), styleable->entries[1].name.value().package); |
| 379 | } |
| 380 | |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 381 | TEST_F(ResourceParserTest, ParseArray) { |
Adam Lesinski | 24aad16 | 2015-04-24 19:19:30 -0700 | [diff] [blame] | 382 | std::string input = "<array name=\"foo\">\n" |
| 383 | " <item>@string/ref</item>\n" |
| 384 | " <item>hey</item>\n" |
| 385 | " <item>23</item>\n" |
| 386 | "</array>"; |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 387 | ASSERT_TRUE(testParse(input)); |
| 388 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 389 | Array* array = test::getValue<Array>(&mTable, u"@array/foo"); |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 390 | ASSERT_NE(array, nullptr); |
| 391 | ASSERT_EQ(3u, array->items.size()); |
| 392 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 393 | EXPECT_NE(nullptr, valueCast<Reference>(array->items[0].get())); |
| 394 | EXPECT_NE(nullptr, valueCast<String>(array->items[1].get())); |
| 395 | EXPECT_NE(nullptr, valueCast<BinaryPrimitive>(array->items[2].get())); |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 396 | } |
| 397 | |
Adam Lesinski | 9ba47d8 | 2015-10-13 11:37:10 -0700 | [diff] [blame] | 398 | TEST_F(ResourceParserTest, ParseStringArray) { |
| 399 | std::string input = "<string-array name=\"foo\">\n" |
| 400 | " <item>\"Werk\"</item>\n" |
| 401 | "</string-array>\n"; |
| 402 | ASSERT_TRUE(testParse(input)); |
| 403 | EXPECT_NE(nullptr, test::getValue<Array>(&mTable, u"@array/foo")); |
| 404 | } |
| 405 | |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 406 | TEST_F(ResourceParserTest, ParsePlural) { |
Adam Lesinski | 24aad16 | 2015-04-24 19:19:30 -0700 | [diff] [blame] | 407 | std::string input = "<plurals name=\"foo\">\n" |
| 408 | " <item quantity=\"other\">apples</item>\n" |
| 409 | " <item quantity=\"one\">apple</item>\n" |
| 410 | "</plurals>"; |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 411 | ASSERT_TRUE(testParse(input)); |
| 412 | } |
| 413 | |
| 414 | TEST_F(ResourceParserTest, ParseCommentsWithResource) { |
Adam Lesinski | e78fd61 | 2015-10-22 12:48:43 -0700 | [diff] [blame] | 415 | std::string input = "<!--This is a comment-->\n" |
Adam Lesinski | 24aad16 | 2015-04-24 19:19:30 -0700 | [diff] [blame] | 416 | "<string name=\"foo\">Hi</string>"; |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 417 | ASSERT_TRUE(testParse(input)); |
| 418 | |
Adam Lesinski | e78fd61 | 2015-10-22 12:48:43 -0700 | [diff] [blame] | 419 | String* value = test::getValue<String>(&mTable, u"@string/foo"); |
| 420 | ASSERT_NE(nullptr, value); |
| 421 | EXPECT_EQ(value->getComment(), u"This is a comment"); |
| 422 | } |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 423 | |
Adam Lesinski | e78fd61 | 2015-10-22 12:48:43 -0700 | [diff] [blame] | 424 | TEST_F(ResourceParserTest, DoNotCombineMultipleComments) { |
| 425 | std::string input = "<!--One-->\n" |
| 426 | "<!--Two-->\n" |
| 427 | "<string name=\"foo\">Hi</string>"; |
| 428 | |
| 429 | ASSERT_TRUE(testParse(input)); |
| 430 | |
| 431 | String* value = test::getValue<String>(&mTable, u"@string/foo"); |
| 432 | ASSERT_NE(nullptr, value); |
| 433 | EXPECT_EQ(value->getComment(), u"Two"); |
| 434 | } |
| 435 | |
| 436 | TEST_F(ResourceParserTest, IgnoreCommentBeforeEndTag) { |
| 437 | std::string input = "<!--One-->\n" |
| 438 | "<string name=\"foo\">\n" |
| 439 | " Hi\n" |
| 440 | "<!--Two-->\n" |
| 441 | "</string>"; |
| 442 | |
| 443 | ASSERT_TRUE(testParse(input)); |
| 444 | |
| 445 | String* value = test::getValue<String>(&mTable, u"@string/foo"); |
| 446 | ASSERT_NE(nullptr, value); |
| 447 | EXPECT_EQ(value->getComment(), u"One"); |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 448 | } |
| 449 | |
Adam Lesinski | ca5638f | 2015-10-21 14:42:43 -0700 | [diff] [blame] | 450 | TEST_F(ResourceParserTest, ParseNestedComments) { |
| 451 | // We only care about declare-styleable and enum/flag attributes because comments |
| 452 | // from those end up in R.java |
| 453 | std::string input = R"EOF( |
| 454 | <declare-styleable name="foo"> |
| 455 | <!-- The name of the bar --> |
| 456 | <attr name="barName" format="string|reference" /> |
| 457 | </declare-styleable> |
| 458 | |
| 459 | <attr name="foo"> |
| 460 | <!-- The very first --> |
| 461 | <enum name="one" value="1" /> |
| 462 | </attr>)EOF"; |
| 463 | ASSERT_TRUE(testParse(input)); |
| 464 | |
| 465 | Styleable* styleable = test::getValue<Styleable>(&mTable, u"@styleable/foo"); |
| 466 | ASSERT_NE(nullptr, styleable); |
| 467 | ASSERT_EQ(1u, styleable->entries.size()); |
| 468 | |
| 469 | EXPECT_EQ(StringPiece16(u"The name of the bar"), styleable->entries.front().getComment()); |
| 470 | |
| 471 | Attribute* attr = test::getValue<Attribute>(&mTable, u"@attr/foo"); |
| 472 | ASSERT_NE(nullptr, attr); |
| 473 | ASSERT_EQ(1u, attr->symbols.size()); |
| 474 | |
| 475 | EXPECT_EQ(StringPiece16(u"The very first"), attr->symbols.front().symbol.getComment()); |
| 476 | } |
| 477 | |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 478 | /* |
| 479 | * Declaring an ID as public should not require a separate definition |
| 480 | * (as an ID has no value). |
| 481 | */ |
| 482 | TEST_F(ResourceParserTest, ParsePublicIdAsDefinition) { |
Adam Lesinski | 24aad16 | 2015-04-24 19:19:30 -0700 | [diff] [blame] | 483 | std::string input = "<public type=\"id\" name=\"foo\"/>"; |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 484 | ASSERT_TRUE(testParse(input)); |
| 485 | |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 486 | Id* id = test::getValue<Id>(&mTable, u"@id/foo"); |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 487 | ASSERT_NE(nullptr, id); |
| 488 | } |
| 489 | |
Adam Lesinski | 9ba47d8 | 2015-10-13 11:37:10 -0700 | [diff] [blame] | 490 | TEST_F(ResourceParserTest, FilterProductsThatDontMatch) { |
| 491 | std::string input = "<string name=\"foo\" product=\"phone\">hi</string>\n" |
| 492 | "<string name=\"foo\" product=\"no-sdcard\">ho</string>\n" |
| 493 | "<string name=\"bar\" product=\"\">wee</string>\n" |
| 494 | "<string name=\"baz\">woo</string>\n"; |
| 495 | ASSERT_TRUE(testParse(input, std::u16string(u"no-sdcard"))); |
| 496 | |
| 497 | String* fooStr = test::getValue<String>(&mTable, u"@string/foo"); |
| 498 | ASSERT_NE(nullptr, fooStr); |
| 499 | EXPECT_EQ(StringPiece16(u"ho"), *fooStr->value); |
| 500 | |
| 501 | EXPECT_NE(nullptr, test::getValue<String>(&mTable, u"@string/bar")); |
| 502 | EXPECT_NE(nullptr, test::getValue<String>(&mTable, u"@string/baz")); |
| 503 | } |
| 504 | |
| 505 | TEST_F(ResourceParserTest, FailWhenProductFilterStripsOutAllVersionsOfResource) { |
| 506 | std::string input = "<string name=\"foo\" product=\"tablet\">hello</string>\n"; |
| 507 | ASSERT_FALSE(testParse(input, std::u16string(u"phone"))); |
| 508 | } |
| 509 | |
Adam Lesinski | 27afb9e | 2015-11-06 18:25:04 -0800 | [diff] [blame] | 510 | TEST_F(ResourceParserTest, AutoIncrementIdsInPublicGroup) { |
| 511 | std::string input = R"EOF( |
| 512 | <public-group type="attr" first-id="0x01010040"> |
| 513 | <public name="foo" /> |
| 514 | <public name="bar" /> |
| 515 | </public-group>)EOF"; |
| 516 | ASSERT_TRUE(testParse(input)); |
| 517 | |
| 518 | Maybe<ResourceTable::SearchResult> result = mTable.findResource( |
| 519 | test::parseNameOrDie(u"@attr/foo")); |
| 520 | AAPT_ASSERT_TRUE(result); |
| 521 | |
| 522 | AAPT_ASSERT_TRUE(result.value().package->id); |
| 523 | AAPT_ASSERT_TRUE(result.value().type->id); |
| 524 | AAPT_ASSERT_TRUE(result.value().entry->id); |
| 525 | ResourceId actualId(result.value().package->id.value(), |
| 526 | result.value().type->id.value(), |
| 527 | result.value().entry->id.value()); |
| 528 | EXPECT_EQ(ResourceId(0x01010040), actualId); |
| 529 | |
| 530 | result = mTable.findResource(test::parseNameOrDie(u"@attr/bar")); |
| 531 | AAPT_ASSERT_TRUE(result); |
| 532 | |
| 533 | AAPT_ASSERT_TRUE(result.value().package->id); |
| 534 | AAPT_ASSERT_TRUE(result.value().type->id); |
| 535 | AAPT_ASSERT_TRUE(result.value().entry->id); |
| 536 | actualId = ResourceId(result.value().package->id.value(), |
| 537 | result.value().type->id.value(), |
| 538 | result.value().entry->id.value()); |
| 539 | EXPECT_EQ(ResourceId(0x01010041), actualId); |
| 540 | } |
| 541 | |
Adam Lesinski | fa10505 | 2015-11-07 13:34:39 -0800 | [diff] [blame] | 542 | TEST_F(ResourceParserTest, ExternalTypesShouldOnlyBeReferences) { |
| 543 | std::string input = R"EOF(<item type="layout" name="foo">@layout/bar</item>)EOF"; |
| 544 | ASSERT_TRUE(testParse(input)); |
| 545 | |
| 546 | input = R"EOF(<item type="layout" name="bar">"this is a string"</item>)EOF"; |
| 547 | ASSERT_FALSE(testParse(input)); |
| 548 | } |
| 549 | |
Adam Lesinski | 6f6ceb7 | 2014-11-14 14:48:12 -0800 | [diff] [blame] | 550 | } // namespace aapt |