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 18 matching lines...) Expand all Loading... |
29 | 29 |
30 protected: | 30 protected: |
31 void AssertType(Manifest* manifest, Manifest::Type type) { | 31 void AssertType(Manifest* manifest, Manifest::Type type) { |
32 EXPECT_EQ(type, manifest->type()); | 32 EXPECT_EQ(type, manifest->type()); |
33 EXPECT_EQ(type == Manifest::TYPE_THEME, manifest->is_theme()); | 33 EXPECT_EQ(type == Manifest::TYPE_THEME, manifest->is_theme()); |
34 EXPECT_EQ(type == Manifest::TYPE_PLATFORM_APP, | 34 EXPECT_EQ(type == Manifest::TYPE_PLATFORM_APP, |
35 manifest->is_platform_app()); | 35 manifest->is_platform_app()); |
36 EXPECT_EQ(type == Manifest::TYPE_LEGACY_PACKAGED_APP, | 36 EXPECT_EQ(type == Manifest::TYPE_LEGACY_PACKAGED_APP, |
37 manifest->is_legacy_packaged_app()); | 37 manifest->is_legacy_packaged_app()); |
38 EXPECT_EQ(type == Manifest::TYPE_HOSTED_APP, manifest->is_hosted_app()); | 38 EXPECT_EQ(type == Manifest::TYPE_HOSTED_APP, manifest->is_hosted_app()); |
| 39 EXPECT_EQ(type == Manifest::TYPE_SHARED_MODULE, |
| 40 manifest->is_shared_module()); |
39 } | 41 } |
40 | 42 |
41 // Helper function that replaces the Manifest held by |manifest| with a copy | 43 // Helper function that replaces the Manifest held by |manifest| with a copy |
42 // with its |key| changed to |value|. If |value| is NULL, then |key| will | 44 // with its |key| changed to |value|. If |value| is NULL, then |key| will |
43 // instead be deleted. | 45 // instead be deleted. |
44 void MutateManifest(scoped_ptr<Manifest>* manifest, | 46 void MutateManifest(scoped_ptr<Manifest>* manifest, |
45 const std::string& key, | 47 const std::string& key, |
46 base::Value* value) { | 48 base::Value* value) { |
47 scoped_ptr<base::DictionaryValue> manifest_value( | 49 scoped_ptr<base::DictionaryValue> manifest_value( |
48 manifest->get()->value()->DeepCopy()); | 50 manifest->get()->value()->DeepCopy()); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 // By default, the type is Extension. | 133 // By default, the type is Extension. |
132 AssertType(manifest.get(), Manifest::TYPE_EXTENSION); | 134 AssertType(manifest.get(), Manifest::TYPE_EXTENSION); |
133 | 135 |
134 // Theme. | 136 // Theme. |
135 MutateManifest( | 137 MutateManifest( |
136 &manifest, keys::kTheme, new base::DictionaryValue()); | 138 &manifest, keys::kTheme, new base::DictionaryValue()); |
137 AssertType(manifest.get(), Manifest::TYPE_THEME); | 139 AssertType(manifest.get(), Manifest::TYPE_THEME); |
138 MutateManifest( | 140 MutateManifest( |
139 &manifest, keys::kTheme, NULL); | 141 &manifest, keys::kTheme, NULL); |
140 | 142 |
| 143 // Shared module. |
| 144 MutateManifest( |
| 145 &manifest, keys::kExport, new base::DictionaryValue()); |
| 146 AssertType(manifest.get(), Manifest::TYPE_SHARED_MODULE); |
| 147 MutateManifest( |
| 148 &manifest, keys::kExport, NULL); |
| 149 |
141 // Packaged app. | 150 // Packaged app. |
142 MutateManifest( | 151 MutateManifest( |
143 &manifest, keys::kApp, new base::DictionaryValue()); | 152 &manifest, keys::kApp, new base::DictionaryValue()); |
144 AssertType(manifest.get(), Manifest::TYPE_LEGACY_PACKAGED_APP); | 153 AssertType(manifest.get(), Manifest::TYPE_LEGACY_PACKAGED_APP); |
145 | 154 |
146 // Platform app. | 155 // Platform app. |
147 MutateManifest( | 156 MutateManifest( |
148 &manifest, keys::kPlatformAppBackground, new base::DictionaryValue()); | 157 &manifest, keys::kPlatformAppBackground, new base::DictionaryValue()); |
149 AssertType(manifest.get(), Manifest::TYPE_PLATFORM_APP); | 158 AssertType(manifest.get(), Manifest::TYPE_PLATFORM_APP); |
150 MutateManifest( | 159 MutateManifest( |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 EXPECT_FALSE(manifest->Get(keys::kCommands, &output)); | 214 EXPECT_FALSE(manifest->Get(keys::kCommands, &output)); |
206 | 215 |
207 MutateManifest( | 216 MutateManifest( |
208 &manifest, keys::kManifestVersion, new base::FundamentalValue(2)); | 217 &manifest, keys::kManifestVersion, new base::FundamentalValue(2)); |
209 EXPECT_TRUE(manifest->HasKey(keys::kCommands)); | 218 EXPECT_TRUE(manifest->HasKey(keys::kCommands)); |
210 EXPECT_TRUE(manifest->Get(keys::kCommands, &output)); | 219 EXPECT_TRUE(manifest->Get(keys::kCommands, &output)); |
211 } | 220 } |
212 }; | 221 }; |
213 | 222 |
214 } // namespace extensions | 223 } // namespace extensions |
OLD | NEW |