Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1411)

Side by Side Diff: content/renderer/manifest/manifest_parser_unittest.cc

Issue 1932623003: DevTools: Introduce Page.getManifest remote debugging protocol method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: browser test updated Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/manifest/manifest_parser.h" 5 #include "content/renderer/manifest/manifest_parser.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 15 matching lines...) Expand all
26 class ManifestParserTest : public testing::Test { 26 class ManifestParserTest : public testing::Test {
27 protected: 27 protected:
28 ManifestParserTest() {} 28 ManifestParserTest() {}
29 ~ManifestParserTest() override {} 29 ~ManifestParserTest() override {}
30 30
31 Manifest ParseManifestWithURLs(const base::StringPiece& data, 31 Manifest ParseManifestWithURLs(const base::StringPiece& data,
32 const GURL& document_url, 32 const GURL& document_url,
33 const GURL& manifest_url) { 33 const GURL& manifest_url) {
34 ManifestParser parser(data, document_url, manifest_url); 34 ManifestParser parser(data, document_url, manifest_url);
35 parser.Parse(); 35 parser.Parse();
36 std::vector<ManifestDebugInfo::Error> errors;
37 parser.TakeErrors(&errors);
38
36 errors_.clear(); 39 errors_.clear();
37 for (const std::unique_ptr<ManifestParser::ErrorInfo>& error_info : 40 for (const auto& error : errors)
38 parser.errors()) { 41 errors_.push_back(error.message);
39 errors_.push_back(error_info->error_msg);
40 }
41 return parser.manifest(); 42 return parser.manifest();
42 } 43 }
43 44
44 Manifest ParseManifest(const base::StringPiece& data) { 45 Manifest ParseManifest(const base::StringPiece& data) {
45 return ParseManifestWithURLs( 46 return ParseManifestWithURLs(
46 data, default_document_url, default_manifest_url); 47 data, default_document_url, default_manifest_url);
47 } 48 }
48 49
49 const std::vector<std::string>& errors() const { 50 const std::vector<std::string>& errors() const {
50 return errors_; 51 return errors_;
(...skipping 16 matching lines...) Expand all
67 "http://foo.com/index.html"); 68 "http://foo.com/index.html");
68 const GURL ManifestParserTest::default_manifest_url( 69 const GURL ManifestParserTest::default_manifest_url(
69 "http://foo.com/manifest.json"); 70 "http://foo.com/manifest.json");
70 71
71 TEST_F(ManifestParserTest, CrashTest) { 72 TEST_F(ManifestParserTest, CrashTest) {
72 // Passing temporary variables should not crash. 73 // Passing temporary variables should not crash.
73 ManifestParser parser("{\"start_url\": \"/\"}", 74 ManifestParser parser("{\"start_url\": \"/\"}",
74 GURL("http://example.com"), 75 GURL("http://example.com"),
75 GURL("http://example.com")); 76 GURL("http://example.com"));
76 parser.Parse(); 77 parser.Parse();
78 std::vector<ManifestDebugInfo::Error> errors;
79 parser.TakeErrors(&errors);
77 80
78 // .Parse() should have been call without crashing and succeeded. 81 // .Parse() should have been call without crashing and succeeded.
79 EXPECT_EQ(0u, parser.errors().size()); 82 EXPECT_EQ(0u, errors.size());
80 EXPECT_FALSE(parser.manifest().IsEmpty()); 83 EXPECT_FALSE(parser.manifest().IsEmpty());
81 } 84 }
82 85
83 TEST_F(ManifestParserTest, EmptyStringNull) { 86 TEST_F(ManifestParserTest, EmptyStringNull) {
84 Manifest manifest = ParseManifest(""); 87 Manifest manifest = ParseManifest("");
85 88
86 // This Manifest is not a valid JSON object, it's a parsing error. 89 // This Manifest is not a valid JSON object, it's a parsing error.
87 EXPECT_EQ(1u, GetErrorCount()); 90 EXPECT_EQ(1u, GetErrorCount());
88 EXPECT_EQ("Manifest parsing error: Line: 1, column: 1, Unexpected token.", 91 EXPECT_EQ("Line: 1, column: 1, Unexpected token.",
89 errors()[0]); 92 errors()[0]);
90 93
91 // A parsing error is equivalent to an empty manifest. 94 // A parsing error is equivalent to an empty manifest.
92 ASSERT_TRUE(manifest.IsEmpty()); 95 ASSERT_TRUE(manifest.IsEmpty());
93 ASSERT_TRUE(manifest.name.is_null()); 96 ASSERT_TRUE(manifest.name.is_null());
94 ASSERT_TRUE(manifest.short_name.is_null()); 97 ASSERT_TRUE(manifest.short_name.is_null());
95 ASSERT_TRUE(manifest.start_url.is_empty()); 98 ASSERT_TRUE(manifest.start_url.is_empty());
96 ASSERT_EQ(manifest.display, blink::WebDisplayModeUndefined); 99 ASSERT_EQ(manifest.display, blink::WebDisplayModeUndefined);
97 ASSERT_EQ(manifest.orientation, blink::WebScreenOrientationLockDefault); 100 ASSERT_EQ(manifest.orientation, blink::WebScreenOrientationLockDefault);
98 ASSERT_EQ(manifest.theme_color, Manifest::kInvalidOrMissingColor); 101 ASSERT_EQ(manifest.theme_color, Manifest::kInvalidOrMissingColor);
(...skipping 20 matching lines...) Expand all
119 } 122 }
120 123
121 TEST_F(ManifestParserTest, MultipleErrorsReporting) { 124 TEST_F(ManifestParserTest, MultipleErrorsReporting) {
122 Manifest manifest = ParseManifest("{ \"name\": 42, \"short_name\": 4," 125 Manifest manifest = ParseManifest("{ \"name\": 42, \"short_name\": 4,"
123 "\"orientation\": {}, \"display\": \"foo\"," 126 "\"orientation\": {}, \"display\": \"foo\","
124 "\"start_url\": null, \"icons\": {}, \"theme_color\": 42," 127 "\"start_url\": null, \"icons\": {}, \"theme_color\": 42,"
125 "\"background_color\": 42 }"); 128 "\"background_color\": 42 }");
126 129
127 EXPECT_EQ(8u, GetErrorCount()); 130 EXPECT_EQ(8u, GetErrorCount());
128 131
129 EXPECT_EQ("Manifest parsing error: property 'name' ignored," 132 EXPECT_EQ("property 'name' ignored, type string expected.",
130 " type string expected.",
131 errors()[0]); 133 errors()[0]);
132 EXPECT_EQ("Manifest parsing error: property 'short_name' ignored," 134 EXPECT_EQ("property 'short_name' ignored, type string expected.",
133 " type string expected.",
134 errors()[1]); 135 errors()[1]);
135 EXPECT_EQ("Manifest parsing error: property 'start_url' ignored," 136 EXPECT_EQ("property 'start_url' ignored, type string expected.",
136 " type string expected.",
137 errors()[2]); 137 errors()[2]);
138 EXPECT_EQ("Manifest parsing error: unknown 'display' value ignored.", 138 EXPECT_EQ("unknown 'display' value ignored.",
139 errors()[3]); 139 errors()[3]);
140 EXPECT_EQ("Manifest parsing error: property 'orientation' ignored," 140 EXPECT_EQ("property 'orientation' ignored, type string expected.",
141 " type string expected.",
142 errors()[4]); 141 errors()[4]);
143 EXPECT_EQ("Manifest parsing error: property 'icons' ignored, " 142 EXPECT_EQ("property 'icons' ignored, type array expected.",
144 "type array expected.",
145 errors()[5]); 143 errors()[5]);
146 EXPECT_EQ("Manifest parsing error: property 'theme_color' ignored," 144 EXPECT_EQ("property 'theme_color' ignored, type string expected.",
147 " type string expected.",
148 errors()[6]); 145 errors()[6]);
149 EXPECT_EQ("Manifest parsing error: property 'background_color' ignored," 146 EXPECT_EQ("property 'background_color' ignored, type string expected.",
150 " type string expected.",
151 errors()[7]); 147 errors()[7]);
152 } 148 }
153 149
154 TEST_F(ManifestParserTest, NameParseRules) { 150 TEST_F(ManifestParserTest, NameParseRules) {
155 // Smoke test. 151 // Smoke test.
156 { 152 {
157 Manifest manifest = ParseManifest("{ \"name\": \"foo\" }"); 153 Manifest manifest = ParseManifest("{ \"name\": \"foo\" }");
158 ASSERT_TRUE(base::EqualsASCII(manifest.name.string(), "foo")); 154 ASSERT_TRUE(base::EqualsASCII(manifest.name.string(), "foo"));
159 ASSERT_FALSE(manifest.IsEmpty()); 155 ASSERT_FALSE(manifest.IsEmpty());
160 EXPECT_EQ(0u, GetErrorCount()); 156 EXPECT_EQ(0u, GetErrorCount());
161 } 157 }
162 158
163 // Trim whitespaces. 159 // Trim whitespaces.
164 { 160 {
165 Manifest manifest = ParseManifest("{ \"name\": \" foo \" }"); 161 Manifest manifest = ParseManifest("{ \"name\": \" foo \" }");
166 ASSERT_TRUE(base::EqualsASCII(manifest.name.string(), "foo")); 162 ASSERT_TRUE(base::EqualsASCII(manifest.name.string(), "foo"));
167 EXPECT_EQ(0u, GetErrorCount()); 163 EXPECT_EQ(0u, GetErrorCount());
168 } 164 }
169 165
170 // Don't parse if name isn't a string. 166 // Don't parse if name isn't a string.
171 { 167 {
172 Manifest manifest = ParseManifest("{ \"name\": {} }"); 168 Manifest manifest = ParseManifest("{ \"name\": {} }");
173 ASSERT_TRUE(manifest.name.is_null()); 169 ASSERT_TRUE(manifest.name.is_null());
174 EXPECT_EQ(1u, GetErrorCount()); 170 EXPECT_EQ(1u, GetErrorCount());
175 EXPECT_EQ("Manifest parsing error: property 'name' ignored," 171 EXPECT_EQ("property 'name' ignored, type string expected.",
176 " type string expected.",
177 errors()[0]); 172 errors()[0]);
178 } 173 }
179 174
180 // Don't parse if name isn't a string. 175 // Don't parse if name isn't a string.
181 { 176 {
182 Manifest manifest = ParseManifest("{ \"name\": 42 }"); 177 Manifest manifest = ParseManifest("{ \"name\": 42 }");
183 ASSERT_TRUE(manifest.name.is_null()); 178 ASSERT_TRUE(manifest.name.is_null());
184 EXPECT_EQ(1u, GetErrorCount()); 179 EXPECT_EQ(1u, GetErrorCount());
185 EXPECT_EQ("Manifest parsing error: property 'name' ignored," 180 EXPECT_EQ("property 'name' ignored, type string expected.",
186 " type string expected.",
187 errors()[0]); 181 errors()[0]);
188 } 182 }
189 } 183 }
190 184
191 TEST_F(ManifestParserTest, ShortNameParseRules) { 185 TEST_F(ManifestParserTest, ShortNameParseRules) {
192 // Smoke test. 186 // Smoke test.
193 { 187 {
194 Manifest manifest = ParseManifest("{ \"short_name\": \"foo\" }"); 188 Manifest manifest = ParseManifest("{ \"short_name\": \"foo\" }");
195 ASSERT_TRUE(base::EqualsASCII(manifest.short_name.string(), "foo")); 189 ASSERT_TRUE(base::EqualsASCII(manifest.short_name.string(), "foo"));
196 ASSERT_FALSE(manifest.IsEmpty()); 190 ASSERT_FALSE(manifest.IsEmpty());
197 EXPECT_EQ(0u, GetErrorCount()); 191 EXPECT_EQ(0u, GetErrorCount());
198 } 192 }
199 193
200 // Trim whitespaces. 194 // Trim whitespaces.
201 { 195 {
202 Manifest manifest = ParseManifest("{ \"short_name\": \" foo \" }"); 196 Manifest manifest = ParseManifest("{ \"short_name\": \" foo \" }");
203 ASSERT_TRUE(base::EqualsASCII(manifest.short_name.string(), "foo")); 197 ASSERT_TRUE(base::EqualsASCII(manifest.short_name.string(), "foo"));
204 EXPECT_EQ(0u, GetErrorCount()); 198 EXPECT_EQ(0u, GetErrorCount());
205 } 199 }
206 200
207 // Don't parse if name isn't a string. 201 // Don't parse if name isn't a string.
208 { 202 {
209 Manifest manifest = ParseManifest("{ \"short_name\": {} }"); 203 Manifest manifest = ParseManifest("{ \"short_name\": {} }");
210 ASSERT_TRUE(manifest.short_name.is_null()); 204 ASSERT_TRUE(manifest.short_name.is_null());
211 EXPECT_EQ(1u, GetErrorCount()); 205 EXPECT_EQ(1u, GetErrorCount());
212 EXPECT_EQ("Manifest parsing error: property 'short_name' ignored," 206 EXPECT_EQ("property 'short_name' ignored, type string expected.",
213 " type string expected.",
214 errors()[0]); 207 errors()[0]);
215 } 208 }
216 209
217 // Don't parse if name isn't a string. 210 // Don't parse if name isn't a string.
218 { 211 {
219 Manifest manifest = ParseManifest("{ \"short_name\": 42 }"); 212 Manifest manifest = ParseManifest("{ \"short_name\": 42 }");
220 ASSERT_TRUE(manifest.short_name.is_null()); 213 ASSERT_TRUE(manifest.short_name.is_null());
221 EXPECT_EQ(1u, GetErrorCount()); 214 EXPECT_EQ(1u, GetErrorCount());
222 EXPECT_EQ("Manifest parsing error: property 'short_name' ignored," 215 EXPECT_EQ("property 'short_name' ignored, type string expected.",
223 " type string expected.",
224 errors()[0]); 216 errors()[0]);
225 } 217 }
226 } 218 }
227 219
228 TEST_F(ManifestParserTest, StartURLParseRules) { 220 TEST_F(ManifestParserTest, StartURLParseRules) {
229 // Smoke test. 221 // Smoke test.
230 { 222 {
231 Manifest manifest = ParseManifest("{ \"start_url\": \"land.html\" }"); 223 Manifest manifest = ParseManifest("{ \"start_url\": \"land.html\" }");
232 ASSERT_EQ(manifest.start_url.spec(), 224 ASSERT_EQ(manifest.start_url.spec(),
233 default_document_url.Resolve("land.html").spec()); 225 default_document_url.Resolve("land.html").spec());
234 ASSERT_FALSE(manifest.IsEmpty()); 226 ASSERT_FALSE(manifest.IsEmpty());
235 EXPECT_EQ(0u, GetErrorCount()); 227 EXPECT_EQ(0u, GetErrorCount());
236 } 228 }
237 229
238 // Whitespaces. 230 // Whitespaces.
239 { 231 {
240 Manifest manifest = ParseManifest("{ \"start_url\": \" land.html \" }"); 232 Manifest manifest = ParseManifest("{ \"start_url\": \" land.html \" }");
241 ASSERT_EQ(manifest.start_url.spec(), 233 ASSERT_EQ(manifest.start_url.spec(),
242 default_document_url.Resolve("land.html").spec()); 234 default_document_url.Resolve("land.html").spec());
243 EXPECT_EQ(0u, GetErrorCount()); 235 EXPECT_EQ(0u, GetErrorCount());
244 } 236 }
245 237
246 // Don't parse if property isn't a string. 238 // Don't parse if property isn't a string.
247 { 239 {
248 Manifest manifest = ParseManifest("{ \"start_url\": {} }"); 240 Manifest manifest = ParseManifest("{ \"start_url\": {} }");
249 ASSERT_TRUE(manifest.start_url.is_empty()); 241 ASSERT_TRUE(manifest.start_url.is_empty());
250 EXPECT_EQ(1u, GetErrorCount()); 242 EXPECT_EQ(1u, GetErrorCount());
251 EXPECT_EQ("Manifest parsing error: property 'start_url' ignored," 243 EXPECT_EQ("property 'start_url' ignored, type string expected.",
252 " type string expected.",
253 errors()[0]); 244 errors()[0]);
254 } 245 }
255 246
256 // Don't parse if property isn't a string. 247 // Don't parse if property isn't a string.
257 { 248 {
258 Manifest manifest = ParseManifest("{ \"start_url\": 42 }"); 249 Manifest manifest = ParseManifest("{ \"start_url\": 42 }");
259 ASSERT_TRUE(manifest.start_url.is_empty()); 250 ASSERT_TRUE(manifest.start_url.is_empty());
260 EXPECT_EQ(1u, GetErrorCount()); 251 EXPECT_EQ(1u, GetErrorCount());
261 EXPECT_EQ("Manifest parsing error: property 'start_url' ignored," 252 EXPECT_EQ("property 'start_url' ignored, type string expected.",
262 " type string expected.",
263 errors()[0]); 253 errors()[0]);
264 } 254 }
265 255
266 // Absolute start_url, same origin with document. 256 // Absolute start_url, same origin with document.
267 { 257 {
268 Manifest manifest = 258 Manifest manifest =
269 ParseManifestWithURLs("{ \"start_url\": \"http://foo.com/land.html\" }", 259 ParseManifestWithURLs("{ \"start_url\": \"http://foo.com/land.html\" }",
270 GURL("http://foo.com/manifest.json"), 260 GURL("http://foo.com/manifest.json"),
271 GURL("http://foo.com/index.html")); 261 GURL("http://foo.com/index.html"));
272 ASSERT_EQ(manifest.start_url.spec(), "http://foo.com/land.html"); 262 ASSERT_EQ(manifest.start_url.spec(), "http://foo.com/land.html");
273 EXPECT_EQ(0u, GetErrorCount()); 263 EXPECT_EQ(0u, GetErrorCount());
274 } 264 }
275 265
276 // Absolute start_url, cross origin with document. 266 // Absolute start_url, cross origin with document.
277 { 267 {
278 Manifest manifest = 268 Manifest manifest =
279 ParseManifestWithURLs("{ \"start_url\": \"http://bar.com/land.html\" }", 269 ParseManifestWithURLs("{ \"start_url\": \"http://bar.com/land.html\" }",
280 GURL("http://foo.com/manifest.json"), 270 GURL("http://foo.com/manifest.json"),
281 GURL("http://foo.com/index.html")); 271 GURL("http://foo.com/index.html"));
282 ASSERT_TRUE(manifest.start_url.is_empty()); 272 ASSERT_TRUE(manifest.start_url.is_empty());
283 EXPECT_EQ(1u, GetErrorCount()); 273 EXPECT_EQ(1u, GetErrorCount());
284 EXPECT_EQ("Manifest parsing error: property 'start_url' ignored, should " 274 EXPECT_EQ("property 'start_url' ignored, should "
285 "be same origin as document.", 275 "be same origin as document.",
286 errors()[0]); 276 errors()[0]);
287 } 277 }
288 278
289 // Resolving has to happen based on the manifest_url. 279 // Resolving has to happen based on the manifest_url.
290 { 280 {
291 Manifest manifest = 281 Manifest manifest =
292 ParseManifestWithURLs("{ \"start_url\": \"land.html\" }", 282 ParseManifestWithURLs("{ \"start_url\": \"land.html\" }",
293 GURL("http://foo.com/landing/manifest.json"), 283 GURL("http://foo.com/landing/manifest.json"),
294 GURL("http://foo.com/index.html")); 284 GURL("http://foo.com/index.html"));
(...skipping 16 matching lines...) Expand all
311 Manifest manifest = ParseManifest("{ \"display\": \" browser \" }"); 301 Manifest manifest = ParseManifest("{ \"display\": \" browser \" }");
312 EXPECT_EQ(manifest.display, blink::WebDisplayModeBrowser); 302 EXPECT_EQ(manifest.display, blink::WebDisplayModeBrowser);
313 EXPECT_EQ(0u, GetErrorCount()); 303 EXPECT_EQ(0u, GetErrorCount());
314 } 304 }
315 305
316 // Don't parse if name isn't a string. 306 // Don't parse if name isn't a string.
317 { 307 {
318 Manifest manifest = ParseManifest("{ \"display\": {} }"); 308 Manifest manifest = ParseManifest("{ \"display\": {} }");
319 EXPECT_EQ(manifest.display, blink::WebDisplayModeUndefined); 309 EXPECT_EQ(manifest.display, blink::WebDisplayModeUndefined);
320 EXPECT_EQ(1u, GetErrorCount()); 310 EXPECT_EQ(1u, GetErrorCount());
321 EXPECT_EQ("Manifest parsing error: property 'display' ignored," 311 EXPECT_EQ("property 'display' ignored,"
322 " type string expected.", 312 " type string expected.",
323 errors()[0]); 313 errors()[0]);
324 } 314 }
325 315
326 // Don't parse if name isn't a string. 316 // Don't parse if name isn't a string.
327 { 317 {
328 Manifest manifest = ParseManifest("{ \"display\": 42 }"); 318 Manifest manifest = ParseManifest("{ \"display\": 42 }");
329 EXPECT_EQ(manifest.display, blink::WebDisplayModeUndefined); 319 EXPECT_EQ(manifest.display, blink::WebDisplayModeUndefined);
330 EXPECT_EQ(1u, GetErrorCount()); 320 EXPECT_EQ(1u, GetErrorCount());
331 EXPECT_EQ("Manifest parsing error: property 'display' ignored," 321 EXPECT_EQ("property 'display' ignored,"
332 " type string expected.", 322 " type string expected.",
333 errors()[0]); 323 errors()[0]);
334 } 324 }
335 325
336 // Parse fails if string isn't known. 326 // Parse fails if string isn't known.
337 { 327 {
338 Manifest manifest = ParseManifest("{ \"display\": \"browser_something\" }"); 328 Manifest manifest = ParseManifest("{ \"display\": \"browser_something\" }");
339 EXPECT_EQ(manifest.display, blink::WebDisplayModeUndefined); 329 EXPECT_EQ(manifest.display, blink::WebDisplayModeUndefined);
340 EXPECT_EQ(1u, GetErrorCount()); 330 EXPECT_EQ(1u, GetErrorCount());
341 EXPECT_EQ("Manifest parsing error: unknown 'display' value ignored.", 331 EXPECT_EQ("unknown 'display' value ignored.",
342 errors()[0]); 332 errors()[0]);
343 } 333 }
344 334
345 // Accept 'fullscreen'. 335 // Accept 'fullscreen'.
346 { 336 {
347 Manifest manifest = ParseManifest("{ \"display\": \"fullscreen\" }"); 337 Manifest manifest = ParseManifest("{ \"display\": \"fullscreen\" }");
348 EXPECT_EQ(manifest.display, blink::WebDisplayModeFullscreen); 338 EXPECT_EQ(manifest.display, blink::WebDisplayModeFullscreen);
349 EXPECT_EQ(0u, GetErrorCount()); 339 EXPECT_EQ(0u, GetErrorCount());
350 } 340 }
351 341
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 Manifest manifest = ParseManifest("{ \"orientation\": \"natural\" }"); 382 Manifest manifest = ParseManifest("{ \"orientation\": \"natural\" }");
393 EXPECT_EQ(manifest.orientation, blink::WebScreenOrientationLockNatural); 383 EXPECT_EQ(manifest.orientation, blink::WebScreenOrientationLockNatural);
394 EXPECT_EQ(0u, GetErrorCount()); 384 EXPECT_EQ(0u, GetErrorCount());
395 } 385 }
396 386
397 // Don't parse if name isn't a string. 387 // Don't parse if name isn't a string.
398 { 388 {
399 Manifest manifest = ParseManifest("{ \"orientation\": {} }"); 389 Manifest manifest = ParseManifest("{ \"orientation\": {} }");
400 EXPECT_EQ(manifest.orientation, blink::WebScreenOrientationLockDefault); 390 EXPECT_EQ(manifest.orientation, blink::WebScreenOrientationLockDefault);
401 EXPECT_EQ(1u, GetErrorCount()); 391 EXPECT_EQ(1u, GetErrorCount());
402 EXPECT_EQ("Manifest parsing error: property 'orientation' ignored," 392 EXPECT_EQ("property 'orientation' ignored, type string expected.",
403 " type string expected.",
404 errors()[0]); 393 errors()[0]);
405 } 394 }
406 395
407 // Don't parse if name isn't a string. 396 // Don't parse if name isn't a string.
408 { 397 {
409 Manifest manifest = ParseManifest("{ \"orientation\": 42 }"); 398 Manifest manifest = ParseManifest("{ \"orientation\": 42 }");
410 EXPECT_EQ(manifest.orientation, blink::WebScreenOrientationLockDefault); 399 EXPECT_EQ(manifest.orientation, blink::WebScreenOrientationLockDefault);
411 EXPECT_EQ(1u, GetErrorCount()); 400 EXPECT_EQ(1u, GetErrorCount());
412 EXPECT_EQ("Manifest parsing error: property 'orientation' ignored," 401 EXPECT_EQ("property 'orientation' ignored, type string expected.",
413 " type string expected.",
414 errors()[0]); 402 errors()[0]);
415 } 403 }
416 404
417 // Parse fails if string isn't known. 405 // Parse fails if string isn't known.
418 { 406 {
419 Manifest manifest = ParseManifest("{ \"orientation\": \"naturalish\" }"); 407 Manifest manifest = ParseManifest("{ \"orientation\": \"naturalish\" }");
420 EXPECT_EQ(manifest.orientation, blink::WebScreenOrientationLockDefault); 408 EXPECT_EQ(manifest.orientation, blink::WebScreenOrientationLockDefault);
421 EXPECT_EQ(1u, GetErrorCount()); 409 EXPECT_EQ(1u, GetErrorCount());
422 EXPECT_EQ("Manifest parsing error: unknown 'orientation' value ignored.", 410 EXPECT_EQ("unknown 'orientation' value ignored.",
423 errors()[0]); 411 errors()[0]);
424 } 412 }
425 413
426 // Accept 'any'. 414 // Accept 'any'.
427 { 415 {
428 Manifest manifest = ParseManifest("{ \"orientation\": \"any\" }"); 416 Manifest manifest = ParseManifest("{ \"orientation\": \"any\" }");
429 EXPECT_EQ(manifest.orientation, blink::WebScreenOrientationLockAny); 417 EXPECT_EQ(manifest.orientation, blink::WebScreenOrientationLockAny);
430 EXPECT_EQ(0u, GetErrorCount()); 418 EXPECT_EQ(0u, GetErrorCount());
431 } 419 }
432 420
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 EXPECT_EQ(manifest.icons[0].src.spec(), 545 EXPECT_EQ(manifest.icons[0].src.spec(),
558 default_document_url.Resolve("foo.png").spec()); 546 default_document_url.Resolve("foo.png").spec());
559 EXPECT_EQ(0u, GetErrorCount()); 547 EXPECT_EQ(0u, GetErrorCount());
560 } 548 }
561 549
562 // Don't parse if property isn't a string. 550 // Don't parse if property isn't a string.
563 { 551 {
564 Manifest manifest = ParseManifest("{ \"icons\": [ {\"src\": {} } ] }"); 552 Manifest manifest = ParseManifest("{ \"icons\": [ {\"src\": {} } ] }");
565 EXPECT_TRUE(manifest.icons.empty()); 553 EXPECT_TRUE(manifest.icons.empty());
566 EXPECT_EQ(1u, GetErrorCount()); 554 EXPECT_EQ(1u, GetErrorCount());
567 EXPECT_EQ("Manifest parsing error: property 'src' ignored," 555 EXPECT_EQ("property 'src' ignored, type string expected.",
568 " type string expected.",
569 errors()[0]); 556 errors()[0]);
570 } 557 }
571 558
572 // Don't parse if property isn't a string. 559 // Don't parse if property isn't a string.
573 { 560 {
574 Manifest manifest = ParseManifest("{ \"icons\": [ {\"src\": 42 } ] }"); 561 Manifest manifest = ParseManifest("{ \"icons\": [ {\"src\": 42 } ] }");
575 EXPECT_TRUE(manifest.icons.empty()); 562 EXPECT_TRUE(manifest.icons.empty());
576 EXPECT_EQ(1u, GetErrorCount()); 563 EXPECT_EQ(1u, GetErrorCount());
577 EXPECT_EQ("Manifest parsing error: property 'src' ignored," 564 EXPECT_EQ("property 'src' ignored, type string expected.",
578 " type string expected.",
579 errors()[0]); 565 errors()[0]);
580 } 566 }
581 567
582 // Resolving has to happen based on the document_url. 568 // Resolving has to happen based on the document_url.
583 { 569 {
584 Manifest manifest = ParseManifestWithURLs( 570 Manifest manifest = ParseManifestWithURLs(
585 "{ \"icons\": [ {\"src\": \"icons/foo.png\" } ] }", 571 "{ \"icons\": [ {\"src\": \"icons/foo.png\" } ] }",
586 GURL("http://foo.com/landing/index.html"), 572 GURL("http://foo.com/landing/index.html"),
587 default_manifest_url); 573 default_manifest_url);
588 EXPECT_EQ(manifest.icons[0].src.spec(), 574 EXPECT_EQ(manifest.icons[0].src.spec(),
(...skipping 18 matching lines...) Expand all
607 EXPECT_TRUE(base::EqualsASCII(manifest.icons[0].type.string(), "foo")); 593 EXPECT_TRUE(base::EqualsASCII(manifest.icons[0].type.string(), "foo"));
608 EXPECT_EQ(0u, GetErrorCount()); 594 EXPECT_EQ(0u, GetErrorCount());
609 } 595 }
610 596
611 // Don't parse if property isn't a string. 597 // Don't parse if property isn't a string.
612 { 598 {
613 Manifest manifest = 599 Manifest manifest =
614 ParseManifest("{ \"icons\": [ {\"src\": \"\", \"type\": {} } ] }"); 600 ParseManifest("{ \"icons\": [ {\"src\": \"\", \"type\": {} } ] }");
615 EXPECT_TRUE(manifest.icons[0].type.is_null()); 601 EXPECT_TRUE(manifest.icons[0].type.is_null());
616 EXPECT_EQ(1u, GetErrorCount()); 602 EXPECT_EQ(1u, GetErrorCount());
617 EXPECT_EQ("Manifest parsing error: property 'type' ignored," 603 EXPECT_EQ("property 'type' ignored, type string expected.",
618 " type string expected.",
619 errors()[0]); 604 errors()[0]);
620 } 605 }
621 606
622 // Don't parse if property isn't a string. 607 // Don't parse if property isn't a string.
623 { 608 {
624 Manifest manifest = 609 Manifest manifest =
625 ParseManifest("{ \"icons\": [ {\"src\": \"\", \"type\": 42 } ] }"); 610 ParseManifest("{ \"icons\": [ {\"src\": \"\", \"type\": 42 } ] }");
626 EXPECT_TRUE(manifest.icons[0].type.is_null()); 611 EXPECT_TRUE(manifest.icons[0].type.is_null());
627 EXPECT_EQ(1u, GetErrorCount()); 612 EXPECT_EQ(1u, GetErrorCount());
628 EXPECT_EQ("Manifest parsing error: property 'type' ignored," 613 EXPECT_EQ("property 'type' ignored, type string expected.",
629 " type string expected.",
630 errors()[0]); 614 errors()[0]);
631 } 615 }
632 } 616 }
633 617
634 TEST_F(ManifestParserTest, IconSizesParseRules) { 618 TEST_F(ManifestParserTest, IconSizesParseRules) {
635 // Smoke test. 619 // Smoke test.
636 { 620 {
637 Manifest manifest = ParseManifest("{ \"icons\": [ {\"src\": \"\"," 621 Manifest manifest = ParseManifest("{ \"icons\": [ {\"src\": \"\","
638 "\"sizes\": \"42x42\" } ] }"); 622 "\"sizes\": \"42x42\" } ] }");
639 EXPECT_EQ(manifest.icons[0].sizes.size(), 1u); 623 EXPECT_EQ(manifest.icons[0].sizes.size(), 1u);
640 EXPECT_EQ(0u, GetErrorCount()); 624 EXPECT_EQ(0u, GetErrorCount());
641 } 625 }
642 626
643 // Trim whitespaces. 627 // Trim whitespaces.
644 { 628 {
645 Manifest manifest = ParseManifest("{ \"icons\": [ {\"src\": \"\"," 629 Manifest manifest = ParseManifest("{ \"icons\": [ {\"src\": \"\","
646 "\"sizes\": \" 42x42 \" } ] }"); 630 "\"sizes\": \" 42x42 \" } ] }");
647 EXPECT_EQ(manifest.icons[0].sizes.size(), 1u); 631 EXPECT_EQ(manifest.icons[0].sizes.size(), 1u);
648 EXPECT_EQ(0u, GetErrorCount()); 632 EXPECT_EQ(0u, GetErrorCount());
649 } 633 }
650 634
651 // Ignore sizes if property isn't a string. 635 // Ignore sizes if property isn't a string.
652 { 636 {
653 Manifest manifest = ParseManifest("{ \"icons\": [ {\"src\": \"\"," 637 Manifest manifest = ParseManifest("{ \"icons\": [ {\"src\": \"\","
654 "\"sizes\": {} } ] }"); 638 "\"sizes\": {} } ] }");
655 EXPECT_EQ(manifest.icons[0].sizes.size(), 0u); 639 EXPECT_EQ(manifest.icons[0].sizes.size(), 0u);
656 EXPECT_EQ(1u, GetErrorCount()); 640 EXPECT_EQ(1u, GetErrorCount());
657 EXPECT_EQ("Manifest parsing error: property 'sizes' ignored," 641 EXPECT_EQ("property 'sizes' ignored, type string expected.",
658 " type string expected.",
659 errors()[0]); 642 errors()[0]);
660 } 643 }
661 644
662 // Ignore sizes if property isn't a string. 645 // Ignore sizes if property isn't a string.
663 { 646 {
664 Manifest manifest = ParseManifest("{ \"icons\": [ {\"src\": \"\"," 647 Manifest manifest = ParseManifest("{ \"icons\": [ {\"src\": \"\","
665 "\"sizes\": 42 } ] }"); 648 "\"sizes\": 42 } ] }");
666 EXPECT_EQ(manifest.icons[0].sizes.size(), 0u); 649 EXPECT_EQ(manifest.icons[0].sizes.size(), 0u);
667 EXPECT_EQ(1u, GetErrorCount()); 650 EXPECT_EQ(1u, GetErrorCount());
668 EXPECT_EQ("Manifest parsing error: property 'sizes' ignored," 651 EXPECT_EQ("property 'sizes' ignored, type string expected.",
669 " type string expected.",
670 errors()[0]); 652 errors()[0]);
671 } 653 }
672 654
673 // Smoke test: value correctly parsed. 655 // Smoke test: value correctly parsed.
674 { 656 {
675 Manifest manifest = ParseManifest("{ \"icons\": [ {\"src\": \"\"," 657 Manifest manifest = ParseManifest("{ \"icons\": [ {\"src\": \"\","
676 "\"sizes\": \"42x42 48x48\" } ] }"); 658 "\"sizes\": \"42x42 48x48\" } ] }");
677 EXPECT_EQ(manifest.icons[0].sizes[0], gfx::Size(42, 42)); 659 EXPECT_EQ(manifest.icons[0].sizes[0], gfx::Size(42, 42));
678 EXPECT_EQ(manifest.icons[0].sizes[1], gfx::Size(48, 48)); 660 EXPECT_EQ(manifest.icons[0].sizes[1], gfx::Size(48, 48));
679 EXPECT_EQ(0u, GetErrorCount()); 661 EXPECT_EQ(0u, GetErrorCount());
(...skipping 16 matching lines...) Expand all
696 EXPECT_EQ(manifest.icons[0].sizes[1], gfx::Size(42, 42)); 678 EXPECT_EQ(manifest.icons[0].sizes[1], gfx::Size(42, 42));
697 EXPECT_EQ(0u, GetErrorCount()); 679 EXPECT_EQ(0u, GetErrorCount());
698 } 680 }
699 681
700 // Width or height can't start with 0. 682 // Width or height can't start with 0.
701 { 683 {
702 Manifest manifest = ParseManifest("{ \"icons\": [ {\"src\": \"\"," 684 Manifest manifest = ParseManifest("{ \"icons\": [ {\"src\": \"\","
703 "\"sizes\": \"004X007 042x00\" } ] }"); 685 "\"sizes\": \"004X007 042x00\" } ] }");
704 EXPECT_EQ(manifest.icons[0].sizes.size(), 0u); 686 EXPECT_EQ(manifest.icons[0].sizes.size(), 0u);
705 EXPECT_EQ(1u, GetErrorCount()); 687 EXPECT_EQ(1u, GetErrorCount());
706 EXPECT_EQ("Manifest parsing error: found icon with no valid size.", 688 EXPECT_EQ("found icon with no valid size.",
707 errors()[0]); 689 errors()[0]);
708 } 690 }
709 691
710 // Width and height MUST contain digits. 692 // Width and height MUST contain digits.
711 { 693 {
712 Manifest manifest = ParseManifest("{ \"icons\": [ {\"src\": \"\"," 694 Manifest manifest = ParseManifest("{ \"icons\": [ {\"src\": \"\","
713 "\"sizes\": \"e4X1.0 55ax1e10\" } ] }"); 695 "\"sizes\": \"e4X1.0 55ax1e10\" } ] }");
714 EXPECT_EQ(manifest.icons[0].sizes.size(), 0u); 696 EXPECT_EQ(manifest.icons[0].sizes.size(), 0u);
715 EXPECT_EQ(1u, GetErrorCount()); 697 EXPECT_EQ(1u, GetErrorCount());
716 EXPECT_EQ("Manifest parsing error: found icon with no valid size.", 698 EXPECT_EQ("found icon with no valid size.",
717 errors()[0]); 699 errors()[0]);
718 } 700 }
719 701
720 // 'any' is correctly parsed and transformed to gfx::Size(0,0). 702 // 'any' is correctly parsed and transformed to gfx::Size(0,0).
721 { 703 {
722 Manifest manifest = ParseManifest("{ \"icons\": [ {\"src\": \"\"," 704 Manifest manifest = ParseManifest("{ \"icons\": [ {\"src\": \"\","
723 "\"sizes\": \"any AnY ANY aNy\" } ] }"); 705 "\"sizes\": \"any AnY ANY aNy\" } ] }");
724 gfx::Size any = gfx::Size(0, 0); 706 gfx::Size any = gfx::Size(0, 0);
725 EXPECT_EQ(manifest.icons[0].sizes.size(), 4u); 707 EXPECT_EQ(manifest.icons[0].sizes.size(), 4u);
726 EXPECT_EQ(manifest.icons[0].sizes[0], any); 708 EXPECT_EQ(manifest.icons[0].sizes[0], any);
727 EXPECT_EQ(manifest.icons[0].sizes[1], any); 709 EXPECT_EQ(manifest.icons[0].sizes[1], any);
728 EXPECT_EQ(manifest.icons[0].sizes[2], any); 710 EXPECT_EQ(manifest.icons[0].sizes[2], any);
729 EXPECT_EQ(manifest.icons[0].sizes[3], any); 711 EXPECT_EQ(manifest.icons[0].sizes[3], any);
730 EXPECT_EQ(0u, GetErrorCount()); 712 EXPECT_EQ(0u, GetErrorCount());
731 } 713 }
732 714
733 // Some invalid width/height combinations. 715 // Some invalid width/height combinations.
734 { 716 {
735 Manifest manifest = ParseManifest("{ \"icons\": [ {\"src\": \"\"," 717 Manifest manifest = ParseManifest("{ \"icons\": [ {\"src\": \"\","
736 "\"sizes\": \"x 40xx 1x2x3 x42 42xx42\" } ] }"); 718 "\"sizes\": \"x 40xx 1x2x3 x42 42xx42\" } ] }");
737 gfx::Size any = gfx::Size(0, 0); 719 gfx::Size any = gfx::Size(0, 0);
738 EXPECT_EQ(manifest.icons[0].sizes.size(), 0u); 720 EXPECT_EQ(manifest.icons[0].sizes.size(), 0u);
739 EXPECT_EQ(1u, GetErrorCount()); 721 EXPECT_EQ(1u, GetErrorCount());
740 EXPECT_EQ("Manifest parsing error: found icon with no valid size.", 722 EXPECT_EQ("found icon with no valid size.",
741 errors()[0]); 723 errors()[0]);
742 } 724 }
743 } 725 }
744 726
745 TEST_F(ManifestParserTest, RelatedApplicationsParseRules) { 727 TEST_F(ManifestParserTest, RelatedApplicationsParseRules) {
746 // If no application, empty list. 728 // If no application, empty list.
747 { 729 {
748 Manifest manifest = ParseManifest( 730 Manifest manifest = ParseManifest(
749 "{ \"related_applications\": []}"); 731 "{ \"related_applications\": []}");
750 EXPECT_EQ(manifest.related_applications.size(), 0u); 732 EXPECT_EQ(manifest.related_applications.size(), 0u);
751 EXPECT_TRUE(manifest.IsEmpty()); 733 EXPECT_TRUE(manifest.IsEmpty());
752 EXPECT_EQ(0u, GetErrorCount()); 734 EXPECT_EQ(0u, GetErrorCount());
753 } 735 }
754 736
755 // If empty application, empty list. 737 // If empty application, empty list.
756 { 738 {
757 Manifest manifest = ParseManifest( 739 Manifest manifest = ParseManifest(
758 "{ \"related_applications\": [{}]}"); 740 "{ \"related_applications\": [{}]}");
759 EXPECT_EQ(manifest.related_applications.size(), 0u); 741 EXPECT_EQ(manifest.related_applications.size(), 0u);
760 EXPECT_TRUE(manifest.IsEmpty()); 742 EXPECT_TRUE(manifest.IsEmpty());
761 EXPECT_EQ(1u, GetErrorCount()); 743 EXPECT_EQ(1u, GetErrorCount());
762 EXPECT_EQ("Manifest parsing error: 'platform' is a required field, " 744 EXPECT_EQ("'platform' is a required field, related application ignored.",
763 "related application ignored.",
764 errors()[0]); 745 errors()[0]);
765 } 746 }
766 747
767 // If invalid platform, application is ignored. 748 // If invalid platform, application is ignored.
768 { 749 {
769 Manifest manifest = ParseManifest( 750 Manifest manifest = ParseManifest(
770 "{ \"related_applications\": [{\"platform\": 123}]}"); 751 "{ \"related_applications\": [{\"platform\": 123}]}");
771 EXPECT_EQ(manifest.related_applications.size(), 0u); 752 EXPECT_EQ(manifest.related_applications.size(), 0u);
772 EXPECT_TRUE(manifest.IsEmpty()); 753 EXPECT_TRUE(manifest.IsEmpty());
773 EXPECT_EQ(2u, GetErrorCount()); 754 EXPECT_EQ(2u, GetErrorCount());
774 EXPECT_EQ( 755 EXPECT_EQ(
775 "Manifest parsing error: property 'platform' ignored, type string " 756 "property 'platform' ignored, type string expected.",
776 "expected.",
777 errors()[0]); 757 errors()[0]);
778 EXPECT_EQ("Manifest parsing error: 'platform' is a required field, " 758 EXPECT_EQ("'platform' is a required field, "
779 "related application ignored.", 759 "related application ignored.",
780 errors()[1]); 760 errors()[1]);
781 } 761 }
782 762
783 // If missing platform, application is ignored. 763 // If missing platform, application is ignored.
784 { 764 {
785 Manifest manifest = ParseManifest( 765 Manifest manifest = ParseManifest(
786 "{ \"related_applications\": [{\"id\": \"foo\"}]}"); 766 "{ \"related_applications\": [{\"id\": \"foo\"}]}");
787 EXPECT_EQ(manifest.related_applications.size(), 0u); 767 EXPECT_EQ(manifest.related_applications.size(), 0u);
788 EXPECT_TRUE(manifest.IsEmpty()); 768 EXPECT_TRUE(manifest.IsEmpty());
789 EXPECT_EQ(1u, GetErrorCount()); 769 EXPECT_EQ(1u, GetErrorCount());
790 EXPECT_EQ("Manifest parsing error: 'platform' is a required field, " 770 EXPECT_EQ("'platform' is a required field, related application ignored.",
791 "related application ignored.",
792 errors()[0]); 771 errors()[0]);
793 } 772 }
794 773
795 // If missing id and url, application is ignored. 774 // If missing id and url, application is ignored.
796 { 775 {
797 Manifest manifest = ParseManifest( 776 Manifest manifest = ParseManifest(
798 "{ \"related_applications\": [{\"platform\": \"play\"}]}"); 777 "{ \"related_applications\": [{\"platform\": \"play\"}]}");
799 EXPECT_EQ(manifest.related_applications.size(), 0u); 778 EXPECT_EQ(manifest.related_applications.size(), 0u);
800 EXPECT_TRUE(manifest.IsEmpty()); 779 EXPECT_TRUE(manifest.IsEmpty());
801 EXPECT_EQ(1u, GetErrorCount()); 780 EXPECT_EQ(1u, GetErrorCount());
802 EXPECT_EQ("Manifest parsing error: one of 'url' or 'id' is required, " 781 EXPECT_EQ("one of 'url' or 'id' is required, related application ignored.",
803 "related application ignored.",
804 errors()[0]); 782 errors()[0]);
805 } 783 }
806 784
807 // Valid application, with url. 785 // Valid application, with url.
808 { 786 {
809 Manifest manifest = ParseManifest( 787 Manifest manifest = ParseManifest(
810 "{ \"related_applications\": [" 788 "{ \"related_applications\": ["
811 "{\"platform\": \"play\", \"url\": \"http://www.foo.com\"}]}"); 789 "{\"platform\": \"play\", \"url\": \"http://www.foo.com\"}]}");
812 EXPECT_EQ(manifest.related_applications.size(), 1u); 790 EXPECT_EQ(manifest.related_applications.size(), 1u);
813 EXPECT_TRUE(base::EqualsASCII( 791 EXPECT_TRUE(base::EqualsASCII(
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 "{\"platform\": \"play\", \"id\": \"foo\"}," 842 "{\"platform\": \"play\", \"id\": \"foo\"},"
865 "{}]}"); 843 "{}]}");
866 EXPECT_EQ(manifest.related_applications.size(), 1u); 844 EXPECT_EQ(manifest.related_applications.size(), 1u);
867 EXPECT_TRUE(base::EqualsASCII( 845 EXPECT_TRUE(base::EqualsASCII(
868 manifest.related_applications[0].platform.string(), 846 manifest.related_applications[0].platform.string(),
869 "play")); 847 "play"));
870 EXPECT_TRUE(base::EqualsASCII(manifest.related_applications[0].id.string(), 848 EXPECT_TRUE(base::EqualsASCII(manifest.related_applications[0].id.string(),
871 "foo")); 849 "foo"));
872 EXPECT_FALSE(manifest.IsEmpty()); 850 EXPECT_FALSE(manifest.IsEmpty());
873 EXPECT_EQ(2u, GetErrorCount()); 851 EXPECT_EQ(2u, GetErrorCount());
874 EXPECT_EQ("Manifest parsing error: one of 'url' or 'id' is required, " 852 EXPECT_EQ("one of 'url' or 'id' is required, related application ignored.",
875 "related application ignored.",
876 errors()[0]); 853 errors()[0]);
877 EXPECT_EQ("Manifest parsing error: 'platform' is a required field, " 854 EXPECT_EQ("'platform' is a required field, related application ignored.",
878 "related application ignored.",
879 errors()[1]); 855 errors()[1]);
880 } 856 }
881 } 857 }
882 858
883 TEST_F(ManifestParserTest, ParsePreferRelatedApplicationsParseRules) { 859 TEST_F(ManifestParserTest, ParsePreferRelatedApplicationsParseRules) {
884 // Smoke test. 860 // Smoke test.
885 { 861 {
886 Manifest manifest = 862 Manifest manifest =
887 ParseManifest("{ \"prefer_related_applications\": true }"); 863 ParseManifest("{ \"prefer_related_applications\": true }");
888 EXPECT_TRUE(manifest.prefer_related_applications); 864 EXPECT_TRUE(manifest.prefer_related_applications);
889 EXPECT_EQ(0u, GetErrorCount()); 865 EXPECT_EQ(0u, GetErrorCount());
890 } 866 }
891 867
892 // Don't parse if the property isn't a boolean. 868 // Don't parse if the property isn't a boolean.
893 { 869 {
894 Manifest manifest = 870 Manifest manifest =
895 ParseManifest("{ \"prefer_related_applications\": {} }"); 871 ParseManifest("{ \"prefer_related_applications\": {} }");
896 EXPECT_FALSE(manifest.prefer_related_applications); 872 EXPECT_FALSE(manifest.prefer_related_applications);
897 EXPECT_EQ(1u, GetErrorCount()); 873 EXPECT_EQ(1u, GetErrorCount());
898 EXPECT_EQ( 874 EXPECT_EQ(
899 "Manifest parsing error: property 'prefer_related_applications' " 875 "property 'prefer_related_applications' "
900 "ignored, type boolean expected.", 876 "ignored, type boolean expected.",
901 errors()[0]); 877 errors()[0]);
902 } 878 }
903 { 879 {
904 Manifest manifest = ParseManifest( 880 Manifest manifest = ParseManifest(
905 "{ \"prefer_related_applications\": \"true\" }"); 881 "{ \"prefer_related_applications\": \"true\" }");
906 EXPECT_FALSE(manifest.prefer_related_applications); 882 EXPECT_FALSE(manifest.prefer_related_applications);
907 EXPECT_EQ(1u, GetErrorCount()); 883 EXPECT_EQ(1u, GetErrorCount());
908 EXPECT_EQ( 884 EXPECT_EQ(
909 "Manifest parsing error: property 'prefer_related_applications' " 885 "property 'prefer_related_applications' "
910 "ignored, type boolean expected.", 886 "ignored, type boolean expected.",
911 errors()[0]); 887 errors()[0]);
912 } 888 }
913 { 889 {
914 Manifest manifest = ParseManifest("{ \"prefer_related_applications\": 1 }"); 890 Manifest manifest = ParseManifest("{ \"prefer_related_applications\": 1 }");
915 EXPECT_FALSE(manifest.prefer_related_applications); 891 EXPECT_FALSE(manifest.prefer_related_applications);
916 EXPECT_EQ(1u, GetErrorCount()); 892 EXPECT_EQ(1u, GetErrorCount());
917 EXPECT_EQ( 893 EXPECT_EQ(
918 "Manifest parsing error: property 'prefer_related_applications' " 894 "property 'prefer_related_applications' "
919 "ignored, type boolean expected.", 895 "ignored, type boolean expected.",
920 errors()[0]); 896 errors()[0]);
921 } 897 }
922 898
923 // "False" should set the boolean false without throwing errors. 899 // "False" should set the boolean false without throwing errors.
924 { 900 {
925 Manifest manifest = 901 Manifest manifest =
926 ParseManifest("{ \"prefer_related_applications\": false }"); 902 ParseManifest("{ \"prefer_related_applications\": false }");
927 EXPECT_FALSE(manifest.prefer_related_applications); 903 EXPECT_FALSE(manifest.prefer_related_applications);
928 EXPECT_EQ(0u, GetErrorCount()); 904 EXPECT_EQ(0u, GetErrorCount());
(...skipping 14 matching lines...) Expand all
943 Manifest manifest = ParseManifest("{ \"theme_color\": \" blue \" }"); 919 Manifest manifest = ParseManifest("{ \"theme_color\": \" blue \" }");
944 EXPECT_EQ(ExtractColor(manifest.theme_color), 0xFF0000FFu); 920 EXPECT_EQ(ExtractColor(manifest.theme_color), 0xFF0000FFu);
945 EXPECT_EQ(0u, GetErrorCount()); 921 EXPECT_EQ(0u, GetErrorCount());
946 } 922 }
947 923
948 // Don't parse if theme_color isn't a string. 924 // Don't parse if theme_color isn't a string.
949 { 925 {
950 Manifest manifest = ParseManifest("{ \"theme_color\": {} }"); 926 Manifest manifest = ParseManifest("{ \"theme_color\": {} }");
951 EXPECT_EQ(manifest.theme_color, Manifest::kInvalidOrMissingColor); 927 EXPECT_EQ(manifest.theme_color, Manifest::kInvalidOrMissingColor);
952 EXPECT_EQ(1u, GetErrorCount()); 928 EXPECT_EQ(1u, GetErrorCount());
953 EXPECT_EQ("Manifest parsing error: property 'theme_color' ignored," 929 EXPECT_EQ("property 'theme_color' ignored, type string expected.",
954 " type string expected.",
955 errors()[0]); 930 errors()[0]);
956 } 931 }
957 932
958 // Don't parse if theme_color isn't a string. 933 // Don't parse if theme_color isn't a string.
959 { 934 {
960 Manifest manifest = ParseManifest("{ \"theme_color\": false }"); 935 Manifest manifest = ParseManifest("{ \"theme_color\": false }");
961 EXPECT_EQ(manifest.theme_color, Manifest::kInvalidOrMissingColor); 936 EXPECT_EQ(manifest.theme_color, Manifest::kInvalidOrMissingColor);
962 EXPECT_EQ(1u, GetErrorCount()); 937 EXPECT_EQ(1u, GetErrorCount());
963 EXPECT_EQ("Manifest parsing error: property 'theme_color' ignored," 938 EXPECT_EQ("property 'theme_color' ignored, type string expected.",
964 " type string expected.",
965 errors()[0]); 939 errors()[0]);
966 } 940 }
967 941
968 // Don't parse if theme_color isn't a string. 942 // Don't parse if theme_color isn't a string.
969 { 943 {
970 Manifest manifest = ParseManifest("{ \"theme_color\": null }"); 944 Manifest manifest = ParseManifest("{ \"theme_color\": null }");
971 EXPECT_EQ(manifest.theme_color, Manifest::kInvalidOrMissingColor); 945 EXPECT_EQ(manifest.theme_color, Manifest::kInvalidOrMissingColor);
972 EXPECT_EQ(1u, GetErrorCount()); 946 EXPECT_EQ(1u, GetErrorCount());
973 EXPECT_EQ("Manifest parsing error: property 'theme_color' ignored," 947 EXPECT_EQ("property 'theme_color' ignored, type string expected.",
974 " type string expected.",
975 errors()[0]); 948 errors()[0]);
976 } 949 }
977 950
978 // Don't parse if theme_color isn't a string. 951 // Don't parse if theme_color isn't a string.
979 { 952 {
980 Manifest manifest = ParseManifest("{ \"theme_color\": [] }"); 953 Manifest manifest = ParseManifest("{ \"theme_color\": [] }");
981 EXPECT_EQ(manifest.theme_color, Manifest::kInvalidOrMissingColor); 954 EXPECT_EQ(manifest.theme_color, Manifest::kInvalidOrMissingColor);
982 EXPECT_EQ(1u, GetErrorCount()); 955 EXPECT_EQ(1u, GetErrorCount());
983 EXPECT_EQ("Manifest parsing error: property 'theme_color' ignored," 956 EXPECT_EQ("property 'theme_color' ignored, type string expected.",
984 " type string expected.",
985 errors()[0]); 957 errors()[0]);
986 } 958 }
987 959
988 // Don't parse if theme_color isn't a string. 960 // Don't parse if theme_color isn't a string.
989 { 961 {
990 Manifest manifest = ParseManifest("{ \"theme_color\": 42 }"); 962 Manifest manifest = ParseManifest("{ \"theme_color\": 42 }");
991 EXPECT_EQ(manifest.theme_color, Manifest::kInvalidOrMissingColor); 963 EXPECT_EQ(manifest.theme_color, Manifest::kInvalidOrMissingColor);
992 EXPECT_EQ(1u, GetErrorCount()); 964 EXPECT_EQ(1u, GetErrorCount());
993 EXPECT_EQ("Manifest parsing error: property 'theme_color' ignored," 965 EXPECT_EQ("property 'theme_color' ignored, type string expected.",
994 " type string expected.",
995 errors()[0]); 966 errors()[0]);
996 } 967 }
997 968
998 // Parse fails if string is not in a known format. 969 // Parse fails if string is not in a known format.
999 { 970 {
1000 Manifest manifest = ParseManifest("{ \"theme_color\": \"foo(bar)\" }"); 971 Manifest manifest = ParseManifest("{ \"theme_color\": \"foo(bar)\" }");
1001 EXPECT_EQ(manifest.theme_color, Manifest::kInvalidOrMissingColor); 972 EXPECT_EQ(manifest.theme_color, Manifest::kInvalidOrMissingColor);
1002 EXPECT_EQ(1u, GetErrorCount()); 973 EXPECT_EQ(1u, GetErrorCount());
1003 EXPECT_EQ("Manifest parsing error: property 'theme_color' ignored," 974 EXPECT_EQ("property 'theme_color' ignored,"
1004 " 'foo(bar)' is not a valid color.", 975 " 'foo(bar)' is not a valid color.",
1005 errors()[0]); 976 errors()[0]);
1006 } 977 }
1007 978
1008 // Parse fails if string is not in a known format. 979 // Parse fails if string is not in a known format.
1009 { 980 {
1010 Manifest manifest = ParseManifest("{ \"theme_color\": \"bleu\" }"); 981 Manifest manifest = ParseManifest("{ \"theme_color\": \"bleu\" }");
1011 EXPECT_EQ(manifest.theme_color, Manifest::kInvalidOrMissingColor); 982 EXPECT_EQ(manifest.theme_color, Manifest::kInvalidOrMissingColor);
1012 EXPECT_EQ(1u, GetErrorCount()); 983 EXPECT_EQ(1u, GetErrorCount());
1013 EXPECT_EQ("Manifest parsing error: property 'theme_color' ignored, 'bleu'" 984 EXPECT_EQ("property 'theme_color' ignored, 'bleu' is not a valid color.",
1014 " is not a valid color.",
1015 errors()[0]); 985 errors()[0]);
1016 } 986 }
1017 987
1018 // Parse fails if string is not in a known format. 988 // Parse fails if string is not in a known format.
1019 { 989 {
1020 Manifest manifest = ParseManifest("{ \"theme_color\": \"FF00FF\" }"); 990 Manifest manifest = ParseManifest("{ \"theme_color\": \"FF00FF\" }");
1021 EXPECT_EQ(manifest.theme_color, Manifest::kInvalidOrMissingColor); 991 EXPECT_EQ(manifest.theme_color, Manifest::kInvalidOrMissingColor);
1022 EXPECT_EQ(1u, GetErrorCount()); 992 EXPECT_EQ(1u, GetErrorCount());
1023 EXPECT_EQ("Manifest parsing error: property 'theme_color' ignored, 'FF00FF'" 993 EXPECT_EQ("property 'theme_color' ignored, 'FF00FF'"
1024 " is not a valid color.", 994 " is not a valid color.",
1025 errors()[0]); 995 errors()[0]);
1026 } 996 }
1027 997
1028 // Parse fails if multiple values for theme_color are given. 998 // Parse fails if multiple values for theme_color are given.
1029 { 999 {
1030 Manifest manifest = ParseManifest("{ \"theme_color\": \"#ABC #DEF\" }"); 1000 Manifest manifest = ParseManifest("{ \"theme_color\": \"#ABC #DEF\" }");
1031 EXPECT_EQ(manifest.theme_color, Manifest::kInvalidOrMissingColor); 1001 EXPECT_EQ(manifest.theme_color, Manifest::kInvalidOrMissingColor);
1032 EXPECT_EQ(1u, GetErrorCount()); 1002 EXPECT_EQ(1u, GetErrorCount());
1033 EXPECT_EQ("Manifest parsing error: property 'theme_color' ignored, " 1003 EXPECT_EQ("property 'theme_color' ignored, "
1034 "'#ABC #DEF' is not a valid color.", 1004 "'#ABC #DEF' is not a valid color.",
1035 errors()[0]); 1005 errors()[0]);
1036 } 1006 }
1037 1007
1038 // Parse fails if multiple values for theme_color are given. 1008 // Parse fails if multiple values for theme_color are given.
1039 { 1009 {
1040 Manifest manifest = ParseManifest( 1010 Manifest manifest = ParseManifest(
1041 "{ \"theme_color\": \"#AABBCC #DDEEFF\" }"); 1011 "{ \"theme_color\": \"#AABBCC #DDEEFF\" }");
1042 EXPECT_EQ(manifest.theme_color, Manifest::kInvalidOrMissingColor); 1012 EXPECT_EQ(manifest.theme_color, Manifest::kInvalidOrMissingColor);
1043 EXPECT_EQ(1u, GetErrorCount()); 1013 EXPECT_EQ(1u, GetErrorCount());
1044 EXPECT_EQ("Manifest parsing error: property 'theme_color' ignored, " 1014 EXPECT_EQ("property 'theme_color' ignored, "
1045 "'#AABBCC #DDEEFF' is not a valid color.", 1015 "'#AABBCC #DDEEFF' is not a valid color.",
1046 errors()[0]); 1016 errors()[0]);
1047 } 1017 }
1048 1018
1049 // Accept CSS color keyword format. 1019 // Accept CSS color keyword format.
1050 { 1020 {
1051 Manifest manifest = ParseManifest("{ \"theme_color\": \"blue\" }"); 1021 Manifest manifest = ParseManifest("{ \"theme_color\": \"blue\" }");
1052 EXPECT_EQ(ExtractColor(manifest.theme_color), 0xFF0000FFu); 1022 EXPECT_EQ(ExtractColor(manifest.theme_color), 0xFF0000FFu);
1053 EXPECT_EQ(0u, GetErrorCount()); 1023 EXPECT_EQ(0u, GetErrorCount());
1054 } 1024 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 "{ \"background_color\": \" blue \" }"); 1082 "{ \"background_color\": \" blue \" }");
1113 EXPECT_EQ(ExtractColor(manifest.background_color), 0xFF0000FFu); 1083 EXPECT_EQ(ExtractColor(manifest.background_color), 0xFF0000FFu);
1114 EXPECT_EQ(0u, GetErrorCount()); 1084 EXPECT_EQ(0u, GetErrorCount());
1115 } 1085 }
1116 1086
1117 // Don't parse if background_color isn't a string. 1087 // Don't parse if background_color isn't a string.
1118 { 1088 {
1119 Manifest manifest = ParseManifest("{ \"background_color\": {} }"); 1089 Manifest manifest = ParseManifest("{ \"background_color\": {} }");
1120 EXPECT_EQ(manifest.background_color, Manifest::kInvalidOrMissingColor); 1090 EXPECT_EQ(manifest.background_color, Manifest::kInvalidOrMissingColor);
1121 EXPECT_EQ(1u, GetErrorCount()); 1091 EXPECT_EQ(1u, GetErrorCount());
1122 EXPECT_EQ("Manifest parsing error: property 'background_color' ignored," 1092 EXPECT_EQ("property 'background_color' ignored, type string expected.",
1123 " type string expected.",
1124 errors()[0]); 1093 errors()[0]);
1125 } 1094 }
1126 1095
1127 // Don't parse if background_color isn't a string. 1096 // Don't parse if background_color isn't a string.
1128 { 1097 {
1129 Manifest manifest = ParseManifest("{ \"background_color\": false }"); 1098 Manifest manifest = ParseManifest("{ \"background_color\": false }");
1130 EXPECT_EQ(manifest.background_color, Manifest::kInvalidOrMissingColor); 1099 EXPECT_EQ(manifest.background_color, Manifest::kInvalidOrMissingColor);
1131 EXPECT_EQ(1u, GetErrorCount()); 1100 EXPECT_EQ(1u, GetErrorCount());
1132 EXPECT_EQ("Manifest parsing error: property 'background_color' ignored," 1101 EXPECT_EQ("property 'background_color' ignored, type string expected.",
1133 " type string expected.",
1134 errors()[0]); 1102 errors()[0]);
1135 } 1103 }
1136 1104
1137 // Don't parse if background_color isn't a string. 1105 // Don't parse if background_color isn't a string.
1138 { 1106 {
1139 Manifest manifest = ParseManifest("{ \"background_color\": null }"); 1107 Manifest manifest = ParseManifest("{ \"background_color\": null }");
1140 EXPECT_EQ(manifest.background_color, Manifest::kInvalidOrMissingColor); 1108 EXPECT_EQ(manifest.background_color, Manifest::kInvalidOrMissingColor);
1141 EXPECT_EQ(1u, GetErrorCount()); 1109 EXPECT_EQ(1u, GetErrorCount());
1142 EXPECT_EQ("Manifest parsing error: property 'background_color' ignored," 1110 EXPECT_EQ("property 'background_color' ignored, type string expected.",
1143 " type string expected.",
1144 errors()[0]); 1111 errors()[0]);
1145 } 1112 }
1146 1113
1147 // Don't parse if background_color isn't a string. 1114 // Don't parse if background_color isn't a string.
1148 { 1115 {
1149 Manifest manifest = ParseManifest("{ \"background_color\": [] }"); 1116 Manifest manifest = ParseManifest("{ \"background_color\": [] }");
1150 EXPECT_EQ(manifest.background_color, Manifest::kInvalidOrMissingColor); 1117 EXPECT_EQ(manifest.background_color, Manifest::kInvalidOrMissingColor);
1151 EXPECT_EQ(1u, GetErrorCount()); 1118 EXPECT_EQ(1u, GetErrorCount());
1152 EXPECT_EQ("Manifest parsing error: property 'background_color' ignored," 1119 EXPECT_EQ("property 'background_color' ignored, type string expected.",
1153 " type string expected.",
1154 errors()[0]); 1120 errors()[0]);
1155 } 1121 }
1156 1122
1157 // Don't parse if background_color isn't a string. 1123 // Don't parse if background_color isn't a string.
1158 { 1124 {
1159 Manifest manifest = ParseManifest("{ \"background_color\": 42 }"); 1125 Manifest manifest = ParseManifest("{ \"background_color\": 42 }");
1160 EXPECT_EQ(manifest.background_color, Manifest::kInvalidOrMissingColor); 1126 EXPECT_EQ(manifest.background_color, Manifest::kInvalidOrMissingColor);
1161 EXPECT_EQ(1u, GetErrorCount()); 1127 EXPECT_EQ(1u, GetErrorCount());
1162 EXPECT_EQ("Manifest parsing error: property 'background_color' ignored," 1128 EXPECT_EQ("property 'background_color' ignored, type string expected.",
1163 " type string expected.",
1164 errors()[0]); 1129 errors()[0]);
1165 } 1130 }
1166 1131
1167 // Parse fails if string is not in a known format. 1132 // Parse fails if string is not in a known format.
1168 { 1133 {
1169 Manifest manifest = ParseManifest("{ \"background_color\": \"foo(bar)\" }"); 1134 Manifest manifest = ParseManifest("{ \"background_color\": \"foo(bar)\" }");
1170 EXPECT_EQ(manifest.background_color, Manifest::kInvalidOrMissingColor); 1135 EXPECT_EQ(manifest.background_color, Manifest::kInvalidOrMissingColor);
1171 EXPECT_EQ(1u, GetErrorCount()); 1136 EXPECT_EQ(1u, GetErrorCount());
1172 EXPECT_EQ("Manifest parsing error: property 'background_color' ignored," 1137 EXPECT_EQ("property 'background_color' ignored,"
1173 " 'foo(bar)' is not a valid color.", 1138 " 'foo(bar)' is not a valid color.",
1174 errors()[0]); 1139 errors()[0]);
1175 } 1140 }
1176 1141
1177 // Parse fails if string is not in a known format. 1142 // Parse fails if string is not in a known format.
1178 { 1143 {
1179 Manifest manifest = ParseManifest("{ \"background_color\": \"bleu\" }"); 1144 Manifest manifest = ParseManifest("{ \"background_color\": \"bleu\" }");
1180 EXPECT_EQ(manifest.background_color, Manifest::kInvalidOrMissingColor); 1145 EXPECT_EQ(manifest.background_color, Manifest::kInvalidOrMissingColor);
1181 EXPECT_EQ(1u, GetErrorCount()); 1146 EXPECT_EQ(1u, GetErrorCount());
1182 EXPECT_EQ("Manifest parsing error: property 'background_color' ignored," 1147 EXPECT_EQ("property 'background_color' ignored,"
1183 " 'bleu' is not a valid color.", 1148 " 'bleu' is not a valid color.",
1184 errors()[0]); 1149 errors()[0]);
1185 } 1150 }
1186 1151
1187 // Parse fails if string is not in a known format. 1152 // Parse fails if string is not in a known format.
1188 { 1153 {
1189 Manifest manifest = ParseManifest("{ \"background_color\": \"FF00FF\" }"); 1154 Manifest manifest = ParseManifest("{ \"background_color\": \"FF00FF\" }");
1190 EXPECT_EQ(manifest.background_color, Manifest::kInvalidOrMissingColor); 1155 EXPECT_EQ(manifest.background_color, Manifest::kInvalidOrMissingColor);
1191 EXPECT_EQ(1u, GetErrorCount()); 1156 EXPECT_EQ(1u, GetErrorCount());
1192 EXPECT_EQ("Manifest parsing error: property 'background_color' ignored," 1157 EXPECT_EQ("property 'background_color' ignored,"
1193 " 'FF00FF' is not a valid color.", 1158 " 'FF00FF' is not a valid color.",
1194 errors()[0]); 1159 errors()[0]);
1195 } 1160 }
1196 1161
1197 // Parse fails if multiple values for background_color are given. 1162 // Parse fails if multiple values for background_color are given.
1198 { 1163 {
1199 Manifest manifest = ParseManifest( 1164 Manifest manifest = ParseManifest(
1200 "{ \"background_color\": \"#ABC #DEF\" }"); 1165 "{ \"background_color\": \"#ABC #DEF\" }");
1201 EXPECT_EQ(manifest.background_color, Manifest::kInvalidOrMissingColor); 1166 EXPECT_EQ(manifest.background_color, Manifest::kInvalidOrMissingColor);
1202 EXPECT_EQ(1u, GetErrorCount()); 1167 EXPECT_EQ(1u, GetErrorCount());
1203 EXPECT_EQ("Manifest parsing error: property 'background_color' ignored, " 1168 EXPECT_EQ("property 'background_color' ignored, "
1204 "'#ABC #DEF' is not a valid color.", 1169 "'#ABC #DEF' is not a valid color.",
1205 errors()[0]); 1170 errors()[0]);
1206 } 1171 }
1207 1172
1208 // Parse fails if multiple values for background_color are given. 1173 // Parse fails if multiple values for background_color are given.
1209 { 1174 {
1210 Manifest manifest = ParseManifest( 1175 Manifest manifest = ParseManifest(
1211 "{ \"background_color\": \"#AABBCC #DDEEFF\" }"); 1176 "{ \"background_color\": \"#AABBCC #DDEEFF\" }");
1212 EXPECT_EQ(manifest.background_color, Manifest::kInvalidOrMissingColor); 1177 EXPECT_EQ(manifest.background_color, Manifest::kInvalidOrMissingColor);
1213 EXPECT_EQ(1u, GetErrorCount()); 1178 EXPECT_EQ(1u, GetErrorCount());
1214 EXPECT_EQ("Manifest parsing error: property 'background_color' ignored, " 1179 EXPECT_EQ("property 'background_color' ignored, "
1215 "'#AABBCC #DDEEFF' is not a valid color.", 1180 "'#AABBCC #DDEEFF' is not a valid color.",
1216 errors()[0]); 1181 errors()[0]);
1217 } 1182 }
1218 1183
1219 // Accept CSS color keyword format. 1184 // Accept CSS color keyword format.
1220 { 1185 {
1221 Manifest manifest = ParseManifest("{ \"background_color\": \"blue\" }"); 1186 Manifest manifest = ParseManifest("{ \"background_color\": \"blue\" }");
1222 EXPECT_EQ(ExtractColor(manifest.background_color), 0xFF0000FFu); 1187 EXPECT_EQ(ExtractColor(manifest.background_color), 0xFF0000FFu);
1223 EXPECT_EQ(0u, GetErrorCount()); 1188 EXPECT_EQ(0u, GetErrorCount());
1224 } 1189 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 Manifest manifest = ParseManifest("{ \"gcm_sender_id\": \" foo \" }"); 1247 Manifest manifest = ParseManifest("{ \"gcm_sender_id\": \" foo \" }");
1283 EXPECT_TRUE(base::EqualsASCII(manifest.gcm_sender_id.string(), "foo")); 1248 EXPECT_TRUE(base::EqualsASCII(manifest.gcm_sender_id.string(), "foo"));
1284 EXPECT_EQ(0u, GetErrorCount()); 1249 EXPECT_EQ(0u, GetErrorCount());
1285 } 1250 }
1286 1251
1287 // Don't parse if the property isn't a string. 1252 // Don't parse if the property isn't a string.
1288 { 1253 {
1289 Manifest manifest = ParseManifest("{ \"gcm_sender_id\": {} }"); 1254 Manifest manifest = ParseManifest("{ \"gcm_sender_id\": {} }");
1290 EXPECT_TRUE(manifest.gcm_sender_id.is_null()); 1255 EXPECT_TRUE(manifest.gcm_sender_id.is_null());
1291 EXPECT_EQ(1u, GetErrorCount()); 1256 EXPECT_EQ(1u, GetErrorCount());
1292 EXPECT_EQ("Manifest parsing error: property 'gcm_sender_id' ignored," 1257 EXPECT_EQ("property 'gcm_sender_id' ignored, type string expected.",
1293 " type string expected.",
1294 errors()[0]); 1258 errors()[0]);
1295 } 1259 }
1296 { 1260 {
1297 Manifest manifest = ParseManifest("{ \"gcm_sender_id\": 42 }"); 1261 Manifest manifest = ParseManifest("{ \"gcm_sender_id\": 42 }");
1298 EXPECT_TRUE(manifest.gcm_sender_id.is_null()); 1262 EXPECT_TRUE(manifest.gcm_sender_id.is_null());
1299 EXPECT_EQ(1u, GetErrorCount()); 1263 EXPECT_EQ(1u, GetErrorCount());
1300 EXPECT_EQ("Manifest parsing error: property 'gcm_sender_id' ignored," 1264 EXPECT_EQ("property 'gcm_sender_id' ignored, type string expected.",
1301 " type string expected.",
1302 errors()[0]); 1265 errors()[0]);
1303 } 1266 }
1304 } 1267 }
1305 1268
1306 } // namespace content 1269 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/manifest/manifest_parser.cc ('k') | content/renderer/push_messaging/push_messaging_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698