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

Unified Diff: chrome/common/extensions/api/extension_api_unittest.cc

Issue 10367002: Make all extension api types fully qualified. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix webrequest tests Created 8 years, 7 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 | « chrome/common/extensions/api/extension_api.cc ('k') | chrome/common/extensions/api/pageAction.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/api/extension_api_unittest.cc
diff --git a/chrome/common/extensions/api/extension_api_unittest.cc b/chrome/common/extensions/api/extension_api_unittest.cc
index e25adb0768bca746cf486fcec4e3cb29ad7c57a5..a0a94e5dff61037bd27fd15288573723a71e594e 100644
--- a/chrome/common/extensions/api/extension_api_unittest.cc
+++ b/chrome/common/extensions/api/extension_api_unittest.cc
@@ -416,5 +416,74 @@ TEST(ExtensionAPI, FeaturesRequireContexts) {
}
}
+static void GetDictionaryFromList(const DictionaryValue* schema,
+ const std::string& list_name,
+ const int list_index,
+ DictionaryValue** out) {
+ ListValue* list;
+ EXPECT_TRUE(schema->GetList(list_name, &list));
+ EXPECT_TRUE(list->GetDictionary(list_index, out));
+}
+
+TEST(ExtensionAPI, TypesHaveNamespace) {
+ FilePath manifest_path;
+ PathService::Get(chrome::DIR_TEST_DATA, &manifest_path);
+ manifest_path = manifest_path.AppendASCII("extensions")
+ .AppendASCII("extension_api_unittest")
+ .AppendASCII("types_have_namespace.json");
+
+ std::string manifest_str;
+ ASSERT_TRUE(file_util::ReadFileToString(manifest_path, &manifest_str))
+ << "Failed to load: " << manifest_path.value();
+
+ ExtensionAPI api;
+ api.RegisterSchema("test.foo", manifest_str);
+ api.LoadAllSchemas();
+
+ const DictionaryValue* schema = api.GetSchema("test.foo");
+
+ DictionaryValue* dict;
+ DictionaryValue* sub_dict;
+ std::string type;
+
+ GetDictionaryFromList(schema, "types", 0, &dict);
+ EXPECT_TRUE(dict->GetString("id", &type));
+ EXPECT_EQ("test.foo.TestType", type);
+ EXPECT_TRUE(dict->GetString("customBindings", &type));
+ EXPECT_EQ("test.foo.TestType", type);
+ EXPECT_TRUE(dict->GetDictionary("properties", &sub_dict));
+ DictionaryValue* property;
+ EXPECT_TRUE(sub_dict->GetDictionary("foo", &property));
+ EXPECT_TRUE(property->GetString("$ref", &type));
+ EXPECT_EQ("test.foo.OtherType", type);
+ EXPECT_TRUE(sub_dict->GetDictionary("bar", &property));
+ EXPECT_TRUE(property->GetString("$ref", &type));
+ EXPECT_EQ("fully.qualified.Type", type);
+
+ GetDictionaryFromList(schema, "functions", 0, &dict);
+ GetDictionaryFromList(dict, "parameters", 0, &sub_dict);
+ EXPECT_TRUE(sub_dict->GetString("$ref", &type));
+ EXPECT_EQ("test.foo.TestType", type);
+ EXPECT_TRUE(dict->GetDictionary("returns", &sub_dict));
+ EXPECT_TRUE(sub_dict->GetString("$ref", &type));
+ EXPECT_EQ("fully.qualified.Type", type);
+
+ GetDictionaryFromList(schema, "functions", 1, &dict);
+ GetDictionaryFromList(dict, "parameters", 0, &sub_dict);
+ EXPECT_TRUE(sub_dict->GetString("$ref", &type));
+ EXPECT_EQ("fully.qualified.Type", type);
+ EXPECT_TRUE(dict->GetDictionary("returns", &sub_dict));
+ EXPECT_TRUE(sub_dict->GetString("$ref", &type));
+ EXPECT_EQ("test.foo.TestType", type);
+
+ GetDictionaryFromList(schema, "events", 0, &dict);
+ GetDictionaryFromList(dict, "parameters", 0, &sub_dict);
+ EXPECT_TRUE(sub_dict->GetString("$ref", &type));
+ EXPECT_EQ("test.foo.TestType", type);
+ GetDictionaryFromList(dict, "parameters", 1, &sub_dict);
+ EXPECT_TRUE(sub_dict->GetString("$ref", &type));
+ EXPECT_EQ("fully.qualified.Type", type);
+}
+
} // namespace
} // namespace extensions
« no previous file with comments | « chrome/common/extensions/api/extension_api.cc ('k') | chrome/common/extensions/api/pageAction.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698