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 "chrome/common/extensions/api/extension_api.h" | 5 #include "chrome/common/extensions/api/extension_api.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 scoped_ptr<base::DictionaryValue> value(static_cast<DictionaryValue*>( | 202 scoped_ptr<base::DictionaryValue> value(static_cast<DictionaryValue*>( |
203 base::JSONReader::Read(api_features_str))); | 203 base::JSONReader::Read(api_features_str))); |
204 BaseFeatureProvider api_feature_provider(*value, CreateAPIFeature); | 204 BaseFeatureProvider api_feature_provider(*value, CreateAPIFeature); |
205 | 205 |
206 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_data); ++i) { | 206 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_data); ++i) { |
207 ExtensionAPI api; | 207 ExtensionAPI api; |
208 api.RegisterDependencyProvider("api", &api_feature_provider); | 208 api.RegisterDependencyProvider("api", &api_feature_provider); |
209 for (base::DictionaryValue::Iterator iter(*value); !iter.IsAtEnd(); | 209 for (base::DictionaryValue::Iterator iter(*value); !iter.IsAtEnd(); |
210 iter.Advance()) { | 210 iter.Advance()) { |
211 if (iter.key().find(".") == std::string::npos) | 211 if (iter.key().find(".") == std::string::npos) |
212 api.RegisterSchema(iter.key(), ""); | 212 api.RegisterSchemaResource(iter.key(), 0); |
not at google - send to devlin
2013/05/20 17:19:04
what does this do?
cduvall
2013/05/22 03:19:56
Registers a dummy schema resource. I'm still fixin
| |
213 } | 213 } |
214 | 214 |
215 EXPECT_EQ(test_data[i].expect_is_available, | 215 EXPECT_EQ(test_data[i].expect_is_available, |
216 api.IsAvailable(test_data[i].api_full_name, | 216 api.IsAvailable(test_data[i].api_full_name, |
217 NULL, | 217 NULL, |
218 test_data[i].context, | 218 test_data[i].context, |
219 test_data[i].url).is_available()) << i; | 219 test_data[i].url).is_available()) << i; |
220 } | 220 } |
221 } | 221 } |
222 | 222 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
254 scoped_ptr<base::DictionaryValue> value(static_cast<DictionaryValue*>( | 254 scoped_ptr<base::DictionaryValue> value(static_cast<DictionaryValue*>( |
255 base::JSONReader::Read(api_features_str))); | 255 base::JSONReader::Read(api_features_str))); |
256 BaseFeatureProvider api_feature_provider(*value, CreateAPIFeature); | 256 BaseFeatureProvider api_feature_provider(*value, CreateAPIFeature); |
257 | 257 |
258 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_data); ++i) { | 258 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_data); ++i) { |
259 ExtensionAPI api; | 259 ExtensionAPI api; |
260 api.RegisterDependencyProvider("api", &api_feature_provider); | 260 api.RegisterDependencyProvider("api", &api_feature_provider); |
261 for (base::DictionaryValue::Iterator iter(*value); !iter.IsAtEnd(); | 261 for (base::DictionaryValue::Iterator iter(*value); !iter.IsAtEnd(); |
262 iter.Advance()) { | 262 iter.Advance()) { |
263 if (iter.key().find(".") == std::string::npos) | 263 if (iter.key().find(".") == std::string::npos) |
264 api.RegisterSchema(iter.key(), ""); | 264 api.RegisterSchemaResource(iter.key(), 0); |
265 } | 265 } |
266 | 266 |
267 EXPECT_EQ(test_data[i].expect_is_available, | 267 EXPECT_EQ(test_data[i].expect_is_available, |
268 api.IsAnyFeatureAvailableToContext(test_data[i].api_full_name, | 268 api.IsAnyFeatureAvailableToContext(test_data[i].api_full_name, |
269 test_data[i].context, | 269 test_data[i].context, |
270 test_data[i].url)) << i; | 270 test_data[i].url)) << i; |
271 } | 271 } |
272 } | 272 } |
273 | 273 |
274 TEST(ExtensionAPITest, LazyGetSchema) { | 274 TEST(ExtensionAPITest, LazyGetSchema) { |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
615 PathService::Get(chrome::DIR_TEST_DATA, &manifest_path); | 615 PathService::Get(chrome::DIR_TEST_DATA, &manifest_path); |
616 manifest_path = manifest_path.AppendASCII("extensions") | 616 manifest_path = manifest_path.AppendASCII("extensions") |
617 .AppendASCII("extension_api_unittest") | 617 .AppendASCII("extension_api_unittest") |
618 .AppendASCII("types_have_namespace.json"); | 618 .AppendASCII("types_have_namespace.json"); |
619 | 619 |
620 std::string manifest_str; | 620 std::string manifest_str; |
621 ASSERT_TRUE(file_util::ReadFileToString(manifest_path, &manifest_str)) | 621 ASSERT_TRUE(file_util::ReadFileToString(manifest_path, &manifest_str)) |
622 << "Failed to load: " << manifest_path.value(); | 622 << "Failed to load: " << manifest_path.value(); |
623 | 623 |
624 ExtensionAPI api; | 624 ExtensionAPI api; |
625 api.RegisterSchema("test.foo", manifest_str); | 625 // TODO(cduvall): MAKE THIS WORK |
cduvall
2013/05/17 03:09:30
Still fixing the unit tests.
| |
626 api.RegisterSchemaResource("test.foo", 0); | |
626 | 627 |
627 const base::DictionaryValue* schema = api.GetSchema("test.foo"); | 628 const base::DictionaryValue* schema = api.GetSchema("test.foo"); |
628 | 629 |
629 const base::DictionaryValue* dict; | 630 const base::DictionaryValue* dict; |
630 const base::DictionaryValue* sub_dict; | 631 const base::DictionaryValue* sub_dict; |
631 std::string type; | 632 std::string type; |
632 | 633 |
633 GetDictionaryFromList(schema, "types", 0, &dict); | 634 GetDictionaryFromList(schema, "types", 0, &dict); |
634 EXPECT_TRUE(dict->GetString("id", &type)); | 635 EXPECT_TRUE(dict->GetString("id", &type)); |
635 EXPECT_EQ("test.foo.TestType", type); | 636 EXPECT_EQ("test.foo.TestType", type); |
(...skipping 28 matching lines...) Expand all Loading... | |
664 GetDictionaryFromList(dict, "parameters", 0, &sub_dict); | 665 GetDictionaryFromList(dict, "parameters", 0, &sub_dict); |
665 EXPECT_TRUE(sub_dict->GetString("$ref", &type)); | 666 EXPECT_TRUE(sub_dict->GetString("$ref", &type)); |
666 EXPECT_EQ("test.foo.TestType", type); | 667 EXPECT_EQ("test.foo.TestType", type); |
667 GetDictionaryFromList(dict, "parameters", 1, &sub_dict); | 668 GetDictionaryFromList(dict, "parameters", 1, &sub_dict); |
668 EXPECT_TRUE(sub_dict->GetString("$ref", &type)); | 669 EXPECT_TRUE(sub_dict->GetString("$ref", &type)); |
669 EXPECT_EQ("fully.qualified.Type", type); | 670 EXPECT_EQ("fully.qualified.Type", type); |
670 } | 671 } |
671 | 672 |
672 } // namespace | 673 } // namespace |
673 } // namespace extensions | 674 } // namespace extensions |
OLD | NEW |