| Index: chrome/browser/search_engines/template_url_service_test_util.cc
|
| diff --git a/chrome/browser/search_engines/template_url_service_test_util.cc b/chrome/browser/search_engines/template_url_service_test_util.cc
|
| index 34894ab0a29a0a1a8db1f1caeb924ae446976c0b..d5bfdcf2f7a962a5f9d4a78f7d8cf93bd41d14c5 100644
|
| --- a/chrome/browser/search_engines/template_url_service_test_util.cc
|
| +++ b/chrome/browser/search_engines/template_url_service_test_util.cc
|
| @@ -19,6 +19,8 @@
|
| #include "chrome/test/automation/value_conversion_util.h"
|
| #include "chrome/test/base/testing_pref_service_syncable.h"
|
| #include "chrome/test/base/testing_profile.h"
|
| +#include "components/webdata/common/web_data_service_test_util.h"
|
| +#include "components/webdata/common/web_database_service.h"
|
| #include "content/public/browser/notification_service.h"
|
| #include "content/public/test/test_browser_thread.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| @@ -54,6 +56,32 @@ static void WaitForThreadToProcessRequests(BrowserThread::ID identifier) {
|
|
|
| } // namespace
|
|
|
| +class MockWebDataServiceWrapperDB : public MockWebDataServiceWrapper {
|
| + public:
|
| + static BrowserContextKeyedService* Build(content::BrowserContext* profile) {
|
| + return new MockWebDataServiceWrapperDB(static_cast<Profile*>(profile));
|
| + }
|
| +
|
| + explicit MockWebDataServiceWrapperDB(Profile* profile)
|
| + : MockWebDataServiceWrapper(NULL, NULL, NULL) {
|
| + base::FilePath profile_path = profile->GetPath();
|
| + base::FilePath path = profile_path.AppendASCII("TestWebDB");
|
| + web_database_ = new WebDatabaseService(path);
|
| + web_database_->AddTable(scoped_ptr<WebDatabaseTable>(new KeywordTable()));
|
| + fake_web_data_ = new WebDataService(
|
| + web_database_, WebDataServiceBase::ProfileErrorCallback());
|
| + fake_web_data_->Init();
|
| + }
|
| +
|
| + virtual void Shutdown() OVERRIDE {
|
| + fake_web_data_->ShutdownDatabase();
|
| + }
|
| +
|
| + private:
|
| + scoped_refptr<WebDatabaseService> web_database_;
|
| + DISALLOW_COPY_AND_ASSIGN(MockWebDataServiceWrapperDB);
|
| +};
|
| +
|
| // Trivial subclass of TemplateURLService that records the last invocation of
|
| // SetKeywordSearchTermsForURL.
|
| class TestingTemplateURLService : public TemplateURLService {
|
| @@ -100,7 +128,9 @@ void TemplateURLServiceTestUtil::SetUp() {
|
| ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
|
| profile_.reset(new TestingProfile(temp_dir_.path()));
|
| db_thread_.Start();
|
| - profile_->CreateWebDataService();
|
| +
|
| + WebDataServiceFactory::GetInstance()->SetTestingFactory(
|
| + profile_.get(), MockWebDataServiceWrapperDB::Build);
|
|
|
| TemplateURLService* service = static_cast<TemplateURLService*>(
|
| TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
|
|
|