Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(815)

Side by Side Diff: chrome/common/extensions/api/common_extension_api_unittest.cc

Issue 2266673002: [Extensions] Remove mechanism for non-generated schemas (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: testfix Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 { "parent3.noparent.child", true, Feature::UNBLESSED_EXTENSION_CONTEXT, 166 { "parent3.noparent.child", true, Feature::UNBLESSED_EXTENSION_CONTEXT,
167 GURL() } 167 GURL() }
168 }; 168 };
169 169
170 UnittestFeatureProvider api_feature_provider; 170 UnittestFeatureProvider api_feature_provider;
171 171
172 for (size_t i = 0; i < arraysize(test_data); ++i) { 172 for (size_t i = 0; i < arraysize(test_data); ++i) {
173 ExtensionAPI api; 173 ExtensionAPI api;
174 api.RegisterDependencyProvider("api", &api_feature_provider); 174 api.RegisterDependencyProvider("api", &api_feature_provider);
175 for (const auto& key : kTestFeatures) 175 for (const auto& key : kTestFeatures)
176 api.RegisterSchemaResource(key, 0); 176 api.RegisterFakeSchemaForTesting(key);
177 ExtensionAPI::OverrideSharedInstanceForTest scope(&api); 177 ExtensionAPI::OverrideSharedInstanceForTest scope(&api);
178 178
179 bool expected = test_data[i].expect_is_available; 179 bool expected = test_data[i].expect_is_available;
180 Feature::Availability availability = 180 Feature::Availability availability =
181 api.IsAvailable(test_data[i].api_full_name, 181 api.IsAvailable(test_data[i].api_full_name,
182 NULL, 182 NULL,
183 test_data[i].context, 183 test_data[i].context,
184 test_data[i].url); 184 test_data[i].url);
185 EXPECT_EQ(expected, availability.is_available()) 185 EXPECT_EQ(expected, availability.is_available())
186 << base::StringPrintf("Test %d: Feature '%s' was %s: %s", 186 << base::StringPrintf("Test %d: Feature '%s' was %s: %s",
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 { "test7", true, Feature::WEB_PAGE_CONTEXT, NULL, GURL("http://foo.com") }, 244 { "test7", true, Feature::WEB_PAGE_CONTEXT, NULL, GURL("http://foo.com") },
245 { "test7", false, Feature::WEB_PAGE_CONTEXT, NULL, GURL("http://bar.com") } 245 { "test7", false, Feature::WEB_PAGE_CONTEXT, NULL, GURL("http://bar.com") }
246 }; 246 };
247 247
248 UnittestFeatureProvider api_feature_provider; 248 UnittestFeatureProvider api_feature_provider;
249 249
250 for (size_t i = 0; i < arraysize(test_data); ++i) { 250 for (size_t i = 0; i < arraysize(test_data); ++i) {
251 ExtensionAPI api; 251 ExtensionAPI api;
252 api.RegisterDependencyProvider("api", &api_feature_provider); 252 api.RegisterDependencyProvider("api", &api_feature_provider);
253 for (const auto& key : kTestFeatures) 253 for (const auto& key : kTestFeatures)
254 api.RegisterSchemaResource(key, 0); 254 api.RegisterFakeSchemaForTesting(key);
255 ExtensionAPI::OverrideSharedInstanceForTest scope(&api); 255 ExtensionAPI::OverrideSharedInstanceForTest scope(&api);
256 256
257 Feature* test_feature = 257 Feature* test_feature =
258 api_feature_provider.GetFeature(test_data[i].api_full_name); 258 api_feature_provider.GetFeature(test_data[i].api_full_name);
259 ASSERT_TRUE(test_feature); 259 ASSERT_TRUE(test_feature);
260 EXPECT_EQ(test_data[i].expect_is_available, 260 EXPECT_EQ(test_data[i].expect_is_available,
261 api.IsAnyFeatureAvailableToContext(*test_feature, 261 api.IsAnyFeatureAvailableToContext(*test_feature,
262 test_data[i].extension, 262 test_data[i].extension,
263 test_data[i].context, 263 test_data[i].context,
264 test_data[i].url)) 264 test_data[i].url))
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 PathService::Get(chrome::DIR_TEST_DATA, &manifest_path); 662 PathService::Get(chrome::DIR_TEST_DATA, &manifest_path);
663 manifest_path = manifest_path.AppendASCII("extensions") 663 manifest_path = manifest_path.AppendASCII("extensions")
664 .AppendASCII("extension_api_unittest") 664 .AppendASCII("extension_api_unittest")
665 .AppendASCII("types_have_namespace.json"); 665 .AppendASCII("types_have_namespace.json");
666 666
667 std::string manifest_str; 667 std::string manifest_str;
668 ASSERT_TRUE(base::ReadFileToString(manifest_path, &manifest_str)) 668 ASSERT_TRUE(base::ReadFileToString(manifest_path, &manifest_str))
669 << "Failed to load: " << manifest_path.value(); 669 << "Failed to load: " << manifest_path.value();
670 670
671 ExtensionAPI api; 671 ExtensionAPI api;
672 api.RegisterSchemaResource("test.foo", 0); 672 api.RegisterFakeSchemaForTesting("test.foo");
673 api.LoadSchema("test.foo", manifest_str); 673 api.LoadSchema("test.foo", manifest_str);
674 674
675 const base::DictionaryValue* schema = api.GetSchema("test.foo"); 675 const base::DictionaryValue* schema = api.GetSchema("test.foo");
676 676
677 const base::DictionaryValue* dict; 677 const base::DictionaryValue* dict;
678 const base::DictionaryValue* sub_dict; 678 const base::DictionaryValue* sub_dict;
679 std::string type; 679 std::string type;
680 680
681 GetDictionaryFromList(schema, "types", 0, &dict); 681 GetDictionaryFromList(schema, "types", 0, &dict);
682 EXPECT_TRUE(dict->GetString("id", &type)); 682 EXPECT_TRUE(dict->GetString("id", &type));
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 extension.get(), 795 extension.get(),
796 Feature::BLESSED_EXTENSION_CONTEXT, 796 Feature::BLESSED_EXTENSION_CONTEXT,
797 GURL()).is_available()); 797 GURL()).is_available());
798 EXPECT_FALSE(extension_api->IsAvailable("pageAction", 798 EXPECT_FALSE(extension_api->IsAvailable("pageAction",
799 extension.get(), 799 extension.get(),
800 Feature::BLESSED_EXTENSION_CONTEXT, 800 Feature::BLESSED_EXTENSION_CONTEXT,
801 GURL()).is_available()); 801 GURL()).is_available());
802 } 802 }
803 803
804 } // namespace extensions 804 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/chrome_extensions_client.h » ('j') | extensions/common/extension_api.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698