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

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

Issue 10911073: NOT FOR COMMIT: Add DeviceInfo type and ChangeProcessor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix several issues Created 8 years, 3 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
« no previous file with comments | « chrome/browser/sync/abstract_profile_sync_service_test.h ('k') | chrome/browser/sync/glue/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" 5 #include "chrome/browser/sync/abstract_profile_sync_service_test.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "chrome/browser/sync/test_profile_sync_service.h" 10 #include "chrome/browser/sync/test_profile_sync_service.h"
11 #include "sync/internal_api/public/test/test_user_share.h"
11 #include "sync/internal_api/public/write_transaction.h" 12 #include "sync/internal_api/public/write_transaction.h"
12 #include "sync/protocol/sync.pb.h" 13 #include "sync/protocol/sync.pb.h"
13 #include "sync/syncable/entry.h" 14 #include "sync/syncable/entry.h"
14 #include "sync/syncable/mutable_entry.h" 15 #include "sync/syncable/mutable_entry.h"
15 #include "sync/syncable/write_transaction.h" 16 #include "sync/syncable/write_transaction.h"
16 #include "sync/test/engine/test_id_factory.h" 17 #include "sync/test/engine/test_id_factory.h"
17 #include "sync/util/cryptographer.h" 18 #include "sync/util/cryptographer.h"
18 19
19 using syncer::TestIdFactory; 20 using syncer::TestIdFactory;
20 using content::BrowserThread; 21 using content::BrowserThread;
21 using syncer::ModelType; 22 using syncer::ModelType;
22 using syncer::UserShare; 23 using syncer::UserShare;
23 using syncer::syncable::BASE_VERSION; 24 using syncer::syncable::BASE_VERSION;
24 using syncer::syncable::CREATE; 25 using syncer::syncable::CREATE;
25 using syncer::syncable::IS_DEL; 26 using syncer::syncable::IS_DEL;
26 using syncer::syncable::IS_DIR; 27 using syncer::syncable::IS_DIR;
27 using syncer::syncable::IS_UNAPPLIED_UPDATE; 28 using syncer::syncable::IS_UNAPPLIED_UPDATE;
28 using syncer::syncable::IS_UNSYNCED; 29 using syncer::syncable::IS_UNSYNCED;
29 using syncer::syncable::MutableEntry; 30 using syncer::syncable::MutableEntry;
30 using syncer::syncable::SERVER_IS_DIR; 31 using syncer::syncable::SERVER_IS_DIR;
31 using syncer::syncable::SERVER_VERSION; 32 using syncer::syncable::SERVER_VERSION;
32 using syncer::syncable::SPECIFICS; 33 using syncer::syncable::SPECIFICS;
33 using syncer::syncable::UNIQUE_SERVER_TAG; 34 using syncer::syncable::UNIQUE_SERVER_TAG;
34 using syncer::syncable::UNITTEST; 35 using syncer::syncable::UNITTEST;
35 using syncer::syncable::WriteTransaction; 36 using syncer::syncable::WriteTransaction;
36 37
37 /* static */ 38 /* static */
38 const std::string ProfileSyncServiceTestHelper::GetTagForType(
39 ModelType model_type) {
40 return syncer::ModelTypeToRootTag(model_type);
41 }
42
43 /* static */
44 bool ProfileSyncServiceTestHelper::CreateRoot(ModelType model_type,
45 UserShare* user_share,
46 TestIdFactory* ids) {
47 syncer::syncable::Directory* directory = user_share->directory.get();
48
49 std::string tag_name = GetTagForType(model_type);
50
51 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory);
52 MutableEntry node(&wtrans,
53 CREATE,
54 wtrans.root_id(),
55 tag_name);
56 node.Put(UNIQUE_SERVER_TAG, tag_name);
57 node.Put(IS_DIR, true);
58 node.Put(SERVER_IS_DIR, false);
59 node.Put(IS_UNSYNCED, false);
60 node.Put(IS_UNAPPLIED_UPDATE, false);
61 node.Put(SERVER_VERSION, 20);
62 node.Put(BASE_VERSION, 20);
63 node.Put(IS_DEL, false);
64 node.Put(syncer::syncable::ID, ids->MakeServer(tag_name));
65 sync_pb::EntitySpecifics specifics;
66 syncer::AddDefaultFieldValue(model_type, &specifics);
67 node.Put(SPECIFICS, specifics);
68
69 return true;
70 }
71
72 /* static */
73 syncer::ImmutableChangeRecordList 39 syncer::ImmutableChangeRecordList
74 ProfileSyncServiceTestHelper::MakeSingletonChangeRecordList( 40 ProfileSyncServiceTestHelper::MakeSingletonChangeRecordList(
75 int64 node_id, syncer::ChangeRecord::Action action) { 41 int64 node_id, syncer::ChangeRecord::Action action) {
76 syncer::ChangeRecord record; 42 syncer::ChangeRecord record;
77 record.action = action; 43 record.action = action;
78 record.id = node_id; 44 record.id = node_id;
79 syncer::ChangeRecordList records(1, record); 45 syncer::ChangeRecordList records(1, record);
80 return syncer::ImmutableChangeRecordList(&records); 46 return syncer::ImmutableChangeRecordList(&records);
81 } 47 }
82 48
(...skipping 28 matching lines...) Expand all
111 // Pump messages posted by the sync core thread (which may end up 77 // Pump messages posted by the sync core thread (which may end up
112 // posting on the IO thread). 78 // posting on the IO thread).
113 ui_loop_.RunAllPending(); 79 ui_loop_.RunAllPending();
114 io_thread_.Stop(); 80 io_thread_.Stop();
115 file_thread_.Stop(); 81 file_thread_.Stop();
116 db_thread_.Stop(); 82 db_thread_.Stop();
117 ui_loop_.RunAllPending(); 83 ui_loop_.RunAllPending();
118 } 84 }
119 85
120 bool AbstractProfileSyncServiceTest::CreateRoot(ModelType model_type) { 86 bool AbstractProfileSyncServiceTest::CreateRoot(ModelType model_type) {
121 return ProfileSyncServiceTestHelper::CreateRoot( 87 return syncer::TestUserShare::CreateRoot(model_type,
122 model_type, 88 service_->GetUserShare());
123 service_->GetUserShare(),
124 service_->id_factory());
125 } 89 }
126 90
127 // static 91 // static
128 ProfileKeyedService* AbstractProfileSyncServiceTest::BuildTokenService( 92 ProfileKeyedService* AbstractProfileSyncServiceTest::BuildTokenService(
129 Profile* profile) { 93 Profile* profile) {
130 return new TokenService; 94 return new TokenService;
131 } 95 }
132 96
133 CreateRootHelper::CreateRootHelper(AbstractProfileSyncServiceTest* test, 97 CreateRootHelper::CreateRootHelper(AbstractProfileSyncServiceTest* test,
134 ModelType model_type) 98 ModelType model_type)
(...skipping 12 matching lines...) Expand all
147 return callback_; 111 return callback_;
148 } 112 }
149 113
150 bool CreateRootHelper::success() { 114 bool CreateRootHelper::success() {
151 return success_; 115 return success_;
152 } 116 }
153 117
154 void CreateRootHelper::CreateRootCallback() { 118 void CreateRootHelper::CreateRootCallback() {
155 success_ = test_->CreateRoot(model_type_); 119 success_ = test_->CreateRoot(model_type_);
156 } 120 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/abstract_profile_sync_service_test.h ('k') | chrome/browser/sync/glue/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698