| Index: chrome/browser/intents/web_intents_registry_unittest.cc
|
| ===================================================================
|
| --- chrome/browser/intents/web_intents_registry_unittest.cc (revision 113231)
|
| +++ chrome/browser/intents/web_intents_registry_unittest.cc (working copy)
|
| @@ -11,6 +11,7 @@
|
| #include "chrome/browser/intents/web_intents_registry.h"
|
| #include "chrome/browser/webdata/web_data_service.h"
|
| #include "chrome/common/chrome_paths.h"
|
| +#include "chrome/common/extensions/extension_set.h"
|
| #include "content/test/test_browser_thread.h"
|
| #include "testing/gmock/include/gmock/gmock.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| @@ -21,51 +22,43 @@
|
| class MockExtensionService: public TestExtensionService {
|
| public:
|
| virtual ~MockExtensionService() {}
|
| - MOCK_CONST_METHOD0(extensions, const ExtensionList*());
|
| + MOCK_CONST_METHOD0(extensions, const ExtensionSet*());
|
| };
|
|
|
| +namespace {
|
| +
|
| // TODO(groby): Unify loading functions with extension_manifest_unittest code.
|
| -DictionaryValue* LoadManifestFile(const std::string& filename,
|
| +DictionaryValue* LoadManifestFile(const FilePath& path,
|
| std::string* error) {
|
| - FilePath path;
|
| - PathService::Get(chrome::DIR_TEST_DATA, &path);
|
| - path = path.AppendASCII("extensions")
|
| - .AppendASCII("manifest_tests")
|
| - .AppendASCII(filename.c_str());
|
| EXPECT_TRUE(file_util::PathExists(path));
|
| -
|
| JSONFileValueSerializer serializer(path);
|
| return static_cast<DictionaryValue*>(serializer.Deserialize(NULL, error));
|
| }
|
|
|
| -namespace {
|
| -
|
| scoped_refptr<Extension> LoadExtensionWithLocation(
|
| - DictionaryValue* value,
|
| + const std::string& name,
|
| Extension::Location location,
|
| bool strict_error_checks,
|
| std::string* error) {
|
| FilePath path;
|
| PathService::Get(chrome::DIR_TEST_DATA, &path);
|
| - path = path.AppendASCII("extensions").AppendASCII("manifest_tests");
|
| + path = path.AppendASCII("extensions")
|
| + .AppendASCII("manifest_tests")
|
| + .AppendASCII(name.c_str());
|
| + scoped_ptr<DictionaryValue> value(LoadManifestFile(path, error));
|
| + if (!value.get())
|
| + return NULL;
|
| int flags = Extension::NO_FLAGS;
|
| if (strict_error_checks)
|
| flags |= Extension::STRICT_ERROR_CHECKS;
|
| - return Extension::Create(path.DirName(), location, *value, flags, error);
|
| + return Extension::CreateWithId(path.DirName(),
|
| + location,
|
| + *value,
|
| + flags,
|
| + Extension::GenerateIdForPath(path),
|
| + error);
|
| }
|
|
|
| -scoped_refptr<Extension> LoadExtensionWithLocation(
|
| - const std::string& name,
|
| - Extension::Location location,
|
| - bool strict_error_checks,
|
| - std::string* error) {
|
| - scoped_ptr<DictionaryValue> value(LoadManifestFile(name, error));
|
| - if (!value.get())
|
| - return NULL;
|
| - return LoadExtensionWithLocation(value.get(), location,
|
| - strict_error_checks, error);
|
| -}
|
| -
|
| scoped_refptr<Extension> LoadExtension(const std::string& name,
|
| std::string* error) {
|
| return LoadExtensionWithLocation(name, Extension::INTERNAL, false, error);
|
| @@ -114,7 +107,7 @@
|
| content::TestBrowserThread db_thread_;
|
| scoped_refptr<WebDataService> wds_;
|
| MockExtensionService extension_service_;
|
| - ExtensionList extensions_;
|
| + ExtensionSet extensions_;
|
| WebIntentsRegistry registry_;
|
| ScopedTempDir temp_dir_;
|
| };
|
| @@ -213,8 +206,9 @@
|
| }
|
|
|
| TEST_F(WebIntentsRegistryTest, GetExtensionIntents) {
|
| - extensions_.push_back(LoadAndExpectSuccess("intent_valid.json"));
|
| - extensions_.push_back(LoadAndExpectSuccess("intent_valid_2.json"));
|
| + extensions_.Insert(LoadAndExpectSuccess("intent_valid.json"));
|
| + extensions_.Insert(LoadAndExpectSuccess("intent_valid_2.json"));
|
| + ASSERT_EQ(2U, extensions_.size());
|
|
|
| TestConsumer consumer;
|
| consumer.expected_id_ = registry_.GetAllIntentProviders(&consumer);
|
| @@ -223,8 +217,9 @@
|
| }
|
|
|
| TEST_F(WebIntentsRegistryTest, GetSomeExtensionIntents) {
|
| - extensions_.push_back(LoadAndExpectSuccess("intent_valid.json"));
|
| - extensions_.push_back(LoadAndExpectSuccess("intent_valid_2.json"));
|
| + extensions_.Insert(LoadAndExpectSuccess("intent_valid.json"));
|
| + extensions_.Insert(LoadAndExpectSuccess("intent_valid_2.json"));
|
| + ASSERT_EQ(2U, extensions_.size());
|
|
|
| TestConsumer consumer;
|
| consumer.expected_id_ = registry_.GetIntentProviders(
|
| @@ -235,8 +230,9 @@
|
| }
|
|
|
| TEST_F(WebIntentsRegistryTest, GetIntentsFromMixedSources) {
|
| - extensions_.push_back(LoadAndExpectSuccess("intent_valid.json"));
|
| - extensions_.push_back(LoadAndExpectSuccess("intent_valid_2.json"));
|
| + extensions_.Insert(LoadAndExpectSuccess("intent_valid.json"));
|
| + extensions_.Insert(LoadAndExpectSuccess("intent_valid_2.json"));
|
| + ASSERT_EQ(2U, extensions_.size());
|
|
|
| webkit_glue::WebIntentServiceData service;
|
| service.service_url = GURL("http://somewhere.com/intent/edit.html");
|
|
|