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

Side by Side Diff: chrome/browser/sync/abstract_profile_sync_service_test.cc

Issue 6375007: [Sync] Refactored ProfileSyncService and remove its backend() function (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add comment Created 9 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 20111 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/sync/abstract_profile_sync_service_test.h"
6
7 #include "chrome/browser/sync/engine/syncapi.h"
8 #include "chrome/browser/sync/glue/autofill_model_associator.h"
9 #include "chrome/browser/sync/glue/autofill_profile_model_associator.h"
10 #include "chrome/browser/sync/glue/password_model_associator.h"
11 #include "chrome/browser/sync/glue/preference_model_associator.h"
12 #include "chrome/browser/sync/glue/session_model_associator.h"
13 #include "chrome/browser/sync/glue/typed_url_model_associator.h"
14 #include "chrome/browser/sync/protocol/sync.pb.h"
15 #include "chrome/browser/sync/syncable/directory_manager.h"
16 #include "chrome/browser/sync/syncable/syncable.h"
17 #include "chrome/browser/sync/test_profile_sync_service.h"
18 #include "chrome/browser/sync/util/cryptographer.h"
19 #include "chrome/test/profile_mock.h"
20 #include "chrome/test/sync/engine/test_id_factory.h"
21
22 using browser_sync::TestIdFactory;
23 using sync_api::UserShare;
24 using syncable::BASE_VERSION;
25 using syncable::CREATE;
26 using syncable::DirectoryManager;
27 using syncable::IS_DEL;
28 using syncable::IS_DIR;
29 using syncable::IS_UNAPPLIED_UPDATE;
30 using syncable::IS_UNSYNCED;
31 using syncable::ModelType;
32 using syncable::MutableEntry;
33 using syncable::SERVER_IS_DIR;
34 using syncable::SERVER_VERSION;
35 using syncable::SPECIFICS;
36 using syncable::ScopedDirLookup;
37 using syncable::UNIQUE_SERVER_TAG;
38 using syncable::UNITTEST;
39 using syncable::WriteTransaction;
40
41 const std::string ProfileSyncServiceTestHelper::GetTagForType(
42 ModelType model_type) {
43 switch (model_type) {
44 case syncable::AUTOFILL:
45 return browser_sync::kAutofillTag;
46 case syncable::AUTOFILL_PROFILE:
47 return browser_sync::kAutofillProfileTag;
48 case syncable::PREFERENCES:
49 return browser_sync::kPreferencesTag;
50 case syncable::PASSWORDS:
51 return browser_sync::kPasswordTag;
52 case syncable::NIGORI:
53 return browser_sync::kNigoriTag;
54 case syncable::TYPED_URLS:
55 return browser_sync::kTypedUrlTag;
56 case syncable::SESSIONS:
57 return browser_sync::kSessionsTag;
58 case syncable::BOOKMARKS:
59 return "google_chrome_bookmarks";
60 default:
61 NOTREACHED();
62 }
63 return std::string();
64 }
65
66 bool ProfileSyncServiceTestHelper::CreateRoot(
67 ModelType model_type, UserShare* user_share,
68 TestIdFactory* ids) {
69 DirectoryManager* dir_manager = user_share->dir_manager.get();
70
71 ScopedDirLookup dir(dir_manager, user_share->name);
72 if (!dir.good())
73 return false;
74
75 std::string tag_name = GetTagForType(model_type);
76
77 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__);
78 MutableEntry node(&wtrans,
79 CREATE,
80 wtrans.root_id(),
81 tag_name);
82 node.Put(UNIQUE_SERVER_TAG, tag_name);
83 node.Put(IS_DIR, true);
84 node.Put(SERVER_IS_DIR, false);
85 node.Put(IS_UNSYNCED, false);
86 node.Put(IS_UNAPPLIED_UPDATE, false);
87 node.Put(SERVER_VERSION, 20);
88 node.Put(BASE_VERSION, 20);
89 node.Put(IS_DEL, false);
90 node.Put(syncable::ID, ids->MakeServer(tag_name));
91 sync_pb::EntitySpecifics specifics;
92 syncable::AddDefaultExtensionValue(model_type, &specifics);
93 node.Put(SPECIFICS, specifics);
94
95 return true;
96 }
97
98 AbstractProfileSyncServiceTest::AbstractProfileSyncServiceTest()
99 : ui_thread_(BrowserThread::UI, &message_loop_) {}
100
101 bool AbstractProfileSyncServiceTest::CreateRoot(ModelType model_type) {
102 return ProfileSyncServiceTestHelper::CreateRoot(
103 model_type,
104 service_->GetUserShare(),
105 service_->id_factory());
106 }
107
108 CreateRootTask::CreateRootTask(
109 AbstractProfileSyncServiceTest* test, ModelType model_type)
110 : test_(test), model_type_(model_type), success_(false) {
111 }
112
113 CreateRootTask::~CreateRootTask() {}
114 void CreateRootTask::Run() {
115 success_ = test_->CreateRoot(model_type_);
116 }
117
118 bool CreateRootTask::success() {
119 return success_;
120 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/abstract_profile_sync_service_test.h ('k') | chrome/browser/sync/glue/autofill_model_associator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698