Chromium Code Reviews| Index: chrome/browser/sync/glue/bookmark_data_type_controller_unittest.cc |
| diff --git a/chrome/browser/sync/glue/bookmark_data_type_controller_unittest.cc b/chrome/browser/sync/glue/bookmark_data_type_controller_unittest.cc |
| index 4e2e4618ace83510f79fcf4f3b3f2a71511d317d..34f6c1f66e6c5154b8e90ae1ef649649b52dfc27 100644 |
| --- a/chrome/browser/sync/glue/bookmark_data_type_controller_unittest.cc |
| +++ b/chrome/browser/sync/glue/bookmark_data_type_controller_unittest.cc |
| @@ -23,6 +23,7 @@ |
| #include "chrome/test/base/profile_mock.h" |
| #include "components/bookmarks/browser/bookmark_model.h" |
| #include "components/bookmarks/test/bookmark_test_helpers.h" |
| +#include "components/history/core/browser/test_history_client.h" |
| #include "components/keyed_service/content/refcounted_browser_context_keyed_service.h" |
| #include "components/sync_driver/change_processor_mock.h" |
| #include "components/sync_driver/data_type_controller_mock.h" |
| @@ -49,13 +50,31 @@ using testing::SetArgumentPointee; |
| namespace { |
| -class HistoryMock : public HistoryService { |
| +class HistoryServiceMock : public HistoryService { |
| public: |
| - explicit HistoryMock(Profile* profile) : HistoryService(profile) {} |
| + HistoryServiceMock(history::HistoryClient* client, Profile* profile) |
| + : HistoryService(client, profile) {} |
| MOCK_METHOD0(BackendLoaded, bool(void)); |
| +}; |
| - protected: |
| - virtual ~HistoryMock() {} |
| +class HistoryClientMock : public history::TestHistoryClient, |
|
blundell
2014/05/27 09:56:38
I think the need for this change will go away if y
sdefresne
2014/05/28 17:10:42
Done.
|
| + public KeyedService { |
| + public: |
| + explicit HistoryClientMock(Profile* profile) { |
| + history_service_.reset(new HistoryServiceMock(this, profile)); |
| + } |
| + |
| + HistoryServiceMock* history_service() { |
| + return history_service_.get(); |
| + } |
| + |
| + // KeyedService: |
| + virtual void Shutdown() OVERRIDE { |
| + history_service_->Cleanup(); |
| + } |
| + |
| + private: |
| + scoped_ptr<HistoryServiceMock> history_service_; |
| }; |
| KeyedService* BuildBookmarkModel(content::BrowserContext* context) { |
| @@ -81,7 +100,7 @@ KeyedService* BuildBookmarkModelWithoutLoading( |
| } |
| KeyedService* BuildHistoryService(content::BrowserContext* profile) { |
| - return new HistoryMock(static_cast<Profile*>(profile)); |
| + return new HistoryClientMock(static_cast<Profile*>(profile)); |
| } |
| } // namespace |
| @@ -95,9 +114,9 @@ class SyncBookmarkDataTypeControllerTest : public testing::Test { |
| virtual void SetUp() { |
| model_associator_ = new ModelAssociatorMock(); |
| change_processor_ = new ChangeProcessorMock(); |
| - history_service_ = static_cast<HistoryMock*>( |
| + history_service_ = static_cast<HistoryClientMock*>( |
| HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
| - &profile_, BuildHistoryService)); |
| + &profile_, BuildHistoryService))->history_service(); |
| profile_sync_factory_.reset( |
| new ProfileSyncComponentsFactoryMock(model_associator_, |
| change_processor_)); |
| @@ -164,7 +183,7 @@ class SyncBookmarkDataTypeControllerTest : public testing::Test { |
| scoped_ptr<ProfileSyncComponentsFactoryMock> profile_sync_factory_; |
| ProfileMock profile_; |
| BookmarkModel* bookmark_model_; |
| - HistoryMock* history_service_; |
| + HistoryServiceMock* history_service_; |
| ProfileSyncServiceMock service_; |
| ModelAssociatorMock* model_associator_; |
| ChangeProcessorMock* change_processor_; |