Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Unified Diff: chrome/browser/sync/glue/bookmark_data_type_controller_unittest.cc

Issue 285233012: Abstract history dependencies on bookmarks through HistoryClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 e0dcc88e1bea3e44b026568466051228c8065bbe..b7eba5f621e5bd5a22e62455e29a8c116452ca8d 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/core/browser/bookmark_model.h"
#include "components/bookmarks/core/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,
+ 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_;

Powered by Google App Engine
This is Rietveld 408576698