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 |
(...skipping 13 matching lines...) Expand all Loading... |
24 class ManifestTest : public testing::Test { | 24 class ManifestTest : public testing::Test { |
25 public: | 25 public: |
26 ManifestTest() : default_value_("test") {} | 26 ManifestTest() : default_value_("test") {} |
27 | 27 |
28 protected: | 28 protected: |
29 void AssertType(Manifest* manifest, Extension::Type type) { | 29 void AssertType(Manifest* manifest, Extension::Type type) { |
30 EXPECT_EQ(type, manifest->type()); | 30 EXPECT_EQ(type, manifest->type()); |
31 EXPECT_EQ(type == Extension::TYPE_THEME, manifest->is_theme()); | 31 EXPECT_EQ(type == Extension::TYPE_THEME, manifest->is_theme()); |
32 EXPECT_EQ(type == Extension::TYPE_PLATFORM_APP, | 32 EXPECT_EQ(type == Extension::TYPE_PLATFORM_APP, |
33 manifest->is_platform_app()); | 33 manifest->is_platform_app()); |
34 EXPECT_EQ(type == Extension::TYPE_PACKAGED_APP, | 34 EXPECT_EQ(type == Extension::TYPE_LEGACY_PACKAGED_APP, |
35 manifest->is_packaged_app()); | 35 manifest->is_legacy_packaged_app()); |
36 EXPECT_EQ(type == Extension::TYPE_HOSTED_APP, manifest->is_hosted_app()); | 36 EXPECT_EQ(type == Extension::TYPE_HOSTED_APP, manifest->is_hosted_app()); |
37 } | 37 } |
38 | 38 |
39 // Helper function that replaces the Manifest held by |manifest| with a copy | 39 // Helper function that replaces the Manifest held by |manifest| with a copy |
40 // with its |key| changed to |value|. If |value| is NULL, then |key| will | 40 // with its |key| changed to |value|. If |value| is NULL, then |key| will |
41 // instead be deleted. | 41 // instead be deleted. |
42 void MutateManifest( | 42 void MutateManifest( |
43 scoped_ptr<Manifest>* manifest, const std::string& key, Value* value) { | 43 scoped_ptr<Manifest>* manifest, const std::string& key, Value* value) { |
44 scoped_ptr<DictionaryValue> manifest_value( | 44 scoped_ptr<DictionaryValue> manifest_value( |
45 manifest->get()->value()->DeepCopy()); | 45 manifest->get()->value()->DeepCopy()); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 // Theme. | 131 // Theme. |
132 MutateManifest( | 132 MutateManifest( |
133 &manifest, keys::kTheme, new DictionaryValue()); | 133 &manifest, keys::kTheme, new DictionaryValue()); |
134 AssertType(manifest.get(), Extension::TYPE_THEME); | 134 AssertType(manifest.get(), Extension::TYPE_THEME); |
135 MutateManifest( | 135 MutateManifest( |
136 &manifest, keys::kTheme, NULL); | 136 &manifest, keys::kTheme, NULL); |
137 | 137 |
138 // Packaged app. | 138 // Packaged app. |
139 MutateManifest( | 139 MutateManifest( |
140 &manifest, keys::kApp, new DictionaryValue()); | 140 &manifest, keys::kApp, new DictionaryValue()); |
141 AssertType(manifest.get(), Extension::TYPE_PACKAGED_APP); | 141 AssertType(manifest.get(), Extension::TYPE_LEGACY_PACKAGED_APP); |
142 | 142 |
143 // Platform app. | 143 // Platform app. |
144 MutateManifest( | 144 MutateManifest( |
145 &manifest, keys::kPlatformAppBackground, new DictionaryValue()); | 145 &manifest, keys::kPlatformAppBackground, new DictionaryValue()); |
146 AssertType(manifest.get(), Extension::TYPE_PLATFORM_APP); | 146 AssertType(manifest.get(), Extension::TYPE_PLATFORM_APP); |
147 MutateManifest( | 147 MutateManifest( |
148 &manifest, keys::kPlatformAppBackground, NULL); | 148 &manifest, keys::kPlatformAppBackground, NULL); |
149 | 149 |
150 // Hosted app. | 150 // Hosted app. |
151 MutateManifest( | 151 MutateManifest( |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 EXPECT_FALSE(manifest->Get(keys::kCommands, &output)); | 202 EXPECT_FALSE(manifest->Get(keys::kCommands, &output)); |
203 | 203 |
204 MutateManifest( | 204 MutateManifest( |
205 &manifest, keys::kManifestVersion, Value::CreateIntegerValue(2)); | 205 &manifest, keys::kManifestVersion, Value::CreateIntegerValue(2)); |
206 EXPECT_TRUE(manifest->HasKey(keys::kCommands)); | 206 EXPECT_TRUE(manifest->HasKey(keys::kCommands)); |
207 EXPECT_TRUE(manifest->Get(keys::kCommands, &output)); | 207 EXPECT_TRUE(manifest->Get(keys::kCommands, &output)); |
208 } | 208 } |
209 }; | 209 }; |
210 | 210 |
211 } // namespace extensions | 211 } // namespace extensions |
OLD | NEW |