| 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
|
|
|