Commit 20de10a8 authored by Manas Verma's avatar Manas Verma Committed by Commit Bot

[Autofill Offers] Updating text for cards with offers.

Text now includes "Cashback linked" instead of including
the percentage or dollar amount.

Bug: 1093057
Change-Id: I53e046a6a495cc4b6cabbf35a8876e940f280b49
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2466142
Commit-Queue: Manas Verma <manasverma@google.com>
Reviewed-by: default avatarSiyu An <siyua@chromium.org>
Reviewed-by: default avatarJared Saul <jsaul@google.com>
Cr-Commit-Position: refs/heads/master@{#816903}
parent 8a90893d
......@@ -62,14 +62,8 @@ void AutofillOfferManager::UpdateSuggestionsWithOffers(
for (auto& suggestion : suggestions) {
std::string id = suggestion.backend_id;
if (eligible_offers_map.count(id)) {
base::string16 reward_amount =
base::UTF8ToUTF16(eligible_offers_map[id]->offer_reward_amount);
auto string_id = (reward_amount.find('%') == std::string::npos)
? IDS_AUTOFILL_OFFERS_DISCOUNT
: IDS_AUTOFILL_OFFERS_CASHBACK;
suggestion.offer_label =
l10n_util::GetStringFUTF16(string_id, reward_amount);
l10n_util::GetStringUTF16(IDS_AUTOFILL_OFFERS_CASHBACK);
}
}
}
......
......@@ -14,6 +14,7 @@
#include "components/autofill/core/browser/test_personal_data_manager.h"
#include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
#include "components/autofill/core/common/autofill_clock.h"
#include "components/strings/grit/components_strings.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h"
......@@ -87,18 +88,6 @@ class AutofillOfferManagerTest : public testing::Test {
std::unique_ptr<AutofillOfferManager> autofill_offer_manager_ = nullptr;
};
TEST_F(AutofillOfferManagerTest, UpdateSuggestionsWithOffers_EligibleDiscount) {
CreditCard card = CreateCreditCard(kTestGuid);
CreateCreditCardOfferForCard(card, "$4");
std::vector<Suggestion> suggestions = {Suggestion()};
suggestions[0].backend_id = kTestGuid;
autofill_offer_manager_->UpdateSuggestionsWithOffers(GURL(kTestUrlWithParam),
suggestions);
EXPECT_EQ(suggestions[0].offer_label, base::UTF8ToUTF16("$4 Off"));
}
TEST_F(AutofillOfferManagerTest, UpdateSuggestionsWithOffers_EligibleCashback) {
CreditCard card = CreateCreditCard(kTestGuid);
CreateCreditCardOfferForCard(card, "5%");
......@@ -108,7 +97,8 @@ TEST_F(AutofillOfferManagerTest, UpdateSuggestionsWithOffers_EligibleCashback) {
autofill_offer_manager_->UpdateSuggestionsWithOffers(GURL(kTestUrlWithParam),
suggestions);
EXPECT_EQ(suggestions[0].offer_label, base::UTF8ToUTF16("5% Cash Back"));
EXPECT_EQ(suggestions[0].offer_label,
l10n_util::GetStringUTF16(IDS_AUTOFILL_OFFERS_CASHBACK));
}
TEST_F(AutofillOfferManagerTest, UpdateSuggestionsWithOffers_ExpiredOffer) {
......
......@@ -507,10 +507,7 @@
<!-- Credit card offers and rewards related strings -->
<message name="IDS_AUTOFILL_OFFERS_CASHBACK" desc="Displays that a cashback offer will be rewarded if credit card is used on current page. Part of Autofill suggestions popup.">
<ph name="PERCENT">$1<ex>5%</ex></ph> Cash Back
</message>
<message name="IDS_AUTOFILL_OFFERS_DISCOUNT" desc="Displays a discount that will be rewarded if credit card is used on current page. Part of Autofill suggestions popup.">
<ph name="DISCOUNT">$1<ex>$$3</ex></ph> Off
Cashback linked
</message>
</grit-part>
378244426ac8f525d17518614e3d7b1508061cf9
\ No newline at end of file
130304f80bbc14548f470c8363d9dda1fffc280b
\ No newline at end of file
a09ae4c895b292cf8ce625cf9843a477d86dfc35
\ No newline at end of file
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