OLD | NEW |
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 "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 class ManifestParserTest : public testing::Test { | 24 class ManifestParserTest : public testing::Test { |
25 protected: | 25 protected: |
26 ManifestParserTest() {} | 26 ManifestParserTest() {} |
27 ~ManifestParserTest() override {} | 27 ~ManifestParserTest() override {} |
28 | 28 |
29 Manifest ParseManifestWithURLs(const base::StringPiece& data, | 29 Manifest ParseManifestWithURLs(const base::StringPiece& data, |
30 const GURL& document_url, | 30 const GURL& document_url, |
31 const GURL& manifest_url) { | 31 const GURL& manifest_url) { |
32 ManifestParser parser(data, document_url, manifest_url); | 32 ManifestParser parser(data, document_url, manifest_url); |
33 parser.Parse(); | 33 parser.Parse(); |
34 errors_ = parser.errors(); | 34 errors_.clear(); |
| 35 for (const scoped_ptr<ManifestParser::ErrorInfo>& error_info : |
| 36 parser.errors()) { |
| 37 errors_.push_back(error_info->error_msg); |
| 38 } |
35 return parser.manifest(); | 39 return parser.manifest(); |
36 } | 40 } |
37 | 41 |
38 Manifest ParseManifest(const base::StringPiece& data) { | 42 Manifest ParseManifest(const base::StringPiece& data) { |
39 return ParseManifestWithURLs( | 43 return ParseManifestWithURLs( |
40 data, default_document_url, default_manifest_url); | 44 data, default_document_url, default_manifest_url); |
41 } | 45 } |
42 | 46 |
43 const std::vector<std::string>& errors() const { | 47 const std::vector<std::string>& errors() const { |
44 return errors_; | 48 return errors_; |
(...skipping 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1369 Manifest manifest = ParseManifest("{ \"gcm_sender_id\": 42 }"); | 1373 Manifest manifest = ParseManifest("{ \"gcm_sender_id\": 42 }"); |
1370 EXPECT_TRUE(manifest.gcm_sender_id.is_null()); | 1374 EXPECT_TRUE(manifest.gcm_sender_id.is_null()); |
1371 EXPECT_EQ(1u, GetErrorCount()); | 1375 EXPECT_EQ(1u, GetErrorCount()); |
1372 EXPECT_EQ("Manifest parsing error: property 'gcm_sender_id' ignored," | 1376 EXPECT_EQ("Manifest parsing error: property 'gcm_sender_id' ignored," |
1373 " type string expected.", | 1377 " type string expected.", |
1374 errors()[0]); | 1378 errors()[0]); |
1375 } | 1379 } |
1376 } | 1380 } |
1377 | 1381 |
1378 } // namespace content | 1382 } // namespace content |
OLD | NEW |