| Index: ios/chrome/browser/payments/payment_request_unittest.mm
|
| diff --git a/ios/chrome/browser/payments/payment_request_unittest.mm b/ios/chrome/browser/payments/payment_request_unittest.mm
|
| index b01fe09c33a17211281e63e6044ffd6906ad6931..61e584b2c95019936f962731e18378ff46e6fac0 100644
|
| --- a/ios/chrome/browser/payments/payment_request_unittest.mm
|
| +++ b/ios/chrome/browser/payments/payment_request_unittest.mm
|
| @@ -39,6 +39,8 @@ MATCHER_P(GuidMatches, guid, "") {
|
|
|
| } // namespace
|
|
|
| +namespace payments {
|
| +
|
| class PaymentRequestTest : public testing::Test {
|
| protected:
|
| // Returns PaymentDetails with one shipping option that's selected.
|
| @@ -80,7 +82,7 @@ TEST_F(PaymentRequestTest, CreatesCurrencyFormatterCorrectly) {
|
| web_payment_request.details.total.amount.currency = base::ASCIIToUTF16("USD");
|
| TestPaymentRequest payment_request1(web_payment_request,
|
| &personal_data_manager);
|
| - payments::CurrencyFormatter* currency_formatter =
|
| + CurrencyFormatter* currency_formatter =
|
| payment_request1.GetOrCreateCurrencyFormatter();
|
| EXPECT_EQ(base::UTF8ToUTF16("$55.00"), currency_formatter->Format("55.00"));
|
| EXPECT_EQ("USD", currency_formatter->formatted_currency_code());
|
| @@ -107,10 +109,10 @@ TEST_F(PaymentRequestTest, AcceptedPaymentNetworks) {
|
| web::PaymentRequest web_payment_request;
|
| autofill::TestPersonalDataManager personal_data_manager;
|
|
|
| - payments::PaymentMethodData method_datum1;
|
| + PaymentMethodData method_datum1;
|
| method_datum1.supported_methods.push_back("visa");
|
| web_payment_request.method_data.push_back(method_datum1);
|
| - payments::PaymentMethodData method_datum2;
|
| + PaymentMethodData method_datum2;
|
| method_datum2.supported_methods.push_back("mastercard");
|
| web_payment_request.method_data.push_back(method_datum2);
|
|
|
| @@ -127,7 +129,7 @@ TEST_F(PaymentRequestTest, SupportedMethods) {
|
| web::PaymentRequest web_payment_request;
|
| autofill::TestPersonalDataManager personal_data_manager;
|
|
|
| - payments::PaymentMethodData method_datum1;
|
| + PaymentMethodData method_datum1;
|
| method_datum1.supported_methods.push_back("visa");
|
| method_datum1.supported_methods.push_back("mastercard");
|
| method_datum1.supported_methods.push_back("invalid");
|
| @@ -148,16 +150,16 @@ TEST_F(PaymentRequestTest, SupportedMethods_MultipleEntries) {
|
| web::PaymentRequest web_payment_request;
|
| autofill::TestPersonalDataManager personal_data_manager;
|
|
|
| - payments::PaymentMethodData method_datum1;
|
| + PaymentMethodData method_datum1;
|
| method_datum1.supported_methods.push_back("visa");
|
| web_payment_request.method_data.push_back(method_datum1);
|
| - payments::PaymentMethodData method_datum2;
|
| + PaymentMethodData method_datum2;
|
| method_datum2.supported_methods.push_back("mastercard");
|
| web_payment_request.method_data.push_back(method_datum2);
|
| - payments::PaymentMethodData method_datum3;
|
| + PaymentMethodData method_datum3;
|
| method_datum3.supported_methods.push_back("");
|
| web_payment_request.method_data.push_back(method_datum3);
|
| - payments::PaymentMethodData method_datum4;
|
| + PaymentMethodData method_datum4;
|
| method_datum4.supported_methods.push_back("visa");
|
| web_payment_request.method_data.push_back(method_datum4);
|
|
|
| @@ -173,7 +175,7 @@ TEST_F(PaymentRequestTest, SupportedMethods_OnlyBasicCard) {
|
| web::PaymentRequest web_payment_request;
|
| autofill::TestPersonalDataManager personal_data_manager;
|
|
|
| - payments::PaymentMethodData method_datum1;
|
| + PaymentMethodData method_datum1;
|
| method_datum1.supported_methods.push_back("basic-card");
|
| web_payment_request.method_data.push_back(method_datum1);
|
|
|
| @@ -198,7 +200,7 @@ TEST_F(PaymentRequestTest, SupportedMethods_BasicCard_WithSpecificMethod) {
|
| web::PaymentRequest web_payment_request;
|
| autofill::TestPersonalDataManager personal_data_manager;
|
|
|
| - payments::PaymentMethodData method_datum1;
|
| + PaymentMethodData method_datum1;
|
| method_datum1.supported_methods.push_back("jcb");
|
| method_datum1.supported_methods.push_back("basic-card");
|
| web_payment_request.method_data.push_back(method_datum1);
|
| @@ -225,11 +227,11 @@ TEST_F(PaymentRequestTest, SupportedMethods_BasicCard_Overlap) {
|
| web::PaymentRequest web_payment_request;
|
| autofill::TestPersonalDataManager personal_data_manager;
|
|
|
| - payments::PaymentMethodData method_datum1;
|
| + PaymentMethodData method_datum1;
|
| method_datum1.supported_methods.push_back("mastercard");
|
| method_datum1.supported_methods.push_back("visa");
|
| web_payment_request.method_data.push_back(method_datum1);
|
| - payments::PaymentMethodData method_datum2;
|
| + PaymentMethodData method_datum2;
|
| method_datum2.supported_methods.push_back("basic-card");
|
| method_datum2.supported_networks.push_back("visa");
|
| method_datum2.supported_networks.push_back("mastercard");
|
| @@ -251,7 +253,7 @@ TEST_F(PaymentRequestTest, SupportedMethods_BasicCard_WithSupportedNetworks) {
|
| web::PaymentRequest web_payment_request;
|
| autofill::TestPersonalDataManager personal_data_manager;
|
|
|
| - payments::PaymentMethodData method_datum1;
|
| + PaymentMethodData method_datum1;
|
| method_datum1.supported_methods.push_back("basic-card");
|
| method_datum1.supported_networks.push_back("visa");
|
| method_datum1.supported_networks.push_back("unionpay");
|
| @@ -270,7 +272,7 @@ TEST_F(PaymentRequestTest, SupportedMethods_BasicCard_WithSupportedNetworks) {
|
| // to the list of available payment methods.
|
| TEST_F(PaymentRequestTest, AddAutofillPaymentInstrument) {
|
| web::PaymentRequest web_payment_request;
|
| - payments::PaymentMethodData method_datum;
|
| + PaymentMethodData method_datum;
|
| method_datum.supported_methods.push_back("basic-card");
|
| method_datum.supported_networks.push_back("visa");
|
| method_datum.supported_networks.push_back("amex");
|
| @@ -286,7 +288,7 @@ TEST_F(PaymentRequestTest, AddAutofillPaymentInstrument) {
|
| EXPECT_EQ(1U, payment_request.payment_methods().size());
|
|
|
| autofill::CreditCard credit_card_2 = autofill::test::GetCreditCard2();
|
| - payments::AutofillPaymentInstrument* added_credit_card =
|
| + AutofillPaymentInstrument* added_credit_card =
|
| payment_request.AddAutofillPaymentInstrument(credit_card_2);
|
|
|
| EXPECT_EQ(2U, payment_request.payment_methods().size());
|
| @@ -513,9 +515,9 @@ TEST_F(PaymentRequestTest, SelectedPaymentMethod_ExpiredCard) {
|
| TestPaymentRequest payment_request(web_payment_request,
|
| &personal_data_manager);
|
| EXPECT_EQ(payment_request.selected_payment_method()->type(),
|
| - payments::PaymentInstrument::Type::AUTOFILL);
|
| - payments::AutofillPaymentInstrument* payment_instrument =
|
| - static_cast<payments::AutofillPaymentInstrument*>(
|
| + PaymentInstrument::Type::AUTOFILL);
|
| + AutofillPaymentInstrument* payment_instrument =
|
| + static_cast<AutofillPaymentInstrument*>(
|
| payment_request.selected_payment_method());
|
| EXPECT_EQ(credit_card.guid(), payment_instrument->credit_card()->guid());
|
| }
|
| @@ -541,8 +543,8 @@ TEST_F(PaymentRequestTest, SelectedPaymentMethod_Complete) {
|
| // model).
|
| TestPaymentRequest payment_request(web_payment_request,
|
| &personal_data_manager);
|
| - payments::AutofillPaymentInstrument* payment_instrument =
|
| - static_cast<payments::AutofillPaymentInstrument*>(
|
| + AutofillPaymentInstrument* payment_instrument =
|
| + static_cast<AutofillPaymentInstrument*>(
|
| payment_request.selected_payment_method());
|
| EXPECT_EQ(credit_card2.guid(), payment_instrument->credit_card()->guid());
|
| }
|
| @@ -567,8 +569,8 @@ TEST_F(PaymentRequestTest, SelectedPaymentMethod_Incomplete) {
|
| // because it is complete.
|
| TestPaymentRequest payment_request(web_payment_request,
|
| &personal_data_manager);
|
| - payments::AutofillPaymentInstrument* payment_instrument =
|
| - static_cast<payments::AutofillPaymentInstrument*>(
|
| + AutofillPaymentInstrument* payment_instrument =
|
| + static_cast<AutofillPaymentInstrument*>(
|
| payment_request.selected_payment_method());
|
| EXPECT_EQ(credit_card.guid(), payment_instrument->credit_card()->guid());
|
| }
|
| @@ -597,8 +599,8 @@ TEST_F(PaymentRequestTest, RecordUseStats_RequestShippingAndContactInfo) {
|
|
|
| TestPaymentRequest payment_request(web_payment_request,
|
| &personal_data_manager);
|
| - payments::AutofillPaymentInstrument* payment_instrument =
|
| - static_cast<payments::AutofillPaymentInstrument*>(
|
| + AutofillPaymentInstrument* payment_instrument =
|
| + static_cast<AutofillPaymentInstrument*>(
|
| payment_request.selected_payment_method());
|
| EXPECT_EQ(address.guid(),
|
| payment_request.selected_shipping_profile()->guid());
|
| @@ -633,8 +635,8 @@ TEST_F(PaymentRequestTest, RecordUseStats_SameShippingAndContactInfoProfile) {
|
|
|
| TestPaymentRequest payment_request(web_payment_request,
|
| &personal_data_manager);
|
| - payments::AutofillPaymentInstrument* payment_instrument =
|
| - static_cast<payments::AutofillPaymentInstrument*>(
|
| + AutofillPaymentInstrument* payment_instrument =
|
| + static_cast<AutofillPaymentInstrument*>(
|
| payment_request.selected_payment_method());
|
| EXPECT_EQ(address.guid(),
|
| payment_request.selected_shipping_profile()->guid());
|
| @@ -670,8 +672,8 @@ TEST_F(PaymentRequestTest, RecordUseStats_RequestShippingOnly) {
|
|
|
| TestPaymentRequest payment_request(web_payment_request,
|
| &personal_data_manager);
|
| - payments::AutofillPaymentInstrument* payment_instrument =
|
| - static_cast<payments::AutofillPaymentInstrument*>(
|
| + AutofillPaymentInstrument* payment_instrument =
|
| + static_cast<AutofillPaymentInstrument*>(
|
| payment_request.selected_payment_method());
|
| EXPECT_EQ(address.guid(),
|
| payment_request.selected_shipping_profile()->guid());
|
| @@ -703,8 +705,8 @@ TEST_F(PaymentRequestTest, RecordUseStats_RequestContactInfoOnly) {
|
|
|
| TestPaymentRequest payment_request(web_payment_request,
|
| &personal_data_manager);
|
| - payments::AutofillPaymentInstrument* payment_instrument =
|
| - static_cast<payments::AutofillPaymentInstrument*>(
|
| + AutofillPaymentInstrument* payment_instrument =
|
| + static_cast<AutofillPaymentInstrument*>(
|
| payment_request.selected_payment_method());
|
| EXPECT_EQ(nullptr, payment_request.selected_shipping_profile());
|
| EXPECT_EQ(address.guid(), payment_request.selected_contact_profile()->guid());
|
| @@ -738,8 +740,8 @@ TEST_F(PaymentRequestTest, RecordUseStats_NoShippingOrContactInfoRequested) {
|
|
|
| TestPaymentRequest payment_request(web_payment_request,
|
| &personal_data_manager);
|
| - payments::AutofillPaymentInstrument* payment_instrument =
|
| - static_cast<payments::AutofillPaymentInstrument*>(
|
| + AutofillPaymentInstrument* payment_instrument =
|
| + static_cast<AutofillPaymentInstrument*>(
|
| payment_request.selected_payment_method());
|
| EXPECT_EQ(nullptr, payment_request.selected_shipping_profile());
|
| EXPECT_EQ(nullptr, payment_request.selected_contact_profile());
|
| @@ -753,3 +755,5 @@ TEST_F(PaymentRequestTest, RecordUseStats_NoShippingOrContactInfoRequested) {
|
|
|
| payment_request.RecordUseStats();
|
| }
|
| +
|
| +} // namespace payments
|
|
|