OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/common/extensions/manifest.h" | 5 #include "chrome/common/extensions/manifest.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/common/extensions/extension_manifest_constants.h" | 14 #include "chrome/common/extensions/extension_manifest_constants.h" |
15 #include "chrome/common/extensions/features/feature.h" | 15 #include "chrome/common/extensions/features/feature.h" |
| 16 #include "chrome/common/extensions/features/simple_feature.h" |
16 #include "extensions/common/error_utils.h" | 17 #include "extensions/common/error_utils.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 | 19 |
19 namespace errors = extension_manifest_errors; | 20 namespace errors = extension_manifest_errors; |
20 namespace keys = extension_manifest_keys; | 21 namespace keys = extension_manifest_keys; |
21 | 22 |
22 namespace extensions { | 23 namespace extensions { |
23 | 24 |
24 class ManifestTest : public testing::Test { | 25 class ManifestTest : public testing::Test { |
25 public: | 26 public: |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 &manifest, keys::kManifestVersion, Value::CreateIntegerValue(2)); | 88 &manifest, keys::kManifestVersion, Value::CreateIntegerValue(2)); |
88 EXPECT_FALSE(manifest->GetString("background_page", &value)); | 89 EXPECT_FALSE(manifest->GetString("background_page", &value)); |
89 EXPECT_EQ("", value); | 90 EXPECT_EQ("", value); |
90 | 91 |
91 // Validate should also give a warning. | 92 // Validate should also give a warning. |
92 warnings.clear(); | 93 warnings.clear(); |
93 manifest->ValidateManifest(&error, &warnings); | 94 manifest->ValidateManifest(&error, &warnings); |
94 EXPECT_TRUE(error.empty()); | 95 EXPECT_TRUE(error.empty()); |
95 ASSERT_EQ(2u, warnings.size()); | 96 ASSERT_EQ(2u, warnings.size()); |
96 { | 97 { |
97 Feature feature; | 98 SimpleFeature feature; |
98 feature.set_name("background_page"); | 99 feature.set_name("background_page"); |
99 feature.set_max_manifest_version(1); | 100 feature.set_max_manifest_version(1); |
100 EXPECT_EQ( | 101 EXPECT_EQ( |
101 "'background_page' requires manifest version of 1 or lower.", | 102 "'background_page' requires manifest version of 1 or lower.", |
102 warnings[0].message); | 103 warnings[0].message); |
103 } | 104 } |
104 | 105 |
105 // Test DeepCopy and Equals. | 106 // Test DeepCopy and Equals. |
106 scoped_ptr<Manifest> manifest2(manifest->DeepCopy()); | 107 scoped_ptr<Manifest> manifest2(manifest->DeepCopy()); |
107 EXPECT_TRUE(manifest->Equals(manifest2.get())); | 108 EXPECT_TRUE(manifest->Equals(manifest2.get())); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 EXPECT_FALSE(manifest->Get(keys::kCommands, &output)); | 203 EXPECT_FALSE(manifest->Get(keys::kCommands, &output)); |
203 | 204 |
204 MutateManifest( | 205 MutateManifest( |
205 &manifest, keys::kManifestVersion, Value::CreateIntegerValue(2)); | 206 &manifest, keys::kManifestVersion, Value::CreateIntegerValue(2)); |
206 EXPECT_TRUE(manifest->HasKey(keys::kCommands)); | 207 EXPECT_TRUE(manifest->HasKey(keys::kCommands)); |
207 EXPECT_TRUE(manifest->Get(keys::kCommands, &output)); | 208 EXPECT_TRUE(manifest->Get(keys::kCommands, &output)); |
208 } | 209 } |
209 }; | 210 }; |
210 | 211 |
211 } // namespace extensions | 212 } // namespace extensions |
OLD | NEW |