| 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 c9455875a094ffd5a290306fc3a0c20a19221f2e..476655d61ca72ccb33545013520c3b4417a0ebff 100644
|
| --- a/components/payments/content/payment_request_state_unittest.cc
|
| +++ b/components/payments/content/payment_request_state_unittest.cc
|
| @@ -105,6 +105,77 @@ class PaymentRequestStateTest : public testing::Test,
|
| autofill::CreditCard credit_card_amex_;
|
| };
|
|
|
| +TEST_F(PaymentRequestStateTest, CanMakePayment) {
|
| + // Default options.
|
| + RecreateStateWithOptions(mojom::PaymentOptions::New());
|
| +
|
| + // CanMakePayment returns true because the method data requires Visa, and the
|
| + // user has a Visa card on file.
|
| + EXPECT_TRUE(state()->CanMakePayment());
|
| +}
|
| +
|
| +TEST_F(PaymentRequestStateTest, CanMakePayment_CannotMakePayment) {
|
| + // The method data requires MasterCard.
|
| + std::vector<mojom::PaymentMethodDataPtr> method_data;
|
| + mojom::PaymentMethodDataPtr entry = mojom::PaymentMethodData::New();
|
| + entry->supported_methods.push_back("mastercard");
|
| + method_data.push_back(std::move(entry));
|
| + RecreateStateWithOptionsAndDetails(mojom::PaymentOptions::New(),
|
| + mojom::PaymentDetails::New(),
|
| + std::move(method_data));
|
| +
|
| + // CanMakePayment returns false because the method data requires MasterCard,
|
| + // and the user doesn't have such an instrument.
|
| + EXPECT_FALSE(state()->CanMakePayment());
|
| +}
|
| +
|
| +TEST_F(PaymentRequestStateTest, CanMakePayment_OnlyBasicCard) {
|
| + // The method data supports everything in basic-card.
|
| + mojom::PaymentMethodDataPtr entry = mojom::PaymentMethodData::New();
|
| + entry->supported_methods.push_back("basic-card");
|
| + std::vector<mojom::PaymentMethodDataPtr> method_data;
|
| + method_data.push_back(std::move(entry));
|
| + RecreateStateWithOptionsAndDetails(mojom::PaymentOptions::New(),
|
| + mojom::PaymentDetails::New(),
|
| + std::move(method_data));
|
| +
|
| + // CanMakePayment returns true because the method data supports everything,
|
| + // and the user has at least one instrument.
|
| + EXPECT_TRUE(state()->CanMakePayment());
|
| +}
|
| +
|
| +TEST_F(PaymentRequestStateTest, CanMakePayment_BasicCard_SpecificAvailable) {
|
| + // The method data supports everything in basic-card.
|
| + mojom::PaymentMethodDataPtr entry = mojom::PaymentMethodData::New();
|
| + entry->supported_methods.push_back("basic-card");
|
| + entry->supported_networks.push_back(mojom::BasicCardNetwork::VISA);
|
| + std::vector<mojom::PaymentMethodDataPtr> method_data;
|
| + method_data.push_back(std::move(entry));
|
| + RecreateStateWithOptionsAndDetails(mojom::PaymentOptions::New(),
|
| + mojom::PaymentDetails::New(),
|
| + std::move(method_data));
|
| +
|
| + // CanMakePayment returns true because the method data supports visa, and the
|
| + // user has a Visa instrument.
|
| + EXPECT_TRUE(state()->CanMakePayment());
|
| +}
|
| +
|
| +TEST_F(PaymentRequestStateTest, CanMakePayment_BasicCard_SpecificUnavailable) {
|
| + // The method data supports everything in basic-card.
|
| + mojom::PaymentMethodDataPtr entry = mojom::PaymentMethodData::New();
|
| + entry->supported_methods.push_back("basic-card");
|
| + entry->supported_networks.push_back(mojom::BasicCardNetwork::MASTERCARD);
|
| + std::vector<mojom::PaymentMethodDataPtr> method_data;
|
| + method_data.push_back(std::move(entry));
|
| + RecreateStateWithOptionsAndDetails(mojom::PaymentOptions::New(),
|
| + mojom::PaymentDetails::New(),
|
| + std::move(method_data));
|
| +
|
| + // CanMakePayment returns false because the method data supports mastercard,
|
| + // and the user doesn't have such an instrument.
|
| + EXPECT_FALSE(state()->CanMakePayment());
|
| +}
|
| +
|
| // Test that the last shipping option is selected.
|
| TEST_F(PaymentRequestStateTest, ShippingOptionsSelection) {
|
| std::vector<mojom::PaymentShippingOptionPtr> shipping_options;
|
|
|