| 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 <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 association_stats_.num_sync_items_after_association); | 573 association_stats_.num_sync_items_after_association); |
| 574 } | 574 } |
| 575 EXPECT_EQ(association_stats_.num_sync_items_after_association, | 575 EXPECT_EQ(association_stats_.num_sync_items_after_association, |
| 576 association_stats_.num_sync_items_before_association + | 576 association_stats_.num_sync_items_before_association + |
| 577 association_stats_.num_sync_items_added - | 577 association_stats_.num_sync_items_added - |
| 578 association_stats_.num_sync_items_deleted); | 578 association_stats_.num_sync_items_deleted); |
| 579 } | 579 } |
| 580 | 580 |
| 581 bool AddAutofillSyncNode(const AutofillEntry& entry) { | 581 bool AddAutofillSyncNode(const AutofillEntry& entry) { |
| 582 syncer::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 582 syncer::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
| 583 syncer::ReadNode autofill_root(&trans); | |
| 584 if (autofill_root.InitTypeRoot(syncer::AUTOFILL) != BaseNode::INIT_OK) { | |
| 585 return false; | |
| 586 } | |
| 587 | |
| 588 syncer::WriteNode node(&trans); | 583 syncer::WriteNode node(&trans); |
| 589 std::string tag = AutocompleteSyncableService::KeyToTag( | 584 std::string tag = AutocompleteSyncableService::KeyToTag( |
| 590 base::UTF16ToUTF8(entry.key().name()), | 585 base::UTF16ToUTF8(entry.key().name()), |
| 591 base::UTF16ToUTF8(entry.key().value())); | 586 base::UTF16ToUTF8(entry.key().value())); |
| 592 syncer::WriteNode::InitUniqueByCreationResult result = | 587 syncer::WriteNode::InitUniqueByCreationResult result = |
| 593 node.InitUniqueByCreation(syncer::AUTOFILL, autofill_root, tag); | 588 node.InitUniqueByCreation(syncer::AUTOFILL, tag); |
| 594 if (result != syncer::WriteNode::INIT_SUCCESS) | 589 if (result != syncer::WriteNode::INIT_SUCCESS) |
| 595 return false; | 590 return false; |
| 596 | 591 |
| 597 sync_pb::EntitySpecifics specifics; | 592 sync_pb::EntitySpecifics specifics; |
| 598 AutocompleteSyncableService::WriteAutofillEntry(entry, &specifics); | 593 AutocompleteSyncableService::WriteAutofillEntry(entry, &specifics); |
| 599 node.SetEntitySpecifics(specifics); | 594 node.SetEntitySpecifics(specifics); |
| 600 return true; | 595 return true; |
| 601 } | 596 } |
| 602 | 597 |
| 603 bool AddAutofillSyncNode(const AutofillProfile& profile) { | 598 bool AddAutofillSyncNode(const AutofillProfile& profile) { |
| 604 syncer::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 599 syncer::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
| 605 syncer::ReadNode autofill_root(&trans); | |
| 606 if (autofill_root.InitTypeRoot(AUTOFILL_PROFILE) != BaseNode::INIT_OK) { | |
| 607 return false; | |
| 608 } | |
| 609 syncer::WriteNode node(&trans); | 600 syncer::WriteNode node(&trans); |
| 610 std::string tag = profile.guid(); | 601 std::string tag = profile.guid(); |
| 611 syncer::WriteNode::InitUniqueByCreationResult result = | 602 syncer::WriteNode::InitUniqueByCreationResult result = |
| 612 node.InitUniqueByCreation(syncer::AUTOFILL_PROFILE, | 603 node.InitUniqueByCreation(syncer::AUTOFILL_PROFILE, tag); |
| 613 autofill_root, tag); | |
| 614 if (result != syncer::WriteNode::INIT_SUCCESS) | 604 if (result != syncer::WriteNode::INIT_SUCCESS) |
| 615 return false; | 605 return false; |
| 616 | 606 |
| 617 sync_pb::EntitySpecifics specifics; | 607 sync_pb::EntitySpecifics specifics; |
| 618 AutofillProfileSyncableService::WriteAutofillProfile(profile, &specifics); | 608 AutofillProfileSyncableService::WriteAutofillProfile(profile, &specifics); |
| 619 node.SetEntitySpecifics(specifics); | 609 node.SetEntitySpecifics(specifics); |
| 620 return true; | 610 return true; |
| 621 } | 611 } |
| 622 | 612 |
| 623 bool GetAutofillEntriesFromSyncDB(std::vector<AutofillEntry>* entries, | 613 bool GetAutofillEntriesFromSyncDB(std::vector<AutofillEntry>* entries, |
| (...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1339 std::vector<AutofillEntry> sync_entries; | 1329 std::vector<AutofillEntry> sync_entries; |
| 1340 std::vector<AutofillProfile> sync_profiles; | 1330 std::vector<AutofillProfile> sync_profiles; |
| 1341 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); | 1331 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); |
| 1342 EXPECT_EQ(3U, sync_entries.size()); | 1332 EXPECT_EQ(3U, sync_entries.size()); |
| 1343 EXPECT_EQ(0U, sync_profiles.size()); | 1333 EXPECT_EQ(0U, sync_profiles.size()); |
| 1344 for (size_t i = 0; i < sync_entries.size(); i++) { | 1334 for (size_t i = 0; i < sync_entries.size(); i++) { |
| 1345 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() | 1335 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() |
| 1346 << ", " << sync_entries[i].key().value(); | 1336 << ", " << sync_entries[i].key().value(); |
| 1347 } | 1337 } |
| 1348 } | 1338 } |
| OLD | NEW |