Commit 6bb8985e authored by Jan Krcal's avatar Jan Krcal Committed by Commit Bot

[AF] Fix client tag and storage key for the wallet data USS bridge

This CL adapts GetClientTag() to what integration tests use.

Change-Id: Ie2fbc9c5fd193d0a3635b231e58de7fdf94b3077
Reviewed-on: https://chromium-review.googlesource.com/1171222
Commit-Queue: Jan Krcal <jkrcal@chromium.org>
Commit-Queue: Sebastien Seguin-Gagnon <sebsg@chromium.org>
Reviewed-by: default avatarSebastien Seguin-Gagnon <sebsg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582297}
parent 5ac53354
......@@ -34,7 +34,7 @@ namespace {
// Address to this variable used as the user data key.
static int kAutofillWalletSyncBridgeUserDataKey = 0;
std::string GetStorageKeyFromAutofillWalletSpecifics(
std::string GetSpecificsIdFromAutofillWalletSpecifics(
const AutofillWalletSpecifics& specifics) {
switch (specifics.type()) {
case AutofillWalletSpecifics::MASKED_CREDIT_CARD:
......@@ -50,6 +50,13 @@ std::string GetStorageKeyFromAutofillWalletSpecifics(
return std::string();
}
std::string GetClientTagForWalletDataSpecificsId(
const std::string& specifics_id) {
// Unlike for the wallet_metadata model type, the wallet_data expects
// specifics id directly as client tags.
return specifics_id;
}
} // namespace
// static
......@@ -144,16 +151,16 @@ std::string AutofillWalletSyncBridge::GetClientTag(
const syncer::EntityData& entity_data) {
DCHECK(entity_data.specifics.has_autofill_wallet());
return GetClientTagForSpecificsId(
entity_data.specifics.autofill_wallet().type(),
GetStorageKey(entity_data));
return GetClientTagForWalletDataSpecificsId(
GetSpecificsIdFromAutofillWalletSpecifics(
entity_data.specifics.autofill_wallet()));
}
std::string AutofillWalletSyncBridge::GetStorageKey(
const syncer::EntityData& entity_data) {
DCHECK(entity_data.specifics.has_autofill_wallet());
return GetStorageKeyFromAutofillWalletSpecifics(
entity_data.specifics.autofill_wallet());
return GetStorageKeyForSpecificsId(GetSpecificsIdFromAutofillWalletSpecifics(
entity_data.specifics.autofill_wallet()));
}
void AutofillWalletSyncBridge::SetSyncData(
......
......@@ -58,8 +58,8 @@ const char kCard1SpecificsId[] = "Y2FyZDHvv74=";
//const char kCard2SpecificsId[] = "Y2FyZDLvv74=";
// Unique sync tags for the server IDs.
const char kAddr1SyncTag[] = "address-YWRkcjHvv74=";
const char kCard1SyncTag[] = "card-Y2FyZDHvv74=";
const char kAddr1SyncTag[] = "YWRkcjHvv74=";
const char kCard1SyncTag[] = "Y2FyZDHvv74=";
const char kLocaleString[] = "en-US";
const base::Time kJune2017 = base::Time::FromDoubleT(1497552271);
......@@ -270,16 +270,16 @@ class AutofillWalletSyncBridgeTest : public testing::Test {
// The following 2 tests make sure client tags stay stable.
TEST_F(AutofillWalletSyncBridgeTest, GetClientTagForAddress) {
AutofillWalletSpecifics specifics =
CreateAutofillWalletSpecificsForAddress(kAddr1SyncTag);
CreateAutofillWalletSpecificsForAddress(kAddr1SpecificsId);
EXPECT_EQ(bridge()->GetClientTag(SpecificsToEntity(specifics)),
"address-" + std::string(kAddr1SyncTag));
kAddr1SyncTag);
}
TEST_F(AutofillWalletSyncBridgeTest, GetClientTagForCard) {
AutofillWalletSpecifics specifics =
CreateAutofillWalletSpecificsForCard(kCard1SyncTag);
CreateAutofillWalletSpecificsForCard(kCard1SpecificsId);
EXPECT_EQ(bridge()->GetClientTag(SpecificsToEntity(specifics)),
"card-" + std::string(kCard1SyncTag));
kCard1SyncTag);
}
// The following 2 tests make sure storage keys stay stable.
......@@ -503,4 +503,4 @@ TEST_F(AutofillWalletSyncBridgeTest, MergeSyncData_SetsAllWalletCardData) {
EXPECT_FALSE(card.bank_name().empty());
}
} // namespace autofill
\ No newline at end of file
} // namespace autofill
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