OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
| 11 #include "base/bind.h" |
11 #include "base/callback.h" | 12 #include "base/callback.h" |
12 #include "base/location.h" | 13 #include "base/location.h" |
13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
15 #include "base/message_loop.h" | 16 #include "base/message_loop.h" |
16 #include "base/string16.h" | 17 #include "base/string16.h" |
17 #include "base/synchronization/waitable_event.h" | 18 #include "base/synchronization/waitable_event.h" |
18 #include "base/task.h" | 19 #include "base/task.h" |
19 #include "base/time.h" | 20 #include "base/time.h" |
20 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 #include "content/browser/browser_thread.h" | 54 #include "content/browser/browser_thread.h" |
54 #include "content/common/notification_source.h" | 55 #include "content/common/notification_source.h" |
55 #include "testing/gmock/include/gmock/gmock.h" | 56 #include "testing/gmock/include/gmock/gmock.h" |
56 | 57 |
57 using base::Time; | 58 using base::Time; |
58 using base::WaitableEvent; | 59 using base::WaitableEvent; |
59 using browser_sync::AutofillChangeProcessor; | 60 using browser_sync::AutofillChangeProcessor; |
60 using browser_sync::AutofillDataTypeController; | 61 using browser_sync::AutofillDataTypeController; |
61 using browser_sync::AutofillModelAssociator; | 62 using browser_sync::AutofillModelAssociator; |
62 using browser_sync::AutofillProfileDataTypeController; | 63 using browser_sync::AutofillProfileDataTypeController; |
63 using browser_sync::AutofillProfileSyncableService; | |
64 using browser_sync::DataTypeController; | 64 using browser_sync::DataTypeController; |
65 using browser_sync::GenericChangeProcessor; | 65 using browser_sync::GenericChangeProcessor; |
66 using browser_sync::SyncableServiceAdapter; | 66 using browser_sync::SyncableServiceAdapter; |
67 using browser_sync::GROUP_DB; | 67 using browser_sync::GROUP_DB; |
68 using browser_sync::kAutofillTag; | 68 using browser_sync::kAutofillTag; |
69 using browser_sync::SyncBackendHostForProfileSyncTest; | 69 using browser_sync::SyncBackendHostForProfileSyncTest; |
70 using browser_sync::UnrecoverableErrorHandler; | 70 using browser_sync::UnrecoverableErrorHandler; |
71 using syncable::CREATE_NEW_UPDATE_ITEM; | 71 using syncable::CREATE_NEW_UPDATE_ITEM; |
72 using syncable::AUTOFILL; | 72 using syncable::AUTOFILL; |
73 using syncable::BASE_VERSION; | 73 using syncable::BASE_VERSION; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 } | 146 } |
147 | 147 |
148 template<> | 148 template<> |
149 syncable::ModelType GetModelType<AutofillProfile>() { | 149 syncable::ModelType GetModelType<AutofillProfile>() { |
150 return syncable::AUTOFILL_PROFILE; | 150 return syncable::AUTOFILL_PROFILE; |
151 } | 151 } |
152 | 152 |
153 class WebDataServiceFake : public WebDataService { | 153 class WebDataServiceFake : public WebDataService { |
154 public: | 154 public: |
155 explicit WebDataServiceFake(WebDatabase* web_database) | 155 explicit WebDataServiceFake(WebDatabase* web_database) |
156 : web_database_(web_database) {} | 156 : web_database_(web_database), |
| 157 syncable_service_created_or_destroyed_(false, false) { |
| 158 } |
| 159 |
| 160 void StartSyncableService() { |
| 161 // The |autofill_profile_syncable_service_| must be constructed on the DB |
| 162 // thread. |
| 163 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
| 164 base::Bind(&WebDataServiceFake::CreateSyncableService, |
| 165 base::Unretained(this))); |
| 166 syncable_service_created_or_destroyed_.Wait(); |
| 167 } |
| 168 |
| 169 void ShutdownSyncableService() { |
| 170 // The |autofill_profile_syncable_service_| must be destructed on the DB |
| 171 // thread. |
| 172 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
| 173 base::Bind(&WebDataServiceFake::DestroySyncableService, |
| 174 base::Unretained(this))); |
| 175 syncable_service_created_or_destroyed_.Wait(); |
| 176 } |
| 177 |
157 virtual bool IsDatabaseLoaded() { | 178 virtual bool IsDatabaseLoaded() { |
158 return true; | 179 return true; |
159 } | 180 } |
160 | 181 |
161 virtual WebDatabase* GetDatabase() { | 182 virtual WebDatabase* GetDatabase() { |
162 return web_database_; | 183 return web_database_; |
163 } | 184 } |
164 | 185 |
| 186 virtual AutofillProfileSyncableService* |
| 187 GetAutofillProfileSyncableService() const OVERRIDE { |
| 188 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 189 EXPECT_TRUE(autofill_profile_syncable_service_); |
| 190 |
| 191 return autofill_profile_syncable_service_; |
| 192 } |
| 193 |
165 private: | 194 private: |
| 195 void CreateSyncableService() { |
| 196 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 197 autofill_profile_syncable_service_ = |
| 198 new AutofillProfileSyncableService(this); |
| 199 syncable_service_created_or_destroyed_.Signal(); |
| 200 } |
| 201 |
| 202 void DestroySyncableService() { |
| 203 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 204 delete autofill_profile_syncable_service_; |
| 205 syncable_service_created_or_destroyed_.Signal(); |
| 206 } |
| 207 |
166 WebDatabase* web_database_; | 208 WebDatabase* web_database_; |
| 209 |
| 210 // We own the syncable service, but don't use a |scoped_ptr| because the |
| 211 // lifetime must be managed on the DB thread. |
| 212 AutofillProfileSyncableService* autofill_profile_syncable_service_; |
| 213 WaitableEvent syncable_service_created_or_destroyed_; |
167 }; | 214 }; |
168 | 215 |
169 ACTION_P3(MakeAutofillSyncComponents, service, wd, dtc) { | 216 ACTION_P3(MakeAutofillSyncComponents, service, wd, dtc) { |
170 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 217 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
171 if (!BrowserThread::CurrentlyOn(BrowserThread::DB)) | 218 if (!BrowserThread::CurrentlyOn(BrowserThread::DB)) |
172 return ProfileSyncFactory::SyncComponents(NULL, NULL); | 219 return ProfileSyncFactory::SyncComponents(NULL, NULL); |
173 AutofillModelAssociator* model_associator = | 220 AutofillModelAssociator* model_associator = |
174 new AutofillModelAssociator(service, wd, service->profile()); | 221 new AutofillModelAssociator(service, wd, service->profile()); |
175 AutofillChangeProcessor* change_processor = | 222 AutofillChangeProcessor* change_processor = |
176 new AutofillChangeProcessor(model_associator, wd, | 223 new AutofillChangeProcessor(model_associator, wd, |
177 service->profile(), dtc); | 224 service->profile(), dtc); |
178 return ProfileSyncFactory::SyncComponents(model_associator, | 225 return ProfileSyncFactory::SyncComponents(model_associator, |
179 change_processor); | 226 change_processor); |
180 } | 227 } |
181 | 228 |
182 ACTION_P3(MakeAutofillProfileSyncComponents, service, wds, dtc) { | 229 ACTION_P3(MakeAutofillProfileSyncComponents, service, wds, dtc) { |
183 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 230 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
184 if (!BrowserThread::CurrentlyOn(BrowserThread::DB)) | 231 if (!BrowserThread::CurrentlyOn(BrowserThread::DB)) |
185 return ProfileSyncFactory::SyncComponents(NULL, NULL); | 232 return ProfileSyncFactory::SyncComponents(NULL, NULL); |
186 AutofillProfileSyncableService* sync_service = | 233 AutofillProfileSyncableService* sync_service = |
187 new AutofillProfileSyncableService(wds); | 234 wds->GetAutofillProfileSyncableService(); |
188 sync_api::UserShare* user_share = service->GetUserShare(); | 235 sync_api::UserShare* user_share = service->GetUserShare(); |
189 GenericChangeProcessor* change_processor = | 236 GenericChangeProcessor* change_processor = |
190 new GenericChangeProcessor(sync_service, dtc, user_share); | 237 new GenericChangeProcessor(sync_service, dtc, user_share); |
191 SyncableServiceAdapter* sync_service_adapter = | 238 SyncableServiceAdapter* sync_service_adapter = |
192 new SyncableServiceAdapter(syncable::AUTOFILL_PROFILE, | 239 new SyncableServiceAdapter(syncable::AUTOFILL_PROFILE, |
193 sync_service, | 240 sync_service, |
194 change_processor); | 241 change_processor); |
195 return ProfileSyncFactory::SyncComponents(sync_service_adapter, | 242 return ProfileSyncFactory::SyncComponents(sync_service_adapter, |
196 change_processor); | 243 change_processor); |
197 } | 244 } |
(...skipping 10 matching lines...) Expand all Loading... |
208 DataTypeController* dtc) = 0; | 255 DataTypeController* dtc) = 0; |
209 virtual ~AbstractAutofillFactory() {} | 256 virtual ~AbstractAutofillFactory() {} |
210 }; | 257 }; |
211 | 258 |
212 class AutofillEntryFactory : public AbstractAutofillFactory { | 259 class AutofillEntryFactory : public AbstractAutofillFactory { |
213 public: | 260 public: |
214 browser_sync::AutofillDataTypeController* CreateDataTypeController( | 261 browser_sync::AutofillDataTypeController* CreateDataTypeController( |
215 ProfileSyncFactory* factory, | 262 ProfileSyncFactory* factory, |
216 ProfileMock* profile, | 263 ProfileMock* profile, |
217 ProfileSyncService* service) { | 264 ProfileSyncService* service) { |
218 return new AutofillDataTypeController(factory, | 265 return new AutofillDataTypeController(factory, profile); |
219 profile); | |
220 } | 266 } |
221 | 267 |
222 void SetExpectation(ProfileSyncFactoryMock* factory, | 268 void SetExpectation(ProfileSyncFactoryMock* factory, |
223 ProfileSyncService* service, | 269 ProfileSyncService* service, |
224 WebDataService* wds, | 270 WebDataService* wds, |
225 DataTypeController* dtc) { | 271 DataTypeController* dtc) { |
226 EXPECT_CALL(*factory, CreateAutofillSyncComponents(_,_,_)). | 272 EXPECT_CALL(*factory, CreateAutofillSyncComponents(_,_,_)). |
227 WillOnce(MakeAutofillSyncComponents(service, wds->GetDatabase(), dtc)); | 273 WillOnce(MakeAutofillSyncComponents(service, wds->GetDatabase(), dtc)); |
228 } | 274 } |
229 }; | 275 }; |
230 | 276 |
231 class AutofillProfileFactory : public AbstractAutofillFactory { | 277 class AutofillProfileFactory : public AbstractAutofillFactory { |
232 public: | 278 public: |
233 browser_sync::AutofillDataTypeController* CreateDataTypeController( | 279 browser_sync::AutofillDataTypeController* CreateDataTypeController( |
234 ProfileSyncFactory* factory, | 280 ProfileSyncFactory* factory, |
235 ProfileMock* profile, | 281 ProfileMock* profile, |
236 ProfileSyncService* service) { | 282 ProfileSyncService* service) { |
237 return new AutofillProfileDataTypeController(factory, | 283 return new AutofillProfileDataTypeController(factory, profile); |
238 profile); | |
239 } | 284 } |
240 | 285 |
241 void SetExpectation(ProfileSyncFactoryMock* factory, | 286 void SetExpectation(ProfileSyncFactoryMock* factory, |
242 ProfileSyncService* service, | 287 ProfileSyncService* service, |
243 WebDataService* wds, | 288 WebDataService* wds, |
244 DataTypeController* dtc) { | 289 DataTypeController* dtc) { |
245 EXPECT_CALL(*factory, CreateAutofillProfileSyncComponents(_,_,_)). | 290 EXPECT_CALL(*factory, CreateAutofillProfileSyncComponents(_,_,_)). |
246 WillOnce(MakeAutofillProfileSyncComponents(service, wds, dtc)); | 291 WillOnce(MakeAutofillProfileSyncComponents(service, wds, dtc)); |
247 } | 292 } |
248 }; | 293 }; |
249 | 294 |
250 class PersonalDataManagerMock: public PersonalDataManager { | 295 class PersonalDataManagerMock: public PersonalDataManager { |
251 public: | 296 public: |
252 static ProfileKeyedService* Build(Profile* profile) { | 297 static ProfileKeyedService* Build(Profile* profile) { |
253 return new PersonalDataManagerMock; | 298 return new PersonalDataManagerMock; |
254 } | 299 } |
255 | 300 |
256 MOCK_CONST_METHOD0(IsDataLoaded, bool()); | 301 MOCK_CONST_METHOD0(IsDataLoaded, bool()); |
257 MOCK_METHOD0(LoadProfiles, void()); | 302 MOCK_METHOD0(LoadProfiles, void()); |
258 MOCK_METHOD0(LoadCreditCards, void()); | 303 MOCK_METHOD0(LoadCreditCards, void()); |
259 MOCK_METHOD0(Refresh, void()); | 304 MOCK_METHOD0(Refresh, void()); |
260 }; | 305 }; |
261 template <class T> class AddAutofillTask; | 306 template <class T> class AddAutofillTask; |
262 | 307 |
263 class ProfileSyncServiceAutofillTest : public AbstractProfileSyncServiceTest { | 308 class ProfileSyncServiceAutofillTest : public AbstractProfileSyncServiceTest { |
264 protected: | 309 protected: |
265 ProfileSyncServiceAutofillTest() {} | 310 ProfileSyncServiceAutofillTest() { |
| 311 } |
266 | 312 |
267 AutofillProfileFactory profile_factory_; | 313 AutofillProfileFactory profile_factory_; |
268 AutofillEntryFactory entry_factory_; | 314 AutofillEntryFactory entry_factory_; |
269 | 315 |
270 AbstractAutofillFactory* GetFactory(syncable::ModelType type) { | 316 AbstractAutofillFactory* GetFactory(syncable::ModelType type) { |
271 if (type == syncable::AUTOFILL) { | 317 if (type == syncable::AUTOFILL) { |
272 return &entry_factory_; | 318 return &entry_factory_; |
273 } else if (type == syncable::AUTOFILL_PROFILE) { | 319 } else if (type == syncable::AUTOFILL_PROFILE) { |
274 return &profile_factory_; | 320 return &profile_factory_; |
275 } else { | 321 } else { |
(...skipping 15 matching lines...) Expand all Loading... |
291 EXPECT_CALL(profile_, GetWebDataService(_)). | 337 EXPECT_CALL(profile_, GetWebDataService(_)). |
292 // TokenService::Initialize | 338 // TokenService::Initialize |
293 // AutofillDataTypeController::StartModels() | 339 // AutofillDataTypeController::StartModels() |
294 // In some tests: | 340 // In some tests: |
295 // AutofillProfileSyncableService::AutofillProfileSyncableService() | 341 // AutofillProfileSyncableService::AutofillProfileSyncableService() |
296 WillRepeatedly(Return(web_data_service_.get())); | 342 WillRepeatedly(Return(web_data_service_.get())); |
297 personal_data_manager_->Init(&profile_); | 343 personal_data_manager_->Init(&profile_); |
298 | 344 |
299 notification_service_ = new ThreadNotificationService(&db_thread_); | 345 notification_service_ = new ThreadNotificationService(&db_thread_); |
300 notification_service_->Init(); | 346 notification_service_->Init(); |
| 347 |
| 348 // Note: This must be called *after* the notification service is created. |
| 349 web_data_service_->StartSyncableService(); |
301 } | 350 } |
302 | 351 |
303 virtual void TearDown() { | 352 virtual void TearDown() { |
| 353 // Note: The tear down order is important. |
304 service_.reset(); | 354 service_.reset(); |
| 355 web_data_service_->ShutdownSyncableService(); |
305 notification_service_->TearDown(); | 356 notification_service_->TearDown(); |
306 profile_.ResetRequestContext(); | 357 profile_.ResetRequestContext(); |
307 AbstractProfileSyncServiceTest::TearDown(); | 358 AbstractProfileSyncServiceTest::TearDown(); |
308 } | 359 } |
309 | 360 |
310 void StartSyncService(Task* task, | 361 void StartSyncService(Task* task, |
311 bool will_fail_association, | 362 bool will_fail_association, |
312 syncable::ModelType type) { | 363 syncable::ModelType type) { |
313 AbstractAutofillFactory* factory = GetFactory(type); | 364 AbstractAutofillFactory* factory = GetFactory(type); |
314 service_.reset( | 365 service_.reset( |
(...skipping 13 matching lines...) Expand all Loading... |
328 web_data_service_.get(), | 379 web_data_service_.get(), |
329 data_type_controller); | 380 data_type_controller); |
330 | 381 |
331 EXPECT_CALL(factory_, CreateDataTypeManager(_, _)). | 382 EXPECT_CALL(factory_, CreateDataTypeManager(_, _)). |
332 WillOnce(ReturnNewDataTypeManager()); | 383 WillOnce(ReturnNewDataTypeManager()); |
333 | 384 |
334 EXPECT_CALL(*personal_data_manager_, IsDataLoaded()). | 385 EXPECT_CALL(*personal_data_manager_, IsDataLoaded()). |
335 WillRepeatedly(Return(true)); | 386 WillRepeatedly(Return(true)); |
336 | 387 |
337 // We need tokens to get the tests going | 388 // We need tokens to get the tests going |
338 token_service_->IssueAuthTokenForTest( | 389 token_service_->IssueAuthTokenForTest(GaiaConstants::kSyncService, "token"); |
339 GaiaConstants::kSyncService, "token"); | |
340 | 390 |
341 EXPECT_CALL(profile_, GetTokenService()). | 391 EXPECT_CALL(profile_, GetTokenService()). |
342 WillRepeatedly(Return(token_service_.get())); | 392 WillRepeatedly(Return(token_service_.get())); |
343 | 393 |
344 service_->RegisterDataTypeController(data_type_controller); | 394 service_->RegisterDataTypeController(data_type_controller); |
345 service_->Initialize(); | 395 service_->Initialize(); |
346 MessageLoop::current()->Run(); | 396 MessageLoop::current()->Run(); |
347 } | 397 } |
348 | 398 |
349 bool AddAutofillSyncNode(const AutofillEntry& entry) { | 399 bool AddAutofillSyncNode(const AutofillEntry& entry) { |
350 sync_api::WriteTransaction trans(FROM_HERE, service_->GetUserShare()); | 400 sync_api::WriteTransaction trans(FROM_HERE, service_->GetUserShare()); |
351 sync_api::ReadNode autofill_root(&trans); | 401 sync_api::ReadNode autofill_root(&trans); |
352 if (!autofill_root.InitByTagLookup(browser_sync::kAutofillTag)) | 402 if (!autofill_root.InitByTagLookup(browser_sync::kAutofillTag)) |
353 return false; | 403 return false; |
354 | 404 |
355 sync_api::WriteNode node(&trans); | 405 sync_api::WriteNode node(&trans); |
356 std::string tag = AutofillModelAssociator::KeyToTag(entry.key().name(), | 406 std::string tag = AutofillModelAssociator::KeyToTag(entry.key().name(), |
357 entry.key().value()); | 407 entry.key().value()); |
358 if (!node.InitUniqueByCreation(syncable::AUTOFILL, autofill_root, tag)) | 408 if (!node.InitUniqueByCreation(syncable::AUTOFILL, autofill_root, tag)) |
359 return false; | 409 return false; |
360 | 410 |
361 AutofillChangeProcessor::WriteAutofillEntry(entry, &node); | 411 AutofillChangeProcessor::WriteAutofillEntry(entry, &node); |
362 return true; | 412 return true; |
363 } | 413 } |
364 | 414 |
365 bool AddAutofillSyncNode(const AutofillProfile& profile) { | 415 bool AddAutofillSyncNode(const AutofillProfile& profile) { |
366 sync_api::WriteTransaction trans(FROM_HERE, service_->GetUserShare()); | 416 sync_api::WriteTransaction trans(FROM_HERE, service_->GetUserShare()); |
367 sync_api::ReadNode autofill_root(&trans); | 417 sync_api::ReadNode autofill_root(&trans); |
368 if (!autofill_root.InitByTagLookup(browser_sync::kAutofillProfileTag)) | 418 if (!autofill_root.InitByTagLookup(kAutofillProfileTag)) |
369 return false; | 419 return false; |
370 sync_api::WriteNode node(&trans); | 420 sync_api::WriteNode node(&trans); |
371 std::string tag = profile.guid(); | 421 std::string tag = profile.guid(); |
372 if (!node.InitUniqueByCreation(syncable::AUTOFILL_PROFILE, | 422 if (!node.InitUniqueByCreation(syncable::AUTOFILL_PROFILE, |
373 autofill_root, tag)) | 423 autofill_root, tag)) |
374 return false; | 424 return false; |
375 sync_pb::EntitySpecifics specifics; | 425 sync_pb::EntitySpecifics specifics; |
376 AutofillProfileSyncableService::WriteAutofillProfile(profile, &specifics); | 426 AutofillProfileSyncableService::WriteAutofillProfile(profile, &specifics); |
377 sync_pb::AutofillProfileSpecifics* profile_specifics = | 427 sync_pb::AutofillProfileSpecifics* profile_specifics = |
378 specifics.MutableExtension(sync_pb::autofill_profile); | 428 specifics.MutableExtension(sync_pb::autofill_profile); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 } | 464 } |
415 child_id = child_node.GetSuccessorId(); | 465 child_id = child_node.GetSuccessorId(); |
416 } | 466 } |
417 return true; | 467 return true; |
418 } | 468 } |
419 | 469 |
420 bool GetAutofillProfilesFromSyncDBUnderProfileNode( | 470 bool GetAutofillProfilesFromSyncDBUnderProfileNode( |
421 std::vector<AutofillProfile>* profiles) { | 471 std::vector<AutofillProfile>* profiles) { |
422 sync_api::ReadTransaction trans(FROM_HERE, service_->GetUserShare()); | 472 sync_api::ReadTransaction trans(FROM_HERE, service_->GetUserShare()); |
423 sync_api::ReadNode autofill_root(&trans); | 473 sync_api::ReadNode autofill_root(&trans); |
424 if (!autofill_root.InitByTagLookup(browser_sync::kAutofillProfileTag)) | 474 if (!autofill_root.InitByTagLookup(kAutofillProfileTag)) |
425 return false; | 475 return false; |
426 | 476 |
427 int64 child_id = autofill_root.GetFirstChildId(); | 477 int64 child_id = autofill_root.GetFirstChildId(); |
428 while (child_id != sync_api::kInvalidId) { | 478 while (child_id != sync_api::kInvalidId) { |
429 sync_api::ReadNode child_node(&trans); | 479 sync_api::ReadNode child_node(&trans); |
430 if (!child_node.InitByIdLookup(child_id)) | 480 if (!child_node.InitByIdLookup(child_id)) |
431 return false; | 481 return false; |
432 | 482 |
433 const sync_pb::AutofillProfileSpecifics& autofill( | 483 const sync_pb::AutofillProfileSpecifics& autofill( |
434 child_node.GetAutofillProfileSpecifics()); | 484 child_node.GetAutofillProfileSpecifics()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 | 519 |
470 friend class AddAutofillTask<AutofillEntry>; | 520 friend class AddAutofillTask<AutofillEntry>; |
471 friend class AddAutofillTask<AutofillProfile>; | 521 friend class AddAutofillTask<AutofillProfile>; |
472 friend class FakeServerUpdater; | 522 friend class FakeServerUpdater; |
473 | 523 |
474 scoped_refptr<ThreadNotificationService> notification_service_; | 524 scoped_refptr<ThreadNotificationService> notification_service_; |
475 | 525 |
476 ProfileMock profile_; | 526 ProfileMock profile_; |
477 AutofillTableMock autofill_table_; | 527 AutofillTableMock autofill_table_; |
478 scoped_ptr<WebDatabaseFake> web_database_; | 528 scoped_ptr<WebDatabaseFake> web_database_; |
479 scoped_refptr<WebDataService> web_data_service_; | 529 scoped_refptr<WebDataServiceFake> web_data_service_; |
480 PersonalDataManagerMock* personal_data_manager_; | 530 PersonalDataManagerMock* personal_data_manager_; |
481 }; | 531 }; |
482 | 532 |
483 template <class T> | 533 template <class T> |
484 class AddAutofillTask : public Task { | 534 class AddAutofillTask : public Task { |
485 public: | 535 public: |
486 AddAutofillTask(ProfileSyncServiceAutofillTest* test, | 536 AddAutofillTask(ProfileSyncServiceAutofillTest* test, |
487 const std::vector<T>& entries) | 537 const std::vector<T>& entries) |
488 : test_(test), entries_(entries), success_(false) { | 538 : test_(test), entries_(entries), success_(false) { |
489 } | 539 } |
490 | 540 |
491 virtual void Run() { | 541 virtual void Run() { |
492 if (!test_->CreateRoot(GetModelType<T>())) | 542 if (!test_->CreateRoot(GetModelType<T>())) |
493 return; | 543 return; |
494 for (size_t i = 0; i < entries_.size(); ++i) { | 544 for (size_t i = 0; i < entries_.size(); ++i) { |
495 if (!test_->AddAutofillSyncNode(entries_[i])) | 545 if (!test_->AddAutofillSyncNode(entries_[i])) |
496 return; | 546 return; |
497 } | 547 } |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1093 std::vector<AutofillEntry> sync_entries; | 1143 std::vector<AutofillEntry> sync_entries; |
1094 std::vector<AutofillProfile> sync_profiles; | 1144 std::vector<AutofillProfile> sync_profiles; |
1095 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); | 1145 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); |
1096 EXPECT_EQ(3U, sync_entries.size()); | 1146 EXPECT_EQ(3U, sync_entries.size()); |
1097 EXPECT_EQ(0U, sync_profiles.size()); | 1147 EXPECT_EQ(0U, sync_profiles.size()); |
1098 for (size_t i = 0; i < sync_entries.size(); i++) { | 1148 for (size_t i = 0; i < sync_entries.size(); i++) { |
1099 VLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() | 1149 VLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() |
1100 << ", " << sync_entries[i].key().value(); | 1150 << ", " << sync_entries[i].key().value(); |
1101 } | 1151 } |
1102 } | 1152 } |
OLD | NEW |