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

Unified Diff: components/payments/content/payment_request_state_unittest.cc

Issue 2757523002: [Payments] Use PaymentInstrument/AutofillPaymentInstrument throughout. (Closed)
Patch Set: Initial Created 3 years, 9 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/content/payment_request_state_unittest.cc
diff --git a/components/payments/content/payment_request_state_unittest.cc b/components/payments/content/payment_request_state_unittest.cc
index be56d1fcf6b4f69efb0168840e41122c38e8ba6a..e71bd60409d225b3e2aaded7c97b2f423db7c790 100644
--- a/components/payments/content/payment_request_state_unittest.cc
+++ b/components/payments/content/payment_request_state_unittest.cc
@@ -24,10 +24,15 @@ class PaymentRequestStateTest : public testing::Test,
PaymentRequestStateTest()
: num_on_selected_information_changed_called_(0),
address_(autofill::test::GetFullProfile()),
- credit_card_(autofill::test::GetCreditCard()) {
+ credit_card_visa_(autofill::test::GetCreditCard()),
+ credit_card_amex_(autofill::test::GetCreditCard2()) {
test_personal_data_manager_.AddTestingProfile(&address_);
- credit_card_.set_billing_address_id(address_.guid());
- test_personal_data_manager_.AddTestingCreditCard(&credit_card_);
+ credit_card_visa_.set_billing_address_id(address_.guid());
+ credit_card_visa_.set_use_count(5u);
+ test_personal_data_manager_.AddTestingCreditCard(&credit_card_visa_);
+ credit_card_amex_.set_billing_address_id(address_.guid());
+ credit_card_amex_.set_use_count(1u);
+ test_personal_data_manager_.AddTestingCreditCard(&credit_card_amex_);
}
~PaymentRequestStateTest() override {}
@@ -86,7 +91,6 @@ class PaymentRequestStateTest : public testing::Test,
}
autofill::AutofillProfile* test_address() { return &address_; }
- autofill::CreditCard* test_credit_card() { return &credit_card_; }
private:
std::unique_ptr<PaymentRequestState> state_;
@@ -97,7 +101,8 @@ class PaymentRequestStateTest : public testing::Test,
// Test data.
autofill::AutofillProfile address_;
- autofill::CreditCard credit_card_;
+ autofill::CreditCard credit_card_visa_;
+ autofill::CreditCard credit_card_amex_;
};
// Test that the last shipping option is selected.
@@ -142,15 +147,14 @@ TEST_F(PaymentRequestStateTest, ReadyToPay_SelectUnsupportedCard) {
// Ready to pay because the default card is selected and supported.
EXPECT_TRUE(state()->is_ready_to_pay());
- autofill::CreditCard amex_card = autofill::test::GetCreditCard2(); // Amex.
- state()->SetSelectedCreditCard(&amex_card);
+ state()->SetSelectedInstrument(state()->available_instruments()[1]); // Amex.
EXPECT_EQ(1, num_on_selected_information_changed_called());
// Not ready to pay because the card is not supported.
EXPECT_FALSE(state()->is_ready_to_pay());
// Go back to the Visa card.
- state()->SetSelectedCreditCard(test_credit_card()); // Visa card.
+ state()->SetSelectedInstrument(state()->available_instruments()[0]);
EXPECT_EQ(2, num_on_selected_information_changed_called());
// Visa card is supported by the merchant.
@@ -185,13 +189,13 @@ TEST_F(PaymentRequestStateTest, ReadyToPay_ContactInfo) {
TEST_F(PaymentRequestStateTest, GeneratePaymentResponse) {
// Default options (no shipping, no contact info).
RecreateStateWithOptions(mojom::PaymentOptions::New());
- state()->SetSelectedCreditCard(test_credit_card());
+ state()->SetSelectedInstrument(state()->available_instruments()[0]);
EXPECT_EQ(1, num_on_selected_information_changed_called());
EXPECT_TRUE(state()->is_ready_to_pay());
// TODO(mathp): Currently synchronous, when async will need a RunLoop.
state()->GeneratePaymentResponse();
- EXPECT_EQ("basic-card", response()->method_name);
+ EXPECT_EQ("visa", response()->method_name);
EXPECT_EQ(
"{\"billingAddress\":"
"{\"addressLine\":[\"666 Erebus St.\",\"Apt 8\"],"

Powered by Google App Engine
This is Rietveld 408576698