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 "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "content/public/common/manifest.h" | 8 #include "content/public/common/manifest.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 std::vector<std::string> errors_; | 44 std::vector<std::string> errors_; |
45 | 45 |
46 DISALLOW_COPY_AND_ASSIGN(ManifestParserTest); | 46 DISALLOW_COPY_AND_ASSIGN(ManifestParserTest); |
47 }; | 47 }; |
48 | 48 |
49 const GURL ManifestParserTest::default_document_url( | 49 const GURL ManifestParserTest::default_document_url( |
50 "http://foo.com/index.html"); | 50 "http://foo.com/index.html"); |
51 const GURL ManifestParserTest::default_manifest_url( | 51 const GURL ManifestParserTest::default_manifest_url( |
52 "http://foo.com/manifest.json"); | 52 "http://foo.com/manifest.json"); |
53 | 53 |
| 54 TEST_F(ManifestParserTest, CrashTest) { |
| 55 // Passing temporary variables should not crash. |
| 56 ManifestParser parser("{\"start_url\": \"/\"}", |
| 57 GURL("http://example.com"), |
| 58 GURL("http://example.com")); |
| 59 parser.Parse(); |
| 60 |
| 61 // .Parse() should have been call without crashing and succeeded. |
| 62 EXPECT_EQ(0u, parser.errors().size()); |
| 63 EXPECT_FALSE(parser.manifest().IsEmpty()); |
| 64 } |
| 65 |
54 TEST_F(ManifestParserTest, EmptyStringNull) { | 66 TEST_F(ManifestParserTest, EmptyStringNull) { |
55 Manifest manifest = ParseManifest(""); | 67 Manifest manifest = ParseManifest(""); |
56 | 68 |
57 // This Manifest is not a valid JSON object, it's a parsing error. | 69 // This Manifest is not a valid JSON object, it's a parsing error. |
58 EXPECT_EQ(1u, GetErrorCount()); | 70 EXPECT_EQ(1u, GetErrorCount()); |
59 EXPECT_EQ("Manifest parsing error: Line: 1, column: 1, Unexpected token.", | 71 EXPECT_EQ("Manifest parsing error: Line: 1, column: 1, Unexpected token.", |
60 errors()[0]); | 72 errors()[0]); |
61 | 73 |
62 // A parsing error is equivalent to an empty manifest. | 74 // A parsing error is equivalent to an empty manifest. |
63 ASSERT_TRUE(manifest.IsEmpty()); | 75 ASSERT_TRUE(manifest.IsEmpty()); |
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 | 871 |
860 // "False" should set the boolean false without throwing errors. | 872 // "False" should set the boolean false without throwing errors. |
861 { | 873 { |
862 Manifest manifest = ParseManifest("{ \"gcm_user_visible_only\": false }"); | 874 Manifest manifest = ParseManifest("{ \"gcm_user_visible_only\": false }"); |
863 EXPECT_FALSE(manifest.gcm_user_visible_only); | 875 EXPECT_FALSE(manifest.gcm_user_visible_only); |
864 EXPECT_EQ(0u, GetErrorCount()); | 876 EXPECT_EQ(0u, GetErrorCount()); |
865 } | 877 } |
866 } | 878 } |
867 | 879 |
868 } // namespace content | 880 } // namespace content |
OLD | NEW |