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

Side by Side Diff: chrome/browser/webdata/autofill_profile_syncable_service_unittest.cc

Issue 127403002: [Autofill, Sync] Sync additional Autofill address fields for i18n. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 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
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 "base/location.h" 5 #include "base/location.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/webdata/autofill_profile_syncable_service.h" 8 #include "chrome/browser/webdata/autofill_profile_syncable_service.h"
9 #include "components/autofill/core/browser/autofill_profile.h" 9 #include "components/autofill/core/browser/autofill_profile.h"
10 #include "components/autofill/core/browser/webdata/autofill_change.h" 10 #include "components/autofill/core/browser/webdata/autofill_change.h"
11 #include "content/public/test/test_browser_thread.h" 11 #include "content/public/test/test_browser_thread.h"
12 #include "sync/api/sync_error_factory.h" 12 #include "sync/api/sync_error_factory.h"
13 #include "sync/api/sync_error_factory_mock.h" 13 #include "sync/api/sync_error_factory_mock.h"
14 #include "sync/protocol/sync.pb.h" 14 #include "sync/protocol/sync.pb.h"
15 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 namespace autofill { 18 namespace autofill {
19 19
20 using ::testing::_; 20 using ::testing::_;
21 using ::testing::DoAll; 21 using ::testing::DoAll;
22 using ::testing::Eq; 22 using ::testing::Eq;
23 using ::testing::Return; 23 using ::testing::Return;
24 using ::testing::Property; 24 using ::testing::Property;
25 using base::ASCIIToUTF16;
25 using base::UTF8ToUTF16; 26 using base::UTF8ToUTF16;
26 using content::BrowserThread; 27 using content::BrowserThread;
27 28
29 namespace {
30
28 // Some guids for testing. 31 // Some guids for testing.
29 const char kGuid1[] = "EDC609ED-7EEE-4F27-B00C-423242A9C44B"; 32 const char kGuid1[] = "EDC609ED-7EEE-4F27-B00C-423242A9C44B";
30 const char kGuid2[] = "EDC609ED-7EEE-4F27-B00C-423242A9C44C"; 33 const char kGuid2[] = "EDC609ED-7EEE-4F27-B00C-423242A9C44C";
31 const char kGuid3[] = "EDC609ED-7EEE-4F27-B00C-423242A9C44D"; 34 const char kGuid3[] = "EDC609ED-7EEE-4F27-B00C-423242A9C44D";
32 const char kGuid4[] = "EDC609ED-7EEE-4F27-B00C-423242A9C44E"; 35 const char kGuid4[] = "EDC609ED-7EEE-4F27-B00C-423242A9C44E";
33 const char kHttpOrigin[] = "http://www.example.com/"; 36 const char kHttpOrigin[] = "http://www.example.com/";
34 const char kHttpsOrigin[] = "https://www.example.com/"; 37 const char kHttpsOrigin[] = "https://www.example.com/";
35 const char kSettingsOrigin[] = "Chrome settings"; 38 const char kSettingsOrigin[] = "Chrome settings";
36 39
37 class MockAutofillProfileSyncableService 40 class MockAutofillProfileSyncableService
(...skipping 19 matching lines...) Expand all
57 MATCHER_P(CheckSyncChanges, n_sync_changes_list, "") { 60 MATCHER_P(CheckSyncChanges, n_sync_changes_list, "") {
58 if (arg.size() != n_sync_changes_list.size()) 61 if (arg.size() != n_sync_changes_list.size())
59 return false; 62 return false;
60 syncer::SyncChangeList::const_iterator passed, expected; 63 syncer::SyncChangeList::const_iterator passed, expected;
61 for (passed = arg.begin(), expected = n_sync_changes_list.begin(); 64 for (passed = arg.begin(), expected = n_sync_changes_list.begin();
62 passed != arg.end() && expected != n_sync_changes_list.end(); 65 passed != arg.end() && expected != n_sync_changes_list.end();
63 ++passed, ++expected) { 66 ++passed, ++expected) {
64 DCHECK(passed->IsValid()); 67 DCHECK(passed->IsValid());
65 if (passed->change_type() != expected->change_type()) 68 if (passed->change_type() != expected->change_type())
66 return false; 69 return false;
67 if (passed->sync_data().GetSpecifics().autofill_profile().guid() != 70 if (passed->sync_data().GetSpecifics().SerializeAsString() !=
68 expected->sync_data().GetSpecifics().autofill_profile().guid()) { 71 expected->sync_data().GetSpecifics().SerializeAsString()) {
69 return false; 72 return false;
70 } 73 }
71 } 74 }
72 return true; 75 return true;
73 } 76 }
74 77
75 MATCHER_P(DataBundleCheck, n_bundle, "") { 78 MATCHER_P(DataBundleCheck, n_bundle, "") {
76 if ((arg.profiles_to_delete.size() != n_bundle.profiles_to_delete.size()) || 79 if ((arg.profiles_to_delete.size() != n_bundle.profiles_to_delete.size()) ||
77 (arg.profiles_to_update.size() != n_bundle.profiles_to_update.size()) || 80 (arg.profiles_to_update.size() != n_bundle.profiles_to_update.size()) ||
78 (arg.profiles_to_add.size() != n_bundle.profiles_to_add.size())) 81 (arg.profiles_to_add.size() != n_bundle.profiles_to_add.size()))
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 OVERRIDE { 123 OVERRIDE {
121 return syncer::SyncDataList(); 124 return syncer::SyncDataList();
122 } 125 }
123 126
124 const syncer::SyncChangeList& changes() { return changes_; } 127 const syncer::SyncChangeList& changes() { return changes_; }
125 128
126 private: 129 private:
127 syncer::SyncChangeList changes_; 130 syncer::SyncChangeList changes_;
128 }; 131 };
129 132
133 // Returns a profile with all fields set. Contains identical data to the data
134 // returned from ConstructCompleteSyncData().
135 scoped_ptr<AutofillProfile> ConstructCompleteProfile() {
136 scoped_ptr<AutofillProfile> profile(
137 new AutofillProfile(kGuid1, kHttpsOrigin));
138
139 std::vector<base::string16> names;
140 names.push_back(ASCIIToUTF16("John K. Doe"));
141 names.push_back(ASCIIToUTF16("Jane Luise Smith"));
142 profile->SetRawMultiInfo(NAME_FULL, names);
143
144 std::vector<base::string16> emails;
145 emails.push_back(ASCIIToUTF16("user@example.com"));
146 emails.push_back(ASCIIToUTF16("superuser@example.org"));
147 profile->SetRawMultiInfo(EMAIL_ADDRESS, emails);
148
149 std::vector<base::string16> phones;
150 phones.push_back(ASCIIToUTF16("1.800.555.1234"));
151 phones.push_back(ASCIIToUTF16("1.866.650.0000"));
152 profile->SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, phones);
153
154 profile->SetRawInfo(ADDRESS_HOME_STREET_ADDRESS,
155 ASCIIToUTF16("123 Fake St.\n"
156 "Apt. 42"));
157 EXPECT_EQ(ASCIIToUTF16("123 Fake St."),
158 profile->GetRawInfo(ADDRESS_HOME_LINE1));
159 EXPECT_EQ(ASCIIToUTF16("Apt. 42"), profile->GetRawInfo(ADDRESS_HOME_LINE2));
160
161 profile->SetRawInfo(COMPANY_NAME, ASCIIToUTF16("Google, Inc."));
162 profile->SetRawInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("Mountain View"));
163 profile->SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California"));
164 profile->SetRawInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("94043"));
165 profile->SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"));
166 profile->SetRawInfo(ADDRESS_HOME_SORTING_CODE, ASCIIToUTF16("CEDEX"));
167 profile->SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY,
168 ASCIIToUTF16("Santa Clara"));
169 return profile.Pass();
170 }
171
172 // Returns SyncData with all Autofill profile fields set. Contains identical
173 // data to the data returned from ConstructCompleteProfile().
174 syncer::SyncData ConstructCompleteSyncData() {
175 sync_pb::EntitySpecifics entity_specifics;
176 sync_pb::AutofillProfileSpecifics* specifics =
177 entity_specifics.mutable_autofill_profile();
178
179 specifics->set_guid(kGuid1);
180 specifics->set_origin(kHttpsOrigin);
181
182 specifics->add_name_first("John");
183 specifics->add_name_middle("K.");
184 specifics->add_name_last("Doe");
185
186 specifics->add_name_first("Jane");
187 specifics->add_name_middle("Luise");
188 specifics->add_name_last("Smith");
189
190 specifics->add_email_address("user@example.com");
191 specifics->add_email_address("superuser@example.org");
192
193 specifics->add_phone_home_whole_number("1.800.555.1234");
194 specifics->add_phone_home_whole_number("1.866.650.0000");
195
196 specifics->set_address_home_line1("123 Fake St.");
197 specifics->set_address_home_line2("Apt. 42");
198 specifics->set_address_home_street_address("123 Fake St.\n"
199 "Apt. 42");
200
201 specifics->set_company_name("Google, Inc.");
202 specifics->set_address_home_city("Mountain View");
203 specifics->set_address_home_state("California");
204 specifics->set_address_home_zip("94043");
205 specifics->set_address_home_country("US");
206 specifics->set_address_home_sorting_code("CEDEX");
207 specifics->set_address_home_dependent_locality("Santa Clara");
208
209 return syncer::SyncData::CreateLocalData(kGuid1, kGuid1, entity_specifics);
210 }
211
212 } // namespace
213
130 class AutofillProfileSyncableServiceTest : public testing::Test { 214 class AutofillProfileSyncableServiceTest : public testing::Test {
131 public: 215 public:
132 AutofillProfileSyncableServiceTest() 216 AutofillProfileSyncableServiceTest()
133 : ui_thread_(BrowserThread::UI, &message_loop_), 217 : ui_thread_(BrowserThread::UI, &message_loop_),
134 db_thread_(BrowserThread::DB, &message_loop_) {} 218 db_thread_(BrowserThread::DB, &message_loop_) {}
135 219
136 virtual void SetUp() OVERRIDE { 220 virtual void SetUp() OVERRIDE {
137 sync_processor_.reset(new MockSyncChangeProcessor); 221 sync_processor_.reset(new MockSyncChangeProcessor);
138 } 222 }
139 223
140 // Wrapper around AutofillProfileSyncableService::MergeDataAndStartSyncing() 224 // Wrapper around AutofillProfileSyncableService::MergeDataAndStartSyncing()
141 // that also verifies expectations. 225 // that also verifies expectations.
142 void MergeDataAndStartSyncing( 226 void MergeDataAndStartSyncing(
143 const std::vector<AutofillProfile*>& profiles_from_web_db, 227 const std::vector<AutofillProfile*>& profiles_from_web_db,
144 const syncer::SyncDataList& data_list, 228 const syncer::SyncDataList& data_list,
145 const MockAutofillProfileSyncableService::DataBundle& expected_bundle, 229 const MockAutofillProfileSyncableService::DataBundle& expected_bundle,
146 const syncer::SyncChangeList& expected_change_list) { 230 const syncer::SyncChangeList& expected_change_list) {
147 EXPECT_CALL(autofill_syncable_service_, LoadAutofillData(_)) 231 EXPECT_CALL(autofill_syncable_service_, LoadAutofillData(_))
148 .Times(1) 232 .Times(1)
149 .WillOnce(DoAll(CopyData(&profiles_from_web_db), Return(true))); 233 .WillOnce(DoAll(CopyData(&profiles_from_web_db), Return(true)));
150 EXPECT_CALL(autofill_syncable_service_, 234 EXPECT_CALL(autofill_syncable_service_,
151 SaveChangesToWebData(DataBundleCheck(expected_bundle))) 235 SaveChangesToWebData(DataBundleCheck(expected_bundle)))
152 .Times(1) 236 .Times(1)
153 .WillOnce(Return(true)); 237 .WillOnce(Return(true));
154 ON_CALL(*sync_processor_, ProcessSyncChanges(_, _)) 238 if (expected_change_list.empty()) {
155 .WillByDefault(Return(syncer::SyncError())); 239 EXPECT_CALL(*sync_processor_, ProcessSyncChanges(_, _)).Times(0);
156 EXPECT_CALL(*sync_processor_, 240 } else {
157 ProcessSyncChanges(_, CheckSyncChanges(expected_change_list))) 241 ON_CALL(*sync_processor_, ProcessSyncChanges(_, _))
158 .Times(1) 242 .WillByDefault(Return(syncer::SyncError()));
159 .WillOnce(Return(syncer::SyncError())); 243 EXPECT_CALL(*sync_processor_,
244 ProcessSyncChanges(_, CheckSyncChanges(expected_change_list)))
245 .Times(1)
246 .WillOnce(Return(syncer::SyncError()));
247 }
160 248
161 // Takes ownership of sync_processor_. 249 // Takes ownership of sync_processor_.
162 autofill_syncable_service_.MergeDataAndStartSyncing( 250 autofill_syncable_service_.MergeDataAndStartSyncing(
163 syncer::AUTOFILL_PROFILE, data_list, 251 syncer::AUTOFILL_PROFILE, data_list,
164 sync_processor_.PassAs<syncer::SyncChangeProcessor>(), 252 sync_processor_.PassAs<syncer::SyncChangeProcessor>(),
165 scoped_ptr<syncer::SyncErrorFactory>( 253 scoped_ptr<syncer::SyncErrorFactory>(
166 new syncer::SyncErrorFactoryMock())); 254 new syncer::SyncErrorFactoryMock()));
167 } 255 }
168 256
169 protected: 257 protected:
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 autofill_specifics->add_phone_home_whole_number(std::string()); 455 autofill_specifics->add_phone_home_whole_number(std::string());
368 autofill_specifics->set_address_home_line1("1 1st st"); 456 autofill_specifics->set_address_home_line1("1 1st st");
369 EXPECT_FALSE(autofill_specifics->has_origin()); 457 EXPECT_FALSE(autofill_specifics->has_origin());
370 458
371 syncer::SyncDataList data_list; 459 syncer::SyncDataList data_list;
372 data_list.push_back( 460 data_list.push_back(
373 syncer::SyncData::CreateLocalData( 461 syncer::SyncData::CreateLocalData(
374 profile.guid(), profile.guid(), specifics)); 462 profile.guid(), profile.guid(), specifics));
375 463
376 MockAutofillProfileSyncableService::DataBundle expected_bundle; 464 MockAutofillProfileSyncableService::DataBundle expected_bundle;
377 EXPECT_CALL(autofill_syncable_service_, LoadAutofillData(_)) 465 syncer::SyncChangeList expected_change_list;
378 .Times(1) 466 MergeDataAndStartSyncing(
379 .WillOnce(DoAll(CopyData(&profiles_from_web_db), Return(true))); 467 profiles_from_web_db, data_list, expected_bundle, expected_change_list);
380 EXPECT_CALL(autofill_syncable_service_,
381 SaveChangesToWebData(DataBundleCheck(expected_bundle)))
382 .Times(1)
383 .WillOnce(Return(true));
384 EXPECT_CALL(*sync_processor_, ProcessSyncChanges(_, _)).Times(0);
385
386 // Takes ownership of sync_processor_.
387 autofill_syncable_service_.MergeDataAndStartSyncing(
388 syncer::AUTOFILL_PROFILE, data_list,
389 sync_processor_.PassAs<syncer::SyncChangeProcessor>(),
390 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock()));
391
392 autofill_syncable_service_.StopSyncing(syncer::AUTOFILL_PROFILE); 468 autofill_syncable_service_.StopSyncing(syncer::AUTOFILL_PROFILE);
393 } 469 }
394 470
395 TEST_F(AutofillProfileSyncableServiceTest, GetAllSyncData) { 471 TEST_F(AutofillProfileSyncableServiceTest, GetAllSyncData) {
396 std::vector<AutofillProfile*> profiles_from_web_db; 472 std::vector<AutofillProfile*> profiles_from_web_db;
397 std::string guid_present1 = kGuid1; 473 std::string guid_present1 = kGuid1;
398 std::string guid_present2 = kGuid2; 474 std::string guid_present2 = kGuid2;
399 475
400 profiles_from_web_db.push_back( 476 profiles_from_web_db.push_back(
401 new AutofillProfile(guid_present1, kHttpOrigin)); 477 new AutofillProfile(guid_present1, kHttpOrigin));
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 ASSERT_EQ(values.size(), 3U); 729 ASSERT_EQ(values.size(), 3U);
654 EXPECT_EQ(values[0], UTF8ToUTF16("1@1.com")); 730 EXPECT_EQ(values[0], UTF8ToUTF16("1@1.com"));
655 EXPECT_EQ(values[1], UTF8ToUTF16("2@1.com")); 731 EXPECT_EQ(values[1], UTF8ToUTF16("2@1.com"));
656 EXPECT_EQ(values[2], UTF8ToUTF16("3@1.com")); 732 EXPECT_EQ(values[2], UTF8ToUTF16("3@1.com"));
657 733
658 profile1.GetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values); 734 profile1.GetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values);
659 ASSERT_EQ(values.size(), 1U); 735 ASSERT_EQ(values.size(), 1U);
660 EXPECT_EQ(values[0], UTF8ToUTF16("650234567")); 736 EXPECT_EQ(values[0], UTF8ToUTF16("650234567"));
661 } 737 }
662 738
739 // Ensure that all profile fields are able to be synced up from the client to
740 // the server.
741 TEST_F(AutofillProfileSyncableServiceTest, SyncAllFieldsToServer) {
742 std::vector<AutofillProfile*> profiles_from_web_db;
743
744 // Create a profile with all fields set.
745 profiles_from_web_db.push_back(ConstructCompleteProfile().release());
746
747 // Set up expectations: No changes to the WebDB, and all fields correctly
748 // copied to Sync.
749 MockAutofillProfileSyncableService::DataBundle expected_bundle;
750 syncer::SyncChangeList expected_change_list;
751 expected_change_list.push_back(
752 syncer::SyncChange(FROM_HERE,
753 syncer::SyncChange::ACTION_ADD,
754 ConstructCompleteSyncData()));
755
756 // Verify the expectations.
757 syncer::SyncDataList data_list;
758 MergeDataAndStartSyncing(
759 profiles_from_web_db, data_list, expected_bundle, expected_change_list);
760 autofill_syncable_service_.StopSyncing(syncer::AUTOFILL_PROFILE);
761 }
762
763 // Ensure that all profile fields are able to be synced down from the server to
764 // the client.
765 TEST_F(AutofillProfileSyncableServiceTest, SyncAllFieldsToClient) {
766 // Create a profile with all fields set.
767 syncer::SyncDataList data_list;
768 data_list.push_back(ConstructCompleteSyncData());
769
770 // Set up expectations: All fields correctly copied to the WebDB, and no
771 // changes propagated to Sync.
772 syncer::SyncChangeList expected_change_list;
773 scoped_ptr<AutofillProfile> expected_profile = ConstructCompleteProfile();
774 MockAutofillProfileSyncableService::DataBundle expected_bundle;
775 expected_bundle.profiles_to_add.push_back(expected_profile.get());
776
777 // Verify the expectations.
778 std::vector<AutofillProfile*> profiles_from_web_db;
779 MergeDataAndStartSyncing(
780 profiles_from_web_db, data_list, expected_bundle, expected_change_list);
781 autofill_syncable_service_.StopSyncing(syncer::AUTOFILL_PROFILE);
782 }
783
784 // Ensure that the street address field takes precedence over the address line 1
785 // and line 2 fields, even though these are expected to always be in sync in
786 // practice.
787 TEST_F(AutofillProfileSyncableServiceTest,
788 StreetAddressTakesPrecedenceOverAddressLines) {
789 // Create a Sync profile with conflicting address data in the street address
790 // field vs. the address line 1 and address line 2 fields.
791 sync_pb::EntitySpecifics specifics;
792 sync_pb::AutofillProfileSpecifics* autofill_specifics =
793 specifics.mutable_autofill_profile();
794 autofill_specifics->set_guid(kGuid1);
795 autofill_specifics->set_origin(kHttpsOrigin);
796 autofill_specifics->add_name_first(std::string());
797 autofill_specifics->add_name_middle(std::string());
798 autofill_specifics->add_name_last(std::string());
799 autofill_specifics->add_email_address(std::string());
800 autofill_specifics->add_phone_home_whole_number(std::string());
801 autofill_specifics->set_address_home_line1("123 Example St.");
802 autofill_specifics->set_address_home_line2("Apt. 42");
803 autofill_specifics->set_address_home_street_address("456 El Camino Real\n"
804 "Suite #1337");
805
806 syncer::SyncDataList data_list;
807 data_list.push_back(
808 syncer::SyncData::CreateLocalData(kGuid1, kGuid1, specifics));
809
810 // Set up expectations: Full street address takes precedence over address
811 // lines.
812 syncer::SyncChangeList expected_change_list;
813 AutofillProfile expected_profile(kGuid1, kHttpsOrigin);
814 expected_profile.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS,
815 ASCIIToUTF16("456 El Camino Real\n"
816 "Suite #1337"));
817 EXPECT_EQ(ASCIIToUTF16("456 El Camino Real"),
818 expected_profile.GetRawInfo(ADDRESS_HOME_LINE1));
819 EXPECT_EQ(ASCIIToUTF16("Suite #1337"),
820 expected_profile.GetRawInfo(ADDRESS_HOME_LINE2));
821 MockAutofillProfileSyncableService::DataBundle expected_bundle;
822 expected_bundle.profiles_to_add.push_back(&expected_profile);
823
824 // Verify the expectations.
825 std::vector<AutofillProfile*> profiles_from_web_db;
826 MergeDataAndStartSyncing(
827 profiles_from_web_db, data_list, expected_bundle, expected_change_list);
828 autofill_syncable_service_.StopSyncing(syncer::AUTOFILL_PROFILE);
829 }
830
831 // Ensure that no Sync events are generated to fill in missing street address
832 // fields from Sync with explicitly present ones identical to the data stored in
833 // the line1 and line2 fields. This ensures that the migration to add the
834 // street address field to profiles does not generate lots of needless Sync
835 // updates.
836 TEST_F(AutofillProfileSyncableServiceTest, MergeDataEmptyStreetAddress) {
837 std::vector<AutofillProfile*> profiles_from_web_db;
838
839 // Create a profile with the street address set.
840 AutofillProfile profile(kGuid1, kHttpsOrigin);
841 profile.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS,
842 ASCIIToUTF16("123 Example St.\n"
843 "Apt. 42"));
844 EXPECT_EQ(ASCIIToUTF16("123 Example St."),
845 profile.GetRawInfo(ADDRESS_HOME_LINE1));
846 EXPECT_EQ(ASCIIToUTF16("Apt. 42"), profile.GetRawInfo(ADDRESS_HOME_LINE2));
847
848 profiles_from_web_db.push_back(new AutofillProfile(profile));
849
850 // Create a Sync profile identical to |profile|, except without street address
851 // explicitly set.
852 sync_pb::EntitySpecifics specifics;
853 sync_pb::AutofillProfileSpecifics* autofill_specifics =
854 specifics.mutable_autofill_profile();
855 autofill_specifics->set_guid(profile.guid());
856 autofill_specifics->set_origin(profile.origin());
857 autofill_specifics->add_name_first(std::string());
858 autofill_specifics->add_name_middle(std::string());
859 autofill_specifics->add_name_last(std::string());
860 autofill_specifics->add_email_address(std::string());
861 autofill_specifics->add_phone_home_whole_number(std::string());
862 autofill_specifics->set_address_home_line1("123 Example St.");
863 autofill_specifics->set_address_home_line2("Apt. 42");
864 EXPECT_FALSE(autofill_specifics->has_address_home_street_address());
865
866 syncer::SyncDataList data_list;
867 data_list.push_back(
868 syncer::SyncData::CreateLocalData(
869 profile.guid(), profile.guid(), specifics));
870
871 MockAutofillProfileSyncableService::DataBundle expected_bundle;
872 syncer::SyncChangeList expected_change_list;
873 MergeDataAndStartSyncing(
874 profiles_from_web_db, data_list, expected_bundle, expected_change_list);
875 autofill_syncable_service_.StopSyncing(syncer::AUTOFILL_PROFILE);
876 }
877
663 } // namespace autofill 878 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/webdata/autofill_profile_syncable_service.cc ('k') | sync/protocol/autofill_specifics.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698