Index: components/autofill/core/browser/webdata/autofill_profile_syncable_service_unittest.cc |
diff --git a/components/autofill/core/browser/webdata/autofill_profile_syncable_service_unittest.cc b/components/autofill/core/browser/webdata/autofill_profile_syncable_service_unittest.cc |
index c816f1e5c22fcaf74d80dfde8bd7ed8f6cb30241..fdf116840db9f7fac8538d009ed16c5eb6c8d23e 100644 |
--- a/components/autofill/core/browser/webdata/autofill_profile_syncable_service_unittest.cc |
+++ b/components/autofill/core/browser/webdata/autofill_profile_syncable_service_unittest.cc |
@@ -163,6 +163,7 @@ scoped_ptr<AutofillProfile> ConstructCompleteProfile() { |
profile->SetRawInfo(ADDRESS_HOME_SORTING_CODE, ASCIIToUTF16("CEDEX")); |
profile->SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, |
ASCIIToUTF16("Santa Clara")); |
+ profile->set_language_code("en"); |
return profile.Pass(); |
} |
@@ -202,6 +203,7 @@ syncer::SyncData ConstructCompleteSyncData() { |
specifics->set_address_home_country("US"); |
specifics->set_address_home_sorting_code("CEDEX"); |
specifics->set_address_home_dependent_locality("Santa Clara"); |
+ specifics->set_address_home_language_code("en"); |
return syncer::SyncData::CreateLocalData(kGuid1, kGuid1, entity_specifics); |
} |
@@ -868,4 +870,39 @@ TEST_F(AutofillProfileSyncableServiceTest, MergeDataEmptyStreetAddress) { |
autofill_syncable_service_.StopSyncing(syncer::AUTOFILL_PROFILE); |
} |
+// Missing language code field should not generate sync events. |
+TEST_F(AutofillProfileSyncableServiceTest, MergeDataEmptyLanguageCode) { |
+ std::vector<AutofillProfile*> profiles_from_web_db; |
+ |
+ // Create a profile with the language code set. |
+ AutofillProfile profile(kGuid1, kHttpsOrigin); |
+ profile.set_language_code("en"); |
+ profiles_from_web_db.push_back(new AutofillProfile(profile)); |
+ |
+ // Create a sync profile identical to |profile|, except without language code |
+ // explicitly set. |
+ sync_pb::EntitySpecifics specifics; |
+ sync_pb::AutofillProfileSpecifics* autofill_specifics = |
+ specifics.mutable_autofill_profile(); |
+ autofill_specifics->set_guid(profile.guid()); |
+ autofill_specifics->set_origin(profile.origin()); |
+ autofill_specifics->add_name_first(std::string()); |
+ autofill_specifics->add_name_middle(std::string()); |
+ autofill_specifics->add_name_last(std::string()); |
+ autofill_specifics->add_email_address(std::string()); |
+ autofill_specifics->add_phone_home_whole_number(std::string()); |
+ EXPECT_FALSE(autofill_specifics->has_address_home_language_code()); |
+ |
+ syncer::SyncDataList data_list; |
+ data_list.push_back( |
+ syncer::SyncData::CreateLocalData( |
+ profile.guid(), profile.guid(), specifics)); |
+ |
+ MockAutofillProfileSyncableService::DataBundle expected_empty_bundle; |
+ syncer::SyncChangeList expected_empty_change_list; |
+ MergeDataAndStartSyncing(profiles_from_web_db, data_list, |
+ expected_empty_bundle, expected_empty_change_list); |
+ autofill_syncable_service_.StopSyncing(syncer::AUTOFILL_PROFILE); |
+} |
+ |
} // namespace autofill |