Commit aa503458 authored by Matthias Körber's avatar Matthias Körber Committed by Commit Bot

[Autofill][Slimshady] Migrate new profiles after sync import.

The CL migrates profiles with a legacy name structure when they
are imported from profile specifics.

Change-Id: Ib8ddda534d36d542d1328d1cbd24d05e0da86e12
Bug: 1099202
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2362808
Commit-Queue: Matthias Körber <koerber@google.com>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799284}
parent 3a9145f3
...@@ -361,6 +361,15 @@ std::unique_ptr<AutofillProfile> CreateAutofillProfileFromSpecifics( ...@@ -361,6 +361,15 @@ std::unique_ptr<AutofillProfile> CreateAutofillProfileFromSpecifics(
profile->set_is_client_validity_states_updated( profile->set_is_client_validity_states_updated(
specifics.is_client_validity_states_updated()); specifics.is_client_validity_states_updated());
// The profile may be in a legacy state. By calling |FinalizeAfterImport()|
// * The profile is migrated if the name structure is in legacy state.
// * Nothing happens if the profile is already migrated and therefore
// finalized.
// * If structured names are not enabled, this operation is a noop.
//
// Here, the return value of the finalization step does not have an
// implication.
profile->FinalizeAfterImport();
return profile; return profile;
} }
......
...@@ -638,6 +638,52 @@ TEST_P(AutofillProfileSyncBridgeTest, MergeSyncData) { ...@@ -638,6 +638,52 @@ TEST_P(AutofillProfileSyncBridgeTest, MergeSyncData) {
CreateAutofillProfile(remote3_specifics))); CreateAutofillProfile(remote3_specifics)));
} }
// Tests the profile migration that is performed after specifics are converted
// to profiles.
TEST_P(AutofillProfileSyncBridgeTest, ProfileMigration) {
// This test is only applicable when structured names are enabled.
if (!UsingStructuredNames())
return;
AutofillProfile remote1 = AutofillProfile(kGuidC, kHttpOrigin);
remote1.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Thomas"));
remote1.SetRawInfo(NAME_MIDDLE, ASCIIToUTF16("Neo"));
remote1.SetRawInfo(NAME_LAST, ASCIIToUTF16("Anderson"));
AutofillProfileSpecifics remote1_specifics =
CreateAutofillProfileSpecifics(remote1);
EXPECT_CALL(*backend(), CommitChanges());
StartSyncing({remote1_specifics});
// Create the expected profile after migration.
AutofillProfile finalized_profile = AutofillProfile(kGuidC, kHttpOrigin);
finalized_profile.SetRawInfoWithVerificationStatus(
NAME_FULL, ASCIIToUTF16("Thomas Neo Anderson"),
structured_address::VerificationStatus::kFormatted);
finalized_profile.SetRawInfoWithVerificationStatus(
NAME_FIRST, ASCIIToUTF16("Thomas"),
structured_address::VerificationStatus::kObserved);
finalized_profile.SetRawInfoWithVerificationStatus(
NAME_MIDDLE, ASCIIToUTF16("Neo"),
structured_address::VerificationStatus::kObserved);
finalized_profile.SetRawInfoWithVerificationStatus(
NAME_LAST, ASCIIToUTF16("Anderson"),
structured_address::VerificationStatus::kObserved);
finalized_profile.SetRawInfoWithVerificationStatus(
NAME_LAST_SECOND, ASCIIToUTF16("Anderson"),
structured_address::VerificationStatus::kParsed);
finalized_profile.SetRawInfoWithVerificationStatus(
NAME_LAST_FIRST, ASCIIToUTF16(""),
structured_address::VerificationStatus::kParsed);
finalized_profile.SetRawInfoWithVerificationStatus(
NAME_LAST_CONJUNCTION, ASCIIToUTF16(""),
structured_address::VerificationStatus::kParsed);
EXPECT_THAT(GetAllLocalData(), UnorderedElementsAre(finalized_profile));
}
// Ensure that all profile fields are able to be synced up from the client to // Ensure that all profile fields are able to be synced up from the client to
// the server. // the server.
TEST_P(AutofillProfileSyncBridgeTest, MergeSyncData_SyncAllFieldsToServer) { TEST_P(AutofillProfileSyncBridgeTest, MergeSyncData_SyncAllFieldsToServer) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment