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

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

Issue 306293006: Introduce ChromeBookmarkClientFactory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@364865
Patch Set: Add missing dependency in components/policy/policy_browser.gypi Created 6 years, 6 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 36fd925e5940840d027187be9b040052339c51c3..d5a6a1ae359c049cf3b23696614f5a24ca8be3df 100644
--- a/chrome/browser/sync/glue/bookmark_data_type_controller_unittest.cc
+++ b/chrome/browser/sync/glue/bookmark_data_type_controller_unittest.cc
@@ -13,6 +13,7 @@
#include "base/run_loop.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/bookmarks/chrome_bookmark_client.h"
+#include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/history/history_service.h"
#include "chrome/browser/history/history_service_factory.h"
@@ -59,26 +60,31 @@ class HistoryMock : public HistoryService {
virtual ~HistoryMock() {}
};
-KeyedService* BuildBookmarkModel(content::BrowserContext* context) {
- Profile* profile = static_cast<Profile*>(context);
- ChromeBookmarkClient* bookmark_client =
- new ChromeBookmarkClient(profile, false);
- bookmark_client->model()->Load(
- profile->GetPrefs(),
- profile->GetPrefs()->GetString(prefs::kAcceptLanguages),
- profile->GetPath(),
- profile->GetIOTaskRunner(),
- content::BrowserThread::GetMessageLoopProxyForThread(
- content::BrowserThread::UI));
- return bookmark_client;
+KeyedService* BuildChromeBookmarkClient(content::BrowserContext* context) {
+ return new ChromeBookmarkClient(static_cast<Profile*>(context));
}
KeyedService* BuildBookmarkModelWithoutLoading(
content::BrowserContext* context) {
Profile* profile = static_cast<Profile*>(context);
ChromeBookmarkClient* bookmark_client =
- new ChromeBookmarkClient(profile, false);
- return bookmark_client;
+ ChromeBookmarkClientFactory::GetForProfile(profile);
+ BookmarkModel* bookmark_model = new BookmarkModel(bookmark_client, false);
+ bookmark_client->Init(bookmark_model);
+ return bookmark_model;
+}
+
+KeyedService* BuildBookmarkModel(content::BrowserContext* context) {
+ BookmarkModel* bookmark_model = static_cast<BookmarkModel*>(
+ BuildBookmarkModelWithoutLoading(context));
+ Profile* profile = static_cast<Profile*>(context);
+ bookmark_model->Load(profile->GetPrefs(),
+ profile->GetPrefs()->GetString(prefs::kAcceptLanguages),
+ profile->GetPath(),
+ profile->GetIOTaskRunner(),
+ content::BrowserThread::GetMessageLoopProxyForThread(
+ content::BrowserThread::UI));
+ return bookmark_model;
}
KeyedService* BuildHistoryService(content::BrowserContext* profile) {
@@ -114,17 +120,17 @@ class SyncBookmarkDataTypeControllerTest : public testing::Test {
};
void CreateBookmarkModel(BookmarkLoadPolicy bookmark_load_policy) {
+ ChromeBookmarkClientFactory::GetInstance()->SetTestingFactory(
+ &profile_, BuildChromeBookmarkClient);
if (bookmark_load_policy == LOAD_MODEL) {
- bookmark_model_ =
- static_cast<ChromeBookmarkClient*>(
- BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse(
- &profile_, BuildBookmarkModel))->model();
+ bookmark_model_ = static_cast<BookmarkModel*>(
+ BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse(
+ &profile_, BuildBookmarkModel));
test::WaitForBookmarkModelToLoad(bookmark_model_);
} else {
- bookmark_model_ =
- static_cast<ChromeBookmarkClient*>(
- BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse(
- &profile_, BuildBookmarkModelWithoutLoading))->model();
+ bookmark_model_ = static_cast<BookmarkModel*>(
+ BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse(
+ &profile_, BuildBookmarkModelWithoutLoading));
}
}

Powered by Google App Engine
This is Rietveld 408576698