| Index: components/autofill/core/browser/webdata/autofill_wallet_metadata_syncable_service_unittest.cc
|
| diff --git a/components/autofill/core/browser/webdata/autofill_wallet_metadata_syncable_service_unittest.cc b/components/autofill/core/browser/webdata/autofill_wallet_metadata_syncable_service_unittest.cc
|
| index 89439d7184cbff574f42748a716024a324e1fa4a..462f7bb67f88ab8585fac65d8cf941bbc3080fed 100644
|
| --- a/components/autofill/core/browser/webdata/autofill_wallet_metadata_syncable_service_unittest.cc
|
| +++ b/components/autofill/core/browser/webdata/autofill_wallet_metadata_syncable_service_unittest.cc
|
| @@ -59,6 +59,12 @@ const char kAddr2SyncTag[] = "address-YWRkcjLvv74=";
|
| const char kCard1SyncTag[] = "card-Y2FyZDHvv74=";
|
| const char kCard2SyncTag[] = "card-Y2FyZDLvv74=";
|
|
|
| +// Local profile GUID in UTF8 and non-UTF8.
|
| +const char kLocalAddr1[] = "e171e3ed-858a-4dd5-9bf3-8517f14ba5fc";
|
| +const char kLocalAddr2[] = "fa232b9a-f248-4e5a-8d76-d46f821c0c5f";
|
| +const char kLocalAddr1Utf8[] =
|
| + "ZTE3MWUzZWQtODU4YS00ZGQ1LTliZjMtODUxN2YxNGJhNWZj";
|
| +
|
| // Map values are owned by the caller to GetLocalData.
|
| ACTION_P2(GetCopiesOf, profiles, cards) {
|
| for (const auto& profile : *profiles) {
|
| @@ -1025,9 +1031,10 @@ TEST_F(AutofillWalletMetadataSyncableServiceTest, SaveHigherValues_Mixed2) {
|
| }
|
|
|
| // Verify that if both local and server have a different non empty billing
|
| -// address id, the one with the most recent (bigger) use date is kept.
|
| +// address id refering to a Wallet address, the one with the most recent
|
| +// (bigger) use date is kept.
|
| TEST_F(AutofillWalletMetadataSyncableServiceTest,
|
| - SaveHigherValues_DifferentBillingAddressId_LocalMostRecent) {
|
| + DifferentServerBillingAddressId_LocalMostRecent) {
|
| local_.UpdateCardStats(BuildCard(kCard1, 3, 40, kAddr1));
|
| remote_.UpdateCardStats(BuildCard(kCard1, 3, 4, kAddr2));
|
|
|
| @@ -1044,9 +1051,10 @@ TEST_F(AutofillWalletMetadataSyncableServiceTest,
|
| }
|
|
|
| // Verify that if both local and server have a different non empty billing
|
| -// address id, the one with the most recent (bigger) use date is kept.
|
| +// address id refering to a Wallet address, the one with the most recent
|
| +// (bigger) use date is kept.
|
| TEST_F(AutofillWalletMetadataSyncableServiceTest,
|
| - SaveHigherValues_DifferentBillingAddressId_RemoteMostRecent) {
|
| + DifferentServerBillingAddressId_RemoteMostRecent) {
|
| local_.UpdateCardStats(BuildCard(kCard1, 3, 4, kAddr1));
|
| remote_.UpdateCardStats(BuildCard(kCard1, 3, 40, kAddr2));
|
|
|
| @@ -1059,5 +1067,155 @@ TEST_F(AutofillWalletMetadataSyncableServiceTest,
|
| MergeMetadata(&local_, &remote_);
|
| }
|
|
|
| +// Verify that if both local and server have a different non empty billing
|
| +// address id refering to a local profile, the one with the most recent (bigger)
|
| +// use date is kept.
|
| +TEST_F(AutofillWalletMetadataSyncableServiceTest,
|
| + DifferentLocalBillingAddressId_LocalMostRecent) {
|
| + local_.UpdateCardStats(BuildCard(kCard1, 3, 40, kLocalAddr1));
|
| + remote_.UpdateCardStats(BuildCard(kCard1, 3, 4, kLocalAddr2));
|
| +
|
| + // The value from the local should be kept because it has a more recent use
|
| + // date.
|
| + EXPECT_CALL(local_, UpdateCardStats(_)).Times(0);
|
| + EXPECT_CALL(local_, SendChangesToSyncServer(
|
| + UnorderedElementsAre(SyncCardChangeAndDataMatch(
|
| + syncer::SyncChange::ACTION_UPDATE, kCard1SyncTag,
|
| + sync_pb::WalletMetadataSpecifics::CARD,
|
| + kCard1Utf8, 3, 40, kLocalAddr1Utf8))));
|
| +
|
| + MergeMetadata(&local_, &remote_);
|
| +}
|
| +
|
| +// Verify that if both local and server have a different non empty billing
|
| +// address id refering to a local profile, the one with the most recent (bigger)
|
| +// use date is kept.
|
| +TEST_F(AutofillWalletMetadataSyncableServiceTest,
|
| + DifferentLocalBillingAddressId_RemoteMostRecent) {
|
| + local_.UpdateCardStats(BuildCard(kCard1, 3, 4, kLocalAddr1));
|
| + remote_.UpdateCardStats(BuildCard(kCard1, 3, 40, kLocalAddr2));
|
| +
|
| + // The value from the remote should be kept because it has a more recent use
|
| + // date.
|
| + EXPECT_CALL(local_, UpdateCardStats(AutofillCardMetadataMatches(
|
| + kCard1, 3, 40, kLocalAddr2)));
|
| + EXPECT_CALL(local_, SendChangesToSyncServer(_)).Times(0);
|
| +
|
| + MergeMetadata(&local_, &remote_);
|
| +}
|
| +
|
| +// Verify that if both local and server have a different non empty billing
|
| +// address id, the one refering to a local profile is always kept.
|
| +TEST_F(AutofillWalletMetadataSyncableServiceTest,
|
| + DifferentBillingAddressId_KeepLocalId_Local) {
|
| + local_.UpdateCardStats(BuildCard(kCard1, 3, 4, kLocalAddr1));
|
| + remote_.UpdateCardStats(BuildCard(kCard1, 3, 4, kAddr2));
|
| +
|
| + // The billing address from the local version of the card should be kept since
|
| + // it refers to a local autofill profile.
|
| + EXPECT_CALL(local_, UpdateCardStats(_)).Times(0);
|
| + EXPECT_CALL(local_, SendChangesToSyncServer(
|
| + UnorderedElementsAre(SyncCardChangeAndDataMatch(
|
| + syncer::SyncChange::ACTION_UPDATE, kCard1SyncTag,
|
| + sync_pb::WalletMetadataSpecifics::CARD,
|
| + kCard1Utf8, 3, 4, kLocalAddr1Utf8))));
|
| +
|
| + MergeMetadata(&local_, &remote_);
|
| +}
|
| +
|
| +// Verify that if both local and server have a different non empty billing
|
| +// address id, the one refering to a local profile is always kept, even id the
|
| +// other was used more recently.
|
| +TEST_F(AutofillWalletMetadataSyncableServiceTest,
|
| + DifferentBillingAddressId_KeepLocalId_Remote) {
|
| + local_.UpdateCardStats(BuildCard(kCard1, 3, 4, kAddr2));
|
| + remote_.UpdateCardStats(BuildCard(kCard1, 3, 4, kLocalAddr1));
|
| +
|
| + // The billing address from the remote version of the card should be kept
|
| + // since it refers to a local autofill profile.
|
| + EXPECT_CALL(local_, UpdateCardStats(AutofillCardMetadataMatches(
|
| + kCard1, 3, 4, kLocalAddr1)));
|
| + EXPECT_CALL(local_, SendChangesToSyncServer(_)).Times(0);
|
| +
|
| + MergeMetadata(&local_, &remote_);
|
| +}
|
| +
|
| +// Verify that if both local and server have a different non empty billing
|
| +// address id, the one refering to a local profile is always kept, even id the
|
| +// other was used more recently. Also makes sure that for the rest of the fields
|
| +// the highest values are kept.
|
| +TEST_F(AutofillWalletMetadataSyncableServiceTest,
|
| + SaveHigherValues_DifferentBillingAddressId_KeepLocalId_Local) {
|
| + local_.UpdateCardStats(BuildCard(kCard1, 3, 4, kLocalAddr1));
|
| + remote_.UpdateCardStats(BuildCard(kCard1, 30, 40, kAddr2));
|
| +
|
| + // The billing address from the local version of the card should be kept since
|
| + // it refers to a local autofill profile. The highest use stats should
|
| + // be kept.
|
| + EXPECT_CALL(local_, UpdateCardStats(AutofillCardMetadataMatches(
|
| + kCard1, 30, 40, kLocalAddr1)));
|
| + EXPECT_CALL(local_, SendChangesToSyncServer(
|
| + UnorderedElementsAre(SyncCardChangeAndDataMatch(
|
| + syncer::SyncChange::ACTION_UPDATE, kCard1SyncTag,
|
| + sync_pb::WalletMetadataSpecifics::CARD,
|
| + kCard1Utf8, 30, 40, kLocalAddr1Utf8))));
|
| +
|
| + MergeMetadata(&local_, &remote_);
|
| +}
|
| +
|
| +// Verify that if both local and server have a different non empty billing
|
| +// address id, the one refering to a local profile is always kept. Also makes
|
| +// sure that for the rest of the fields the highest values are kept.
|
| +TEST_F(AutofillWalletMetadataSyncableServiceTest,
|
| + SaveHigherValues_DifferentBillingAddressId_KeepLocalId_Remote) {
|
| + local_.UpdateCardStats(BuildCard(kCard1, 30, 40, kAddr2));
|
| + remote_.UpdateCardStats(BuildCard(kCard1, 3, 4, kLocalAddr1));
|
| +
|
| + // The billing address from the remote version of the card should be kept
|
| + // since it refers to a local autofill profile. The highest use stats should
|
| + // be kept.
|
| + EXPECT_CALL(local_, UpdateCardStats(AutofillCardMetadataMatches(
|
| + kCard1, 30, 40, kLocalAddr1)));
|
| + EXPECT_CALL(local_, SendChangesToSyncServer(
|
| + UnorderedElementsAre(SyncCardChangeAndDataMatch(
|
| + syncer::SyncChange::ACTION_UPDATE, kCard1SyncTag,
|
| + sync_pb::WalletMetadataSpecifics::CARD,
|
| + kCard1Utf8, 30, 40, kLocalAddr1Utf8))));
|
| +
|
| + MergeMetadata(&local_, &remote_);
|
| +}
|
| +
|
| +// Verify that if both local and server have a different non empty billing
|
| +// address id refering to a Wallet address with the same timestamp, the remote
|
| +// one is kept.
|
| +TEST_F(AutofillWalletMetadataSyncableServiceTest,
|
| + DifferentServerBillingAddressId_BothSameTimestamp) {
|
| + local_.UpdateCardStats(BuildCard(kCard1, 3, 4, kAddr1));
|
| + remote_.UpdateCardStats(BuildCard(kCard1, 3, 4, kAddr2));
|
| +
|
| + // The value from the remote should be kept to promote a stable set of values.
|
| + EXPECT_CALL(local_, UpdateCardStats(
|
| + AutofillCardMetadataMatches(kCard1, 3, 4, kAddr2)));
|
| + EXPECT_CALL(local_, SendChangesToSyncServer(_)).Times(0);
|
| +
|
| + MergeMetadata(&local_, &remote_);
|
| +}
|
| +
|
| +// Verify that if both local and server have a different non empty billing
|
| +// address id refering to a local profile with the same timestamp, the remote
|
| +// one is kept.
|
| +TEST_F(AutofillWalletMetadataSyncableServiceTest,
|
| + DifferentLocalBillingAddressId_BothSameTimestamp) {
|
| + local_.UpdateCardStats(BuildCard(kCard1, 3, 4, kLocalAddr1));
|
| + remote_.UpdateCardStats(BuildCard(kCard1, 3, 4, kLocalAddr2));
|
| +
|
| + // The value from the remote should be kept to promote a stable set of values.
|
| + EXPECT_CALL(local_, UpdateCardStats(AutofillCardMetadataMatches(
|
| + kCard1, 3, 4, kLocalAddr2)));
|
| + EXPECT_CALL(local_, SendChangesToSyncServer(_)).Times(0);
|
| +
|
| + MergeMetadata(&local_, &remote_);
|
| +}
|
| +
|
| } // namespace
|
| } // namespace autofill
|
|
|