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 "extensions/common/extension_api.h" | 5 #include "extensions/common/extension_api.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 static_cast<int>(i), | 198 static_cast<int>(i), |
199 test_data[i].api_full_name.c_str(), | 199 test_data[i].api_full_name.c_str(), |
200 expected ? "not available" : "available", | 200 expected ? "not available" : "available", |
201 availability.message().c_str()); | 201 availability.message().c_str()); |
202 } | 202 } |
203 } | 203 } |
204 | 204 |
205 TEST(ExtensionAPITest, IsAnyFeatureAvailableToContext) { | 205 TEST(ExtensionAPITest, IsAnyFeatureAvailableToContext) { |
206 scoped_refptr<const Extension> app = | 206 scoped_refptr<const Extension> app = |
207 ExtensionBuilder() | 207 ExtensionBuilder() |
208 .SetManifest(std::move( | 208 .SetManifest( |
209 DictionaryBuilder() | 209 DictionaryBuilder() |
210 .Set("name", "app") | 210 .Set("name", "app") |
211 .Set("app", std::move(DictionaryBuilder().Set( | 211 .Set("app", |
212 "background", | 212 DictionaryBuilder() |
213 std::move(DictionaryBuilder().Set( | 213 .Set("background", |
214 "scripts", std::move(ListBuilder().Append( | 214 DictionaryBuilder() |
215 "background.js"))))))) | 215 .Set("scripts", ListBuilder() |
| 216 .Append("background.js") |
| 217 .Build()) |
| 218 .Build()) |
| 219 .Build()) |
216 .Set("version", "1") | 220 .Set("version", "1") |
217 .Set("manifest_version", 2))) | 221 .Set("manifest_version", 2) |
| 222 .Build()) |
218 .Build(); | 223 .Build(); |
219 scoped_refptr<const Extension> extension = | 224 scoped_refptr<const Extension> extension = |
220 ExtensionBuilder() | 225 ExtensionBuilder() |
221 .SetManifest(std::move(DictionaryBuilder() | 226 .SetManifest(DictionaryBuilder() |
222 .Set("name", "extension") | 227 .Set("name", "extension") |
223 .Set("version", "1") | 228 .Set("version", "1") |
224 .Set("manifest_version", 2))) | 229 .Set("manifest_version", 2) |
| 230 .Build()) |
225 .Build(); | 231 .Build(); |
226 | 232 |
227 struct { | 233 struct { |
228 std::string api_full_name; | 234 std::string api_full_name; |
229 bool expect_is_available; | 235 bool expect_is_available; |
230 Feature::Context context; | 236 Feature::Context context; |
231 const Extension* extension; | 237 const Extension* extension; |
232 GURL url; | 238 GURL url; |
233 } test_data[] = { | 239 } test_data[] = { |
234 { "test1", false, Feature::WEB_PAGE_CONTEXT, NULL, GURL() }, | 240 { "test1", false, Feature::WEB_PAGE_CONTEXT, NULL, GURL() }, |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 } | 831 } |
826 | 832 |
827 // Tests that permissions that require manifest keys are available when those | 833 // Tests that permissions that require manifest keys are available when those |
828 // keys are present. | 834 // keys are present. |
829 TEST(ExtensionAPITest, ManifestKeys) { | 835 TEST(ExtensionAPITest, ManifestKeys) { |
830 scoped_ptr<ExtensionAPI> extension_api( | 836 scoped_ptr<ExtensionAPI> extension_api( |
831 ExtensionAPI::CreateWithDefaultConfiguration()); | 837 ExtensionAPI::CreateWithDefaultConfiguration()); |
832 | 838 |
833 scoped_refptr<Extension> extension = | 839 scoped_refptr<Extension> extension = |
834 BuildExtension(ExtensionBuilder()) | 840 BuildExtension(ExtensionBuilder()) |
835 .MergeManifest( | 841 .MergeManifest(DictionaryBuilder() |
836 DictionaryBuilder().Set("browser_action", DictionaryBuilder())) | 842 .Set("browser_action", DictionaryBuilder().Build()) |
| 843 .Build()) |
837 .Build(); | 844 .Build(); |
838 | 845 |
839 EXPECT_TRUE(extension_api->IsAvailable("browserAction", | 846 EXPECT_TRUE(extension_api->IsAvailable("browserAction", |
840 extension.get(), | 847 extension.get(), |
841 Feature::BLESSED_EXTENSION_CONTEXT, | 848 Feature::BLESSED_EXTENSION_CONTEXT, |
842 GURL()).is_available()); | 849 GURL()).is_available()); |
843 EXPECT_FALSE(extension_api->IsAvailable("pageAction", | 850 EXPECT_FALSE(extension_api->IsAvailable("pageAction", |
844 extension.get(), | 851 extension.get(), |
845 Feature::BLESSED_EXTENSION_CONTEXT, | 852 Feature::BLESSED_EXTENSION_CONTEXT, |
846 GURL()).is_available()); | 853 GURL()).is_available()); |
847 } | 854 } |
848 | 855 |
849 } // namespace extensions | 856 } // namespace extensions |
OLD | NEW |