| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <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 |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 event.Wait(); | 250 event.Wait(); |
| 251 } | 251 } |
| 252 | 252 |
| 253 private: | 253 private: |
| 254 virtual ~WebDataServiceFake() {} | 254 virtual ~WebDataServiceFake() {} |
| 255 | 255 |
| 256 void CreateSyncableService() { | 256 void CreateSyncableService() { |
| 257 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 257 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 258 // These services are deleted in DestroySyncableService(). | 258 // These services are deleted in DestroySyncableService(). |
| 259 AutocompleteSyncableService::CreateForWebDataService(this); | 259 AutocompleteSyncableService::CreateForWebDataService(this); |
| 260 AutofillProfileSyncableService::CreateForWebDataService(this); | 260 AutofillProfileSyncableService::CreateForWebDataService(this, "en-US"); |
| 261 | 261 |
| 262 autocomplete_syncable_service_ = | 262 autocomplete_syncable_service_ = |
| 263 AutocompleteSyncableService::FromWebDataService(this); | 263 AutocompleteSyncableService::FromWebDataService(this); |
| 264 autofill_profile_syncable_service_ = | 264 autofill_profile_syncable_service_ = |
| 265 AutofillProfileSyncableService::FromWebDataService(this); | 265 AutofillProfileSyncableService::FromWebDataService(this); |
| 266 | 266 |
| 267 syncable_service_created_or_destroyed_.Signal(); | 267 syncable_service_created_or_destroyed_.Signal(); |
| 268 } | 268 } |
| 269 | 269 |
| 270 void DestroySyncableService() { | 270 void DestroySyncableService() { |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 int timestamps_count = autofill.usage_timestamp_size(); | 626 int timestamps_count = autofill.usage_timestamp_size(); |
| 627 for (int i = 0; i < timestamps_count; ++i) { | 627 for (int i = 0; i < timestamps_count; ++i) { |
| 628 timestamps.push_back(Time::FromInternalValue( | 628 timestamps.push_back(Time::FromInternalValue( |
| 629 autofill.usage_timestamp(i))); | 629 autofill.usage_timestamp(i))); |
| 630 } | 630 } |
| 631 entries->push_back(AutofillEntry(key, timestamps)); | 631 entries->push_back(AutofillEntry(key, timestamps)); |
| 632 } else if (autofill.has_profile()) { | 632 } else if (autofill.has_profile()) { |
| 633 AutofillProfile p; | 633 AutofillProfile p; |
| 634 p.set_guid(autofill.profile().guid()); | 634 p.set_guid(autofill.profile().guid()); |
| 635 AutofillProfileSyncableService::OverwriteProfileWithServerData( | 635 AutofillProfileSyncableService::OverwriteProfileWithServerData( |
| 636 autofill.profile(), &p); | 636 autofill.profile(), &p, "en-US"); |
| 637 profiles->push_back(p); | 637 profiles->push_back(p); |
| 638 } | 638 } |
| 639 child_id = child_node.GetSuccessorId(); | 639 child_id = child_node.GetSuccessorId(); |
| 640 } | 640 } |
| 641 return true; | 641 return true; |
| 642 } | 642 } |
| 643 | 643 |
| 644 bool GetAutofillProfilesFromSyncDBUnderProfileNode( | 644 bool GetAutofillProfilesFromSyncDBUnderProfileNode( |
| 645 std::vector<AutofillProfile>* profiles) { | 645 std::vector<AutofillProfile>* profiles) { |
| 646 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 646 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
| 647 syncer::ReadNode autofill_root(&trans); | 647 syncer::ReadNode autofill_root(&trans); |
| 648 if (autofill_root.InitByTagLookup(kAutofillProfileTag) != | 648 if (autofill_root.InitByTagLookup(kAutofillProfileTag) != |
| 649 BaseNode::INIT_OK) { | 649 BaseNode::INIT_OK) { |
| 650 return false; | 650 return false; |
| 651 } | 651 } |
| 652 | 652 |
| 653 int64 child_id = autofill_root.GetFirstChildId(); | 653 int64 child_id = autofill_root.GetFirstChildId(); |
| 654 while (child_id != syncer::kInvalidId) { | 654 while (child_id != syncer::kInvalidId) { |
| 655 syncer::ReadNode child_node(&trans); | 655 syncer::ReadNode child_node(&trans); |
| 656 if (child_node.InitByIdLookup(child_id) != BaseNode::INIT_OK) | 656 if (child_node.InitByIdLookup(child_id) != BaseNode::INIT_OK) |
| 657 return false; | 657 return false; |
| 658 | 658 |
| 659 const sync_pb::AutofillProfileSpecifics& autofill( | 659 const sync_pb::AutofillProfileSpecifics& autofill( |
| 660 child_node.GetAutofillProfileSpecifics()); | 660 child_node.GetAutofillProfileSpecifics()); |
| 661 AutofillProfile p; | 661 AutofillProfile p; |
| 662 p.set_guid(autofill.guid()); | 662 p.set_guid(autofill.guid()); |
| 663 AutofillProfileSyncableService::OverwriteProfileWithServerData( | 663 AutofillProfileSyncableService::OverwriteProfileWithServerData( |
| 664 autofill, &p); | 664 autofill, &p, "en-US"); |
| 665 profiles->push_back(p); | 665 profiles->push_back(p); |
| 666 child_id = child_node.GetSuccessorId(); | 666 child_id = child_node.GetSuccessorId(); |
| 667 } | 667 } |
| 668 return true; | 668 return true; |
| 669 } | 669 } |
| 670 | 670 |
| 671 void SetIdleChangeProcessorExpectations() { | 671 void SetIdleChangeProcessorExpectations() { |
| 672 EXPECT_CALL(autofill_table_, RemoveFormElement(_, _)).Times(0); | 672 EXPECT_CALL(autofill_table_, RemoveFormElement(_, _)).Times(0); |
| 673 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _)).Times(0); | 673 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _)).Times(0); |
| 674 EXPECT_CALL(autofill_table_, UpdateAutofillEntries(_)).Times(0); | 674 EXPECT_CALL(autofill_table_, UpdateAutofillEntries(_)).Times(0); |
| (...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1348 std::vector<AutofillEntry> sync_entries; | 1348 std::vector<AutofillEntry> sync_entries; |
| 1349 std::vector<AutofillProfile> sync_profiles; | 1349 std::vector<AutofillProfile> sync_profiles; |
| 1350 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); | 1350 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); |
| 1351 EXPECT_EQ(3U, sync_entries.size()); | 1351 EXPECT_EQ(3U, sync_entries.size()); |
| 1352 EXPECT_EQ(0U, sync_profiles.size()); | 1352 EXPECT_EQ(0U, sync_profiles.size()); |
| 1353 for (size_t i = 0; i < sync_entries.size(); i++) { | 1353 for (size_t i = 0; i < sync_entries.size(); i++) { |
| 1354 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() | 1354 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() |
| 1355 << ", " << sync_entries[i].key().value(); | 1355 << ", " << sync_entries[i].key().value(); |
| 1356 } | 1356 } |
| 1357 } | 1357 } |
| OLD | NEW |