| Index: chrome/browser/sync/profile_sync_test_util.h
|
| diff --git a/chrome/browser/sync/profile_sync_test_util.h b/chrome/browser/sync/profile_sync_test_util.h
|
| index aa8584e58cbb01280e8b8612c275e66210d9f056..6e9b77a955d43940b586cfca9a74f1a2ce5b3882 100644
|
| --- a/chrome/browser/sync/profile_sync_test_util.h
|
| +++ b/chrome/browser/sync/profile_sync_test_util.h
|
| @@ -19,11 +19,13 @@
|
| #include "chrome/browser/browser_thread.h"
|
| #include "chrome/browser/profile.h"
|
| #include "chrome/browser/webdata/web_database.h"
|
| +#include "chrome/browser/sync/abstract_profile_sync_service_test.h"
|
| #include "chrome/browser/sync/glue/bookmark_change_processor.h"
|
| #include "chrome/browser/sync/glue/bookmark_data_type_controller.h"
|
| #include "chrome/browser/sync/glue/bookmark_model_associator.h"
|
| #include "chrome/browser/sync/glue/change_processor.h"
|
| #include "chrome/browser/sync/glue/data_type_manager_impl.h"
|
| +#include "chrome/browser/sync/glue/sync_backend_host.h"
|
| #include "chrome/browser/sync/profile_sync_factory.h"
|
| #include "chrome/browser/sync/profile_sync_service.h"
|
| #include "chrome/browser/sync/unrecoverable_error_handler.h"
|
| @@ -52,6 +54,8 @@ ACTION_P(InvokeTask, task) {
|
|
|
| class TestModelAssociatorHelper {
|
| public:
|
| + TestModelAssociatorHelper(browser_sync::TestIdFactory* id_factory)
|
| + : id_factory_(id_factory) {}
|
| template <class ModelAssociatorImpl>
|
| bool GetSyncIdForTaggedNode(ModelAssociatorImpl* associator,
|
| const std::string& tag, int64* sync_id) {
|
| @@ -61,10 +65,32 @@ class TestModelAssociatorHelper {
|
| return false;
|
| }
|
|
|
| - sync_api::WriteTransaction trans(
|
| + browser_sync::SyncBackendHost::UserShareHandle share(
|
| associator->sync_service()->backend()->GetUserShareHandle());
|
| + bool root_exists = false;
|
| + ModelType type = ModelAssociatorImpl::model_type();
|
| + {
|
| + sync_api::WriteTransaction trans(share);
|
| + sync_api::ReadNode uber_root(&trans);
|
| + uber_root.InitByRootLookup();
|
| +
|
| + // Look up the top level data type node.
|
| + sync_api::ReadNode root_lookup(&trans);
|
| + root_exists = root_lookup.InitByTagLookup(
|
| + ProfileSyncServiceTestHelper::GetTagForType(type));
|
| + }
|
| +
|
| + if (!root_exists) {
|
| + bool created = ProfileSyncServiceTestHelper::CreateRoot(type,
|
| + associator->sync_service(), id_factory_);
|
| + if (!created)
|
| + return false;
|
| + }
|
| +
|
| + sync_api::WriteTransaction trans(share);
|
| sync_api::ReadNode root(&trans);
|
| - root.InitByRootLookup();
|
| + EXPECT_TRUE(root.InitByTagLookup(
|
| + ProfileSyncServiceTestHelper::GetTagForType(type)));
|
|
|
| // First, try to find a node with the title among the root's children.
|
| // This will be the case if we are testing model persistence, and
|
| @@ -98,6 +124,8 @@ class TestModelAssociatorHelper {
|
| }
|
|
|
| ~TestModelAssociatorHelper() {}
|
| + private:
|
| + browser_sync::TestIdFactory* id_factory_;
|
| };
|
|
|
| class ProfileSyncServiceObserverMock : public ProfileSyncServiceObserver {
|
|
|