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

Side by Side Diff: components/autofill/core/browser/webdata/autofill_profile_syncable_service_unittest.cc

Issue 347183005: autofill names - dont parse when calling SetRawInfo(FULL_NAME) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix android test expectation Created 6 years, 5 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 | « components/autofill/core/browser/personal_data_manager_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/autofill/core/browser/autofill_profile.h" 8 #include "components/autofill/core/browser/autofill_profile.h"
9 #include "components/autofill/core/browser/webdata/autofill_change.h" 9 #include "components/autofill/core/browser/webdata/autofill_change.h"
10 #include "components/autofill/core/browser/webdata/autofill_profile_syncable_ser vice.h" 10 #include "components/autofill/core/browser/webdata/autofill_profile_syncable_ser vice.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 // Returns a profile with all fields set. Contains identical data to the data 130 // Returns a profile with all fields set. Contains identical data to the data
131 // returned from ConstructCompleteSyncData(). 131 // returned from ConstructCompleteSyncData().
132 scoped_ptr<AutofillProfile> ConstructCompleteProfile() { 132 scoped_ptr<AutofillProfile> ConstructCompleteProfile() {
133 scoped_ptr<AutofillProfile> profile( 133 scoped_ptr<AutofillProfile> profile(
134 new AutofillProfile(kGuid1, kHttpsOrigin)); 134 new AutofillProfile(kGuid1, kHttpsOrigin));
135 135
136 std::vector<base::string16> names; 136 std::vector<base::string16> names;
137 names.push_back(ASCIIToUTF16("John K. Doe, Jr.")); 137 names.push_back(ASCIIToUTF16("John K. Doe, Jr."));
138 names.push_back(ASCIIToUTF16("Jane Luise Smith MD")); 138 names.push_back(ASCIIToUTF16("Jane Luise Smith MD"));
139 profile->SetRawMultiInfo(NAME_FULL, names); 139 profile->SetRawMultiInfo(NAME_FULL, names);
140 names.clear();
141 names.push_back(ASCIIToUTF16("John"));
142 names.push_back(ASCIIToUTF16("Jane"));
143 profile->SetRawMultiInfo(NAME_FIRST, names);
144 names.clear();
145 names.push_back(ASCIIToUTF16("K."));
146 names.push_back(ASCIIToUTF16("Luise"));
147 profile->SetRawMultiInfo(NAME_MIDDLE, names);
148 names.clear();
149 names.push_back(ASCIIToUTF16("Doe"));
150 names.push_back(ASCIIToUTF16("Smith"));
151 profile->SetRawMultiInfo(NAME_LAST, names);
140 152
141 std::vector<base::string16> emails; 153 std::vector<base::string16> emails;
142 emails.push_back(ASCIIToUTF16("user@example.com")); 154 emails.push_back(ASCIIToUTF16("user@example.com"));
143 emails.push_back(ASCIIToUTF16("superuser@example.org")); 155 emails.push_back(ASCIIToUTF16("superuser@example.org"));
144 profile->SetRawMultiInfo(EMAIL_ADDRESS, emails); 156 profile->SetRawMultiInfo(EMAIL_ADDRESS, emails);
145 157
146 std::vector<base::string16> phones; 158 std::vector<base::string16> phones;
147 phones.push_back(ASCIIToUTF16("1.800.555.1234")); 159 phones.push_back(ASCIIToUTF16("1.800.555.1234"));
148 phones.push_back(ASCIIToUTF16("1.866.650.0000")); 160 phones.push_back(ASCIIToUTF16("1.866.650.0000"));
149 profile->SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, phones); 161 profile->SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, phones);
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 profiles_from_web_db.push_back(new AutofillProfile(profile)); 453 profiles_from_web_db.push_back(new AutofillProfile(profile));
442 454
443 // Create a Sync profile identical to |profile|, except with no origin set. 455 // Create a Sync profile identical to |profile|, except with no origin set.
444 sync_pb::EntitySpecifics specifics; 456 sync_pb::EntitySpecifics specifics;
445 sync_pb::AutofillProfileSpecifics* autofill_specifics = 457 sync_pb::AutofillProfileSpecifics* autofill_specifics =
446 specifics.mutable_autofill_profile(); 458 specifics.mutable_autofill_profile();
447 autofill_specifics->set_guid(profile.guid()); 459 autofill_specifics->set_guid(profile.guid());
448 autofill_specifics->add_name_first("John"); 460 autofill_specifics->add_name_first("John");
449 autofill_specifics->add_name_middle(std::string()); 461 autofill_specifics->add_name_middle(std::string());
450 autofill_specifics->add_name_last(std::string()); 462 autofill_specifics->add_name_last(std::string());
451 autofill_specifics->add_name_full("John"); 463 autofill_specifics->add_name_full(std::string());
452 autofill_specifics->add_email_address(std::string()); 464 autofill_specifics->add_email_address(std::string());
453 autofill_specifics->add_phone_home_whole_number(std::string()); 465 autofill_specifics->add_phone_home_whole_number(std::string());
454 autofill_specifics->set_address_home_line1("1 1st st"); 466 autofill_specifics->set_address_home_line1("1 1st st");
455 EXPECT_FALSE(autofill_specifics->has_origin()); 467 EXPECT_FALSE(autofill_specifics->has_origin());
456 468
457 syncer::SyncDataList data_list; 469 syncer::SyncDataList data_list;
458 data_list.push_back( 470 data_list.push_back(
459 syncer::SyncData::CreateLocalData( 471 syncer::SyncData::CreateLocalData(
460 profile.guid(), profile.guid(), specifics)); 472 profile.guid(), profile.guid(), specifics));
461 473
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 profiles_from_web_db.push_back(new AutofillProfile(profile)); 898 profiles_from_web_db.push_back(new AutofillProfile(profile));
887 899
888 // Remote data does not have an origin value. 900 // Remote data does not have an origin value.
889 sync_pb::EntitySpecifics specifics; 901 sync_pb::EntitySpecifics specifics;
890 sync_pb::AutofillProfileSpecifics* autofill_specifics = 902 sync_pb::AutofillProfileSpecifics* autofill_specifics =
891 specifics.mutable_autofill_profile(); 903 specifics.mutable_autofill_profile();
892 autofill_specifics->set_guid(profile.guid()); 904 autofill_specifics->set_guid(profile.guid());
893 autofill_specifics->add_name_first("John"); 905 autofill_specifics->add_name_first("John");
894 autofill_specifics->add_name_middle(std::string()); 906 autofill_specifics->add_name_middle(std::string());
895 autofill_specifics->add_name_last(std::string()); 907 autofill_specifics->add_name_last(std::string());
896 autofill_specifics->add_name_full("John"); 908 autofill_specifics->add_name_full(std::string());
897 autofill_specifics->add_email_address(std::string()); 909 autofill_specifics->add_email_address(std::string());
898 autofill_specifics->add_phone_home_whole_number(std::string()); 910 autofill_specifics->add_phone_home_whole_number(std::string());
899 EXPECT_FALSE(autofill_specifics->has_origin()); 911 EXPECT_FALSE(autofill_specifics->has_origin());
900 912
901 syncer::SyncDataList data_list; 913 syncer::SyncDataList data_list;
902 data_list.push_back( 914 data_list.push_back(
903 syncer::SyncData::CreateLocalData( 915 syncer::SyncData::CreateLocalData(
904 profile.guid(), profile.guid(), specifics)); 916 profile.guid(), profile.guid(), specifics));
905 917
906 // Expect the local autofill profile to still have an origin after sync. 918 // Expect the local autofill profile to still have an origin after sync.
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 1064
1053 // Remote data does not have a language code value. 1065 // Remote data does not have a language code value.
1054 sync_pb::EntitySpecifics specifics; 1066 sync_pb::EntitySpecifics specifics;
1055 sync_pb::AutofillProfileSpecifics* autofill_specifics = 1067 sync_pb::AutofillProfileSpecifics* autofill_specifics =
1056 specifics.mutable_autofill_profile(); 1068 specifics.mutable_autofill_profile();
1057 autofill_specifics->set_guid(profile.guid()); 1069 autofill_specifics->set_guid(profile.guid());
1058 autofill_specifics->set_origin(profile.origin()); 1070 autofill_specifics->set_origin(profile.origin());
1059 autofill_specifics->add_name_first("John"); 1071 autofill_specifics->add_name_first("John");
1060 autofill_specifics->add_name_middle(std::string()); 1072 autofill_specifics->add_name_middle(std::string());
1061 autofill_specifics->add_name_last(std::string()); 1073 autofill_specifics->add_name_last(std::string());
1062 autofill_specifics->add_name_full("John"); 1074 autofill_specifics->add_name_full(std::string());
1063 autofill_specifics->add_email_address(std::string()); 1075 autofill_specifics->add_email_address(std::string());
1064 autofill_specifics->add_phone_home_whole_number(std::string()); 1076 autofill_specifics->add_phone_home_whole_number(std::string());
1065 EXPECT_FALSE(autofill_specifics->has_address_home_language_code()); 1077 EXPECT_FALSE(autofill_specifics->has_address_home_language_code());
1066 1078
1067 syncer::SyncDataList data_list; 1079 syncer::SyncDataList data_list;
1068 data_list.push_back( 1080 data_list.push_back(
1069 syncer::SyncData::CreateLocalData( 1081 syncer::SyncData::CreateLocalData(
1070 profile.guid(), profile.guid(), specifics)); 1082 profile.guid(), profile.guid(), specifics));
1071 1083
1072 // Expect local autofill profile to still have "en" language code after sync. 1084 // Expect local autofill profile to still have "en" language code after sync.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 MergeDataAndStartSyncing(profiles_from_web_db, data_list, 1150 MergeDataAndStartSyncing(profiles_from_web_db, data_list,
1139 expected_empty_bundle, expected_empty_change_list); 1151 expected_empty_bundle, expected_empty_change_list);
1140 autofill_syncable_service_.StopSyncing(syncer::AUTOFILL_PROFILE); 1152 autofill_syncable_service_.StopSyncing(syncer::AUTOFILL_PROFILE);
1141 } 1153 }
1142 1154
1143 TEST_F(AutofillProfileSyncableServiceTest, EmptySyncPreservesFullName) { 1155 TEST_F(AutofillProfileSyncableServiceTest, EmptySyncPreservesFullName) {
1144 std::vector<AutofillProfile*> profiles_from_web_db; 1156 std::vector<AutofillProfile*> profiles_from_web_db;
1145 1157
1146 // Local autofill profile has a full name. 1158 // Local autofill profile has a full name.
1147 AutofillProfile profile(kGuid1, kHttpsOrigin); 1159 AutofillProfile profile(kGuid1, kHttpsOrigin);
1148 profile.SetRawInfo(NAME_FULL, ASCIIToUTF16("John Jacob Smith, Jr")); 1160 profile.SetInfo(AutofillType(NAME_FULL),
1161 ASCIIToUTF16("John Jacob Smith, Jr"), "en-US");
1149 profiles_from_web_db.push_back(new AutofillProfile(profile)); 1162 profiles_from_web_db.push_back(new AutofillProfile(profile));
1150 1163
1151 // Remote data does not have a full name value. 1164 // Remote data does not have a full name value.
1152 sync_pb::EntitySpecifics specifics; 1165 sync_pb::EntitySpecifics specifics;
1153 sync_pb::AutofillProfileSpecifics* autofill_specifics = 1166 sync_pb::AutofillProfileSpecifics* autofill_specifics =
1154 specifics.mutable_autofill_profile(); 1167 specifics.mutable_autofill_profile();
1155 autofill_specifics->set_guid(profile.guid()); 1168 autofill_specifics->set_guid(profile.guid());
1156 autofill_specifics->set_origin(profile.origin()); 1169 autofill_specifics->set_origin(profile.origin());
1157 autofill_specifics->add_name_first(std::string("John")); 1170 autofill_specifics->add_name_first(std::string("John"));
1158 autofill_specifics->add_name_middle(std::string("Jacob")); 1171 autofill_specifics->add_name_middle(std::string("Jacob"));
1159 autofill_specifics->add_name_last(std::string("Smith")); 1172 autofill_specifics->add_name_last(std::string("Smith"));
1160 1173
1161 syncer::SyncDataList data_list; 1174 syncer::SyncDataList data_list;
1162 data_list.push_back( 1175 data_list.push_back(
1163 syncer::SyncData::CreateLocalData( 1176 syncer::SyncData::CreateLocalData(
1164 profile.guid(), profile.guid(), specifics)); 1177 profile.guid(), profile.guid(), specifics));
1165 1178
1166 // Expect local autofill profile to still have the same full name after sync. 1179 // Expect local autofill profile to still have the same full name after sync.
1167 MockAutofillProfileSyncableService::DataBundle expected_bundle; 1180 MockAutofillProfileSyncableService::DataBundle expected_bundle;
1168 AutofillProfile expected_profile(profile.guid(), profile.origin()); 1181 AutofillProfile expected_profile(profile.guid(), profile.origin());
1169 expected_profile.SetRawInfo(NAME_FULL, ASCIIToUTF16("John Jacob Smith, Jr")); 1182 expected_profile.SetInfo(AutofillType(NAME_FULL),
1183 ASCIIToUTF16("John Jacob Smith, Jr"),
1184 "en-US");
1170 expected_bundle.profiles_to_update.push_back(&expected_profile); 1185 expected_bundle.profiles_to_update.push_back(&expected_profile);
1171 1186
1172 // Expect no changes to remote data. 1187 // Expect no changes to remote data.
1173 syncer::SyncChangeList expected_empty_change_list; 1188 syncer::SyncChangeList expected_empty_change_list;
1174 1189
1175 MergeDataAndStartSyncing(profiles_from_web_db, data_list, 1190 MergeDataAndStartSyncing(profiles_from_web_db, data_list,
1176 expected_bundle, expected_empty_change_list); 1191 expected_bundle, expected_empty_change_list);
1177 autofill_syncable_service_.StopSyncing(syncer::AUTOFILL_PROFILE); 1192 autofill_syncable_service_.StopSyncing(syncer::AUTOFILL_PROFILE);
1178 } 1193 }
1179 1194
1180 } // namespace autofill 1195 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/personal_data_manager_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698