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

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

Issue 2849523003: Add billing address as a mandatory field of Payments credit cards. (Closed)
Patch Set: Merge branch 'master' into billing Created 3 years, 7 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
« no previous file with comments | « components/payments/core/autofill_payment_instrument.cc ('k') | components/payments_strings.grdp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 892c1969a4a7d70093596ad2e2cbe73c2d73870e..b6afe02d280d4b822a8350ba0d48337aa6225c10 100644
--- a/components/payments/core/autofill_payment_instrument_unittest.cc
+++ b/components/payments/core/autofill_payment_instrument_unittest.cc
@@ -208,6 +208,35 @@ TEST_F(AutofillPaymentInstrumentTest, IsCompleteForPayment_NoNumber) {
instrument.GetMissingInfoLabel());
}
+// A local card with no billing address id is not a valid instrument for
+// payment.
+TEST_F(AutofillPaymentInstrumentTest, IsCompleteForPayment_NoBillinbAddressId) {
+ autofill::CreditCard& card = local_credit_card();
+ card.set_billing_address_id("");
+ 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_BILLING_ADDRESS_REQUIRED),
+ instrument.GetMissingInfoLabel());
+}
+
+// A local card with an invalid billing address id is not a valid instrument for
+// payment.
+TEST_F(AutofillPaymentInstrumentTest,
+ IsCompleteForPayment_InvalidBillinbAddressId) {
+ autofill::CreditCard& card = local_credit_card();
+ card.set_billing_address_id("InvalidBillingAddressId");
+ 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_BILLING_ADDRESS_REQUIRED),
+ instrument.GetMissingInfoLabel());
+}
+
// A local card with no name and no number is not a valid instrument for
// payment.
TEST_F(AutofillPaymentInstrumentTest,
@@ -226,6 +255,8 @@ TEST_F(AutofillPaymentInstrumentTest,
// A Masked (server) card is a valid instrument for payment.
TEST_F(AutofillPaymentInstrumentTest, IsCompleteForPayment_MaskedCard) {
autofill::CreditCard card = autofill::test::GetMaskedServerCard();
+ ASSERT_GT(billing_profiles().size(), 0UL);
+ card.set_billing_address_id(billing_profiles()[0]->guid());
AutofillPaymentInstrument instrument("visa", card, billing_profiles(),
"en-US", nullptr);
EXPECT_TRUE(instrument.IsCompleteForPayment());
@@ -235,6 +266,8 @@ TEST_F(AutofillPaymentInstrumentTest, IsCompleteForPayment_MaskedCard) {
// An expired masked (server) card is not a valid instrument for payment.
TEST_F(AutofillPaymentInstrumentTest, IsCompleteForPayment_ExpiredMaskedCard) {
autofill::CreditCard card = autofill::test::GetMaskedServerCard();
+ ASSERT_GT(billing_profiles().size(), 0UL);
+ card.set_billing_address_id(billing_profiles()[0]->guid());
card.SetExpirationYear(2016); // Expired.
AutofillPaymentInstrument instrument("visa", card, billing_profiles(),
"en-US", nullptr);
« no previous file with comments | « components/payments/core/autofill_payment_instrument.cc ('k') | components/payments_strings.grdp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698