Index: chrome/browser/sync/profile_sync_service_typed_url_unittest.cc |
diff --git a/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc b/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc |
index b94dbc9c66bb32eabdfbffde89b4f41c9ec00850..d8afa62d595075fdbaacb42a7adf85bbeadaf5ac 100644 |
--- a/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc |
+++ b/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc |
@@ -45,6 +45,7 @@ |
#include "chrome/test/base/testing_browser_process.h" |
#include "chrome/test/base/testing_profile.h" |
#include "chrome/test/base/testing_profile_manager.h" |
+#include "components/history/core/browser/test_history_client.h" |
#include "components/keyed_service/content/refcounted_browser_context_keyed_service.h" |
#include "components/signin/core/browser/signin_manager.h" |
#include "components/sync_driver/data_type_error_handler_mock.h" |
@@ -105,21 +106,34 @@ class HistoryBackendMock : public HistoryBackend { |
class HistoryServiceMock : public HistoryService { |
public: |
- explicit HistoryServiceMock(Profile* profile) : HistoryService(profile) {} |
+ HistoryServiceMock(history::HistoryClient* client, Profile* profile) |
+ : HistoryService(client, profile) {} |
MOCK_METHOD2(ScheduleDBTask, void(history::HistoryDBTask*, |
CancelableRequestConsumerBase*)); |
- MOCK_METHOD0(Shutdown, void()); |
+}; |
+ |
+class HistoryClientMock : public history::TestHistoryClient, |
+ public KeyedService { |
+ public: |
+ explicit HistoryClientMock(Profile* profile) { |
+ history_service_.reset(new HistoryServiceMock(this, profile)); |
+ } |
- void ShutdownBaseService() { |
- HistoryService::Shutdown(); |
+ HistoryServiceMock* history_service() { |
+ return history_service_.get(); |
+ } |
+ |
+ // KeyedService: |
+ virtual void Shutdown() OVERRIDE { |
+ history_service_->Cleanup(); |
} |
private: |
- virtual ~HistoryServiceMock() {} |
+ scoped_ptr<HistoryServiceMock> history_service_; |
}; |
KeyedService* BuildHistoryService(content::BrowserContext* profile) { |
- return new HistoryServiceMock(static_cast<Profile*>(profile)); |
+ return new HistoryClientMock(static_cast<Profile*>(profile)); |
} |
class TestTypedUrlModelAssociator : public TypedUrlModelAssociator { |
@@ -150,11 +164,6 @@ ACTION_P2(RunTaskOnDBThread, thread, backend) { |
task)); |
} |
-ACTION_P2(ShutdownHistoryService, thread, service) { |
- service->ShutdownBaseService(); |
- delete thread; |
-} |
- |
ACTION_P6(MakeTypedUrlSyncComponents, |
profile, |
service, |
@@ -210,9 +219,9 @@ class ProfileSyncServiceTypedUrlTest : public AbstractProfileSyncServiceTest { |
invalidation::InvalidationServiceFactory::GetInstance()->SetTestingFactory( |
profile_, invalidation::FakeInvalidationService::Build); |
history_backend_ = new HistoryBackendMock(); |
- history_service_ = static_cast<HistoryServiceMock*>( |
+ history_service_ = static_cast<HistoryClientMock*>( |
HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
- profile_, BuildHistoryService)); |
+ profile_, BuildHistoryService))->history_service(); |
EXPECT_CALL((*history_service_), ScheduleDBTask(_, _)) |
.WillRepeatedly(RunTaskOnDBThread(history_thread_.get(), |
history_backend_.get())); |
@@ -220,9 +229,6 @@ class ProfileSyncServiceTypedUrlTest : public AbstractProfileSyncServiceTest { |
} |
virtual void TearDown() { |
- EXPECT_CALL((*history_service_), Shutdown()) |
- .WillOnce(ShutdownHistoryService(history_thread_.release(), |
- history_service_)); |
profile_ = NULL; |
profile_manager_.DeleteTestingProfile(kTestProfileName); |
AbstractProfileSyncServiceTest::TearDown(); |