Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: components/payments/core/autofill_payment_instrument_unittest.cc

Issue 2813203004: [Payments] Show what's missing for incomplete payment methods. (Closed)
Patch Set: addressed comments, now two functions Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/payments/core/autofill_payment_instrument_unittest.cc
diff --git a/components/payments/core/autofill_payment_instrument_unittest.cc b/components/payments/core/autofill_payment_instrument_unittest.cc
index 7b9db0be6a96b1a828190e7f22a80fa3dcd7c1a8..622a4e90f577f982879a1ed266e13b950e76f14a 100644
--- a/components/payments/core/autofill_payment_instrument_unittest.cc
+++ b/components/payments/core/autofill_payment_instrument_unittest.cc
@@ -5,11 +5,14 @@
#include "components/payments/core/autofill_payment_instrument.h"
#include "base/macros.h"
+#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/browser/autofill_profile.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
#include "components/autofill/core/browser/credit_card.h"
+#include "components/strings/grit/components_strings.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/base/l10n/l10n_util.h"
namespace payments {
@@ -40,6 +43,7 @@ TEST_F(AutofillPaymentInstrumentTest, IsCompleteForPayment) {
AutofillPaymentInstrument instrument("visa", local_credit_card(),
billing_profiles(), "en-US", nullptr);
EXPECT_TRUE(instrument.IsCompleteForPayment());
+ EXPECT_TRUE(instrument.GetMissingInfoLabel().empty());
}
// An expired local card is not a valid instrument for payment.
@@ -49,6 +53,9 @@ TEST_F(AutofillPaymentInstrumentTest, IsCompleteForPayment_Expired) {
AutofillPaymentInstrument instrument("visa", card, billing_profiles(),
"en-US", nullptr);
EXPECT_FALSE(instrument.IsCompleteForPayment());
+ EXPECT_EQ(l10n_util::GetStringUTF16(
+ IDS_PAYMENTS_VALIDATION_INVALID_CREDIT_CARD_EXPIRED),
+ instrument.GetMissingInfoLabel());
}
// A local card with no name is not a valid instrument for payment.
@@ -56,18 +63,40 @@ TEST_F(AutofillPaymentInstrumentTest, IsCompleteForPayment_NoName) {
autofill::CreditCard& card = local_credit_card();
card.SetInfo(autofill::AutofillType(autofill::CREDIT_CARD_NAME_FULL),
base::ASCIIToUTF16(""), "en-US");
+ base::string16 missing_info;
AutofillPaymentInstrument instrument("visa", card, billing_profiles(),
"en-US", nullptr);
EXPECT_FALSE(instrument.IsCompleteForPayment());
+ EXPECT_EQ(l10n_util::GetStringUTF16(IDS_PAYMENTS_NAME_ON_CARD_REQUIRED),
+ instrument.GetMissingInfoLabel());
}
// A local card with no name is not a valid instrument for payment.
TEST_F(AutofillPaymentInstrumentTest, IsCompleteForPayment_NoNumber) {
autofill::CreditCard& card = local_credit_card();
card.SetNumber(base::ASCIIToUTF16(""));
+ base::string16 missing_info;
AutofillPaymentInstrument instrument("visa", card, billing_profiles(),
"en-US", nullptr);
EXPECT_FALSE(instrument.IsCompleteForPayment());
+ EXPECT_EQ(l10n_util::GetStringUTF16(
+ IDS_PAYMENTS_CARD_NUMBER_INVALID_VALIDATION_MESSAGE),
+ instrument.GetMissingInfoLabel());
+}
+
+// A local card with no name and no number is not a valid instrument for
+// payment.
+TEST_F(AutofillPaymentInstrumentTest,
+ IsCompleteForPayment_MultipleThingsMissing) {
+ autofill::CreditCard& card = local_credit_card();
+ card.SetNumber(base::ASCIIToUTF16(""));
+ card.SetInfo(autofill::AutofillType(autofill::CREDIT_CARD_NAME_FULL),
+ base::ASCIIToUTF16(""), "en-US");
+ AutofillPaymentInstrument instrument("visa", card, billing_profiles(),
+ "en-US", nullptr);
+ EXPECT_FALSE(instrument.IsCompleteForPayment());
+ EXPECT_EQ(l10n_util::GetStringUTF16(IDS_PAYMENTS_MORE_INFORMATION_REQUIRED),
+ instrument.GetMissingInfoLabel());
}
// A Masked (server) card is a valid instrument for payment.
@@ -76,6 +105,7 @@ TEST_F(AutofillPaymentInstrumentTest, IsCompleteForPayment_MaskedCard) {
AutofillPaymentInstrument instrument("visa", card, billing_profiles(),
"en-US", nullptr);
EXPECT_TRUE(instrument.IsCompleteForPayment());
+ EXPECT_TRUE(instrument.GetMissingInfoLabel().empty());
}
// An expired masked (server) card is not a valid instrument for payment.
@@ -85,6 +115,9 @@ TEST_F(AutofillPaymentInstrumentTest, IsCompleteForPayment_ExpiredMaskedCard) {
AutofillPaymentInstrument instrument("visa", card, billing_profiles(),
"en-US", nullptr);
EXPECT_FALSE(instrument.IsCompleteForPayment());
+ EXPECT_EQ(l10n_util::GetStringUTF16(
+ IDS_PAYMENTS_VALIDATION_INVALID_CREDIT_CARD_EXPIRED),
+ instrument.GetMissingInfoLabel());
}
// An expired card is a valid instrument for canMakePayment.
« no previous file with comments | « components/payments/core/autofill_payment_instrument.cc ('k') | components/payments/core/payment_instrument.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698