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

Unified 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: lazyboys 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/common/extensions/chrome_extensions_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/api/common_extension_api_unittest.cc
diff --git a/chrome/common/extensions/api/common_extension_api_unittest.cc b/chrome/common/extensions/api/common_extension_api_unittest.cc
index 7e63c8c4a880c717977884d494a57338c71957dc..5249256917d1152f4d8fa1f76ef1482aeb8e05b2 100644
--- a/chrome/common/extensions/api/common_extension_api_unittest.cc
+++ b/chrome/common/extensions/api/common_extension_api_unittest.cc
@@ -38,8 +38,23 @@ const char* const kTestFeatures[] = {
"test6", "test7", "parent1", "parent2", "parent3",
};
-UnittestFeatureProvider api_feature_provider;
-}
+class TestExtensionAPI : public ExtensionAPI {
+ public:
+ TestExtensionAPI() {}
+ ~TestExtensionAPI() override {}
+
+ void add_fake_schema(const std::string& name) { fake_schemas_.insert(name); }
+
+ private:
+ bool IsKnownAPI(const std::string& name, ExtensionsClient* client) override {
+ return fake_schemas_.count(name) != 0;
+ }
+
+ std::set<std::string> fake_schemas_;
+ DISALLOW_COPY_AND_ASSIGN(TestExtensionAPI);
+};
+
+} // namespace
using test_util::BuildExtension;
@@ -170,10 +185,10 @@ TEST(ExtensionAPITest, APIFeatures) {
UnittestFeatureProvider api_feature_provider;
for (size_t i = 0; i < arraysize(test_data); ++i) {
- ExtensionAPI api;
+ TestExtensionAPI api;
api.RegisterDependencyProvider("api", &api_feature_provider);
for (const auto& key : kTestFeatures)
- api.RegisterSchemaResource(key, 0);
+ api.add_fake_schema(key);
ExtensionAPI::OverrideSharedInstanceForTest scope(&api);
bool expected = test_data[i].expect_is_available;
@@ -248,10 +263,10 @@ TEST(ExtensionAPITest, IsAnyFeatureAvailableToContext) {
UnittestFeatureProvider api_feature_provider;
for (size_t i = 0; i < arraysize(test_data); ++i) {
- ExtensionAPI api;
+ TestExtensionAPI api;
api.RegisterDependencyProvider("api", &api_feature_provider);
for (const auto& key : kTestFeatures)
- api.RegisterSchemaResource(key, 0);
+ api.add_fake_schema(key);
ExtensionAPI::OverrideSharedInstanceForTest scope(&api);
Feature* test_feature =
@@ -668,8 +683,8 @@ TEST(ExtensionAPITest, TypesHaveNamespace) {
ASSERT_TRUE(base::ReadFileToString(manifest_path, &manifest_str))
<< "Failed to load: " << manifest_path.value();
- ExtensionAPI api;
- api.RegisterSchemaResource("test.foo", 0);
+ TestExtensionAPI api;
+ api.add_fake_schema("test.foo");
api.LoadSchema("test.foo", manifest_str);
const base::DictionaryValue* schema = api.GetSchema("test.foo");
« no previous file with comments | « no previous file | chrome/common/extensions/chrome_extensions_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698