| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ios/chrome/browser/payments/payment_request.h" | 5 #include "ios/chrome/browser/payments/payment_request.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "base/test/scoped_task_environment.h" | 8 #include "base/test/scoped_task_environment.h" |
| 9 #include "components/autofill/core/browser/autofill_test_utils.h" | 9 #include "components/autofill/core/browser/autofill_test_utils.h" |
| 10 #include "components/autofill/core/browser/autofill_type.h" | 10 #include "components/autofill/core/browser/autofill_type.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 MockTestPersonalDataManager() : TestPersonalDataManager() {} | 32 MockTestPersonalDataManager() : TestPersonalDataManager() {} |
| 33 MOCK_METHOD1(RecordUseOf, void(const autofill::AutofillDataModel&)); | 33 MOCK_METHOD1(RecordUseOf, void(const autofill::AutofillDataModel&)); |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 MATCHER_P(GuidMatches, guid, "") { | 36 MATCHER_P(GuidMatches, guid, "") { |
| 37 return arg.guid() == guid; | 37 return arg.guid() == guid; |
| 38 } | 38 } |
| 39 | 39 |
| 40 } // namespace | 40 } // namespace |
| 41 | 41 |
| 42 namespace payments { |
| 43 |
| 42 class PaymentRequestTest : public testing::Test { | 44 class PaymentRequestTest : public testing::Test { |
| 43 protected: | 45 protected: |
| 44 // Returns PaymentDetails with one shipping option that's selected. | 46 // Returns PaymentDetails with one shipping option that's selected. |
| 45 web::PaymentDetails CreateDetailsWithShippingOption() { | 47 web::PaymentDetails CreateDetailsWithShippingOption() { |
| 46 web::PaymentDetails details; | 48 web::PaymentDetails details; |
| 47 std::vector<web::PaymentShippingOption> shipping_options; | 49 std::vector<web::PaymentShippingOption> shipping_options; |
| 48 web::PaymentShippingOption option1; | 50 web::PaymentShippingOption option1; |
| 49 option1.id = base::UTF8ToUTF16("option:1"); | 51 option1.id = base::UTF8ToUTF16("option:1"); |
| 50 option1.selected = true; | 52 option1.selected = true; |
| 51 shipping_options.push_back(std::move(option1)); | 53 shipping_options.push_back(std::move(option1)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 73 // currency code and currency system. | 75 // currency code and currency system. |
| 74 TEST_F(PaymentRequestTest, CreatesCurrencyFormatterCorrectly) { | 76 TEST_F(PaymentRequestTest, CreatesCurrencyFormatterCorrectly) { |
| 75 ASSERT_EQ("en", GetApplicationContext()->GetApplicationLocale()); | 77 ASSERT_EQ("en", GetApplicationContext()->GetApplicationLocale()); |
| 76 | 78 |
| 77 web::PaymentRequest web_payment_request; | 79 web::PaymentRequest web_payment_request; |
| 78 autofill::TestPersonalDataManager personal_data_manager; | 80 autofill::TestPersonalDataManager personal_data_manager; |
| 79 | 81 |
| 80 web_payment_request.details.total.amount.currency = base::ASCIIToUTF16("USD"); | 82 web_payment_request.details.total.amount.currency = base::ASCIIToUTF16("USD"); |
| 81 TestPaymentRequest payment_request1(web_payment_request, | 83 TestPaymentRequest payment_request1(web_payment_request, |
| 82 &personal_data_manager); | 84 &personal_data_manager); |
| 83 payments::CurrencyFormatter* currency_formatter = | 85 CurrencyFormatter* currency_formatter = |
| 84 payment_request1.GetOrCreateCurrencyFormatter(); | 86 payment_request1.GetOrCreateCurrencyFormatter(); |
| 85 EXPECT_EQ(base::UTF8ToUTF16("$55.00"), currency_formatter->Format("55.00")); | 87 EXPECT_EQ(base::UTF8ToUTF16("$55.00"), currency_formatter->Format("55.00")); |
| 86 EXPECT_EQ("USD", currency_formatter->formatted_currency_code()); | 88 EXPECT_EQ("USD", currency_formatter->formatted_currency_code()); |
| 87 | 89 |
| 88 web_payment_request.details.total.amount.currency = base::ASCIIToUTF16("JPY"); | 90 web_payment_request.details.total.amount.currency = base::ASCIIToUTF16("JPY"); |
| 89 TestPaymentRequest payment_request2(web_payment_request, | 91 TestPaymentRequest payment_request2(web_payment_request, |
| 90 &personal_data_manager); | 92 &personal_data_manager); |
| 91 currency_formatter = payment_request2.GetOrCreateCurrencyFormatter(); | 93 currency_formatter = payment_request2.GetOrCreateCurrencyFormatter(); |
| 92 EXPECT_EQ(base::UTF8ToUTF16("¥55"), currency_formatter->Format("55.00")); | 94 EXPECT_EQ(base::UTF8ToUTF16("¥55"), currency_formatter->Format("55.00")); |
| 93 EXPECT_EQ("JPY", currency_formatter->formatted_currency_code()); | 95 EXPECT_EQ("JPY", currency_formatter->formatted_currency_code()); |
| 94 | 96 |
| 95 web_payment_request.details.total.amount.currency_system = | 97 web_payment_request.details.total.amount.currency_system = |
| 96 base::ASCIIToUTF16("NOT_ISO4217"); | 98 base::ASCIIToUTF16("NOT_ISO4217"); |
| 97 web_payment_request.details.total.amount.currency = base::ASCIIToUTF16("USD"); | 99 web_payment_request.details.total.amount.currency = base::ASCIIToUTF16("USD"); |
| 98 TestPaymentRequest payment_request3(web_payment_request, | 100 TestPaymentRequest payment_request3(web_payment_request, |
| 99 &personal_data_manager); | 101 &personal_data_manager); |
| 100 currency_formatter = payment_request3.GetOrCreateCurrencyFormatter(); | 102 currency_formatter = payment_request3.GetOrCreateCurrencyFormatter(); |
| 101 EXPECT_EQ(base::UTF8ToUTF16("55.00"), currency_formatter->Format("55.00")); | 103 EXPECT_EQ(base::UTF8ToUTF16("55.00"), currency_formatter->Format("55.00")); |
| 102 EXPECT_EQ("USD", currency_formatter->formatted_currency_code()); | 104 EXPECT_EQ("USD", currency_formatter->formatted_currency_code()); |
| 103 } | 105 } |
| 104 | 106 |
| 105 // Tests that the accepted card networks are identified correctly. | 107 // Tests that the accepted card networks are identified correctly. |
| 106 TEST_F(PaymentRequestTest, AcceptedPaymentNetworks) { | 108 TEST_F(PaymentRequestTest, AcceptedPaymentNetworks) { |
| 107 web::PaymentRequest web_payment_request; | 109 web::PaymentRequest web_payment_request; |
| 108 autofill::TestPersonalDataManager personal_data_manager; | 110 autofill::TestPersonalDataManager personal_data_manager; |
| 109 | 111 |
| 110 payments::PaymentMethodData method_datum1; | 112 PaymentMethodData method_datum1; |
| 111 method_datum1.supported_methods.push_back("visa"); | 113 method_datum1.supported_methods.push_back("visa"); |
| 112 web_payment_request.method_data.push_back(method_datum1); | 114 web_payment_request.method_data.push_back(method_datum1); |
| 113 payments::PaymentMethodData method_datum2; | 115 PaymentMethodData method_datum2; |
| 114 method_datum2.supported_methods.push_back("mastercard"); | 116 method_datum2.supported_methods.push_back("mastercard"); |
| 115 web_payment_request.method_data.push_back(method_datum2); | 117 web_payment_request.method_data.push_back(method_datum2); |
| 116 | 118 |
| 117 TestPaymentRequest payment_request(web_payment_request, | 119 TestPaymentRequest payment_request(web_payment_request, |
| 118 &personal_data_manager); | 120 &personal_data_manager); |
| 119 ASSERT_EQ(2U, payment_request.supported_card_networks().size()); | 121 ASSERT_EQ(2U, payment_request.supported_card_networks().size()); |
| 120 EXPECT_EQ("visa", payment_request.supported_card_networks()[0]); | 122 EXPECT_EQ("visa", payment_request.supported_card_networks()[0]); |
| 121 EXPECT_EQ("mastercard", payment_request.supported_card_networks()[1]); | 123 EXPECT_EQ("mastercard", payment_request.supported_card_networks()[1]); |
| 122 } | 124 } |
| 123 | 125 |
| 124 // Test that parsing supported methods (with invalid values and duplicates) | 126 // Test that parsing supported methods (with invalid values and duplicates) |
| 125 // works as expected. | 127 // works as expected. |
| 126 TEST_F(PaymentRequestTest, SupportedMethods) { | 128 TEST_F(PaymentRequestTest, SupportedMethods) { |
| 127 web::PaymentRequest web_payment_request; | 129 web::PaymentRequest web_payment_request; |
| 128 autofill::TestPersonalDataManager personal_data_manager; | 130 autofill::TestPersonalDataManager personal_data_manager; |
| 129 | 131 |
| 130 payments::PaymentMethodData method_datum1; | 132 PaymentMethodData method_datum1; |
| 131 method_datum1.supported_methods.push_back("visa"); | 133 method_datum1.supported_methods.push_back("visa"); |
| 132 method_datum1.supported_methods.push_back("mastercard"); | 134 method_datum1.supported_methods.push_back("mastercard"); |
| 133 method_datum1.supported_methods.push_back("invalid"); | 135 method_datum1.supported_methods.push_back("invalid"); |
| 134 method_datum1.supported_methods.push_back(""); | 136 method_datum1.supported_methods.push_back(""); |
| 135 method_datum1.supported_methods.push_back("visa"); | 137 method_datum1.supported_methods.push_back("visa"); |
| 136 web_payment_request.method_data.push_back(method_datum1); | 138 web_payment_request.method_data.push_back(method_datum1); |
| 137 | 139 |
| 138 TestPaymentRequest payment_request(web_payment_request, | 140 TestPaymentRequest payment_request(web_payment_request, |
| 139 &personal_data_manager); | 141 &personal_data_manager); |
| 140 ASSERT_EQ(2U, payment_request.supported_card_networks().size()); | 142 ASSERT_EQ(2U, payment_request.supported_card_networks().size()); |
| 141 EXPECT_EQ("visa", payment_request.supported_card_networks()[0]); | 143 EXPECT_EQ("visa", payment_request.supported_card_networks()[0]); |
| 142 EXPECT_EQ("mastercard", payment_request.supported_card_networks()[1]); | 144 EXPECT_EQ("mastercard", payment_request.supported_card_networks()[1]); |
| 143 } | 145 } |
| 144 | 146 |
| 145 // Test that parsing supported methods in different method data entries (with | 147 // Test that parsing supported methods in different method data entries (with |
| 146 // invalid values and duplicates) works as expected. | 148 // invalid values and duplicates) works as expected. |
| 147 TEST_F(PaymentRequestTest, SupportedMethods_MultipleEntries) { | 149 TEST_F(PaymentRequestTest, SupportedMethods_MultipleEntries) { |
| 148 web::PaymentRequest web_payment_request; | 150 web::PaymentRequest web_payment_request; |
| 149 autofill::TestPersonalDataManager personal_data_manager; | 151 autofill::TestPersonalDataManager personal_data_manager; |
| 150 | 152 |
| 151 payments::PaymentMethodData method_datum1; | 153 PaymentMethodData method_datum1; |
| 152 method_datum1.supported_methods.push_back("visa"); | 154 method_datum1.supported_methods.push_back("visa"); |
| 153 web_payment_request.method_data.push_back(method_datum1); | 155 web_payment_request.method_data.push_back(method_datum1); |
| 154 payments::PaymentMethodData method_datum2; | 156 PaymentMethodData method_datum2; |
| 155 method_datum2.supported_methods.push_back("mastercard"); | 157 method_datum2.supported_methods.push_back("mastercard"); |
| 156 web_payment_request.method_data.push_back(method_datum2); | 158 web_payment_request.method_data.push_back(method_datum2); |
| 157 payments::PaymentMethodData method_datum3; | 159 PaymentMethodData method_datum3; |
| 158 method_datum3.supported_methods.push_back(""); | 160 method_datum3.supported_methods.push_back(""); |
| 159 web_payment_request.method_data.push_back(method_datum3); | 161 web_payment_request.method_data.push_back(method_datum3); |
| 160 payments::PaymentMethodData method_datum4; | 162 PaymentMethodData method_datum4; |
| 161 method_datum4.supported_methods.push_back("visa"); | 163 method_datum4.supported_methods.push_back("visa"); |
| 162 web_payment_request.method_data.push_back(method_datum4); | 164 web_payment_request.method_data.push_back(method_datum4); |
| 163 | 165 |
| 164 TestPaymentRequest payment_request(web_payment_request, | 166 TestPaymentRequest payment_request(web_payment_request, |
| 165 &personal_data_manager); | 167 &personal_data_manager); |
| 166 ASSERT_EQ(2U, payment_request.supported_card_networks().size()); | 168 ASSERT_EQ(2U, payment_request.supported_card_networks().size()); |
| 167 EXPECT_EQ("visa", payment_request.supported_card_networks()[0]); | 169 EXPECT_EQ("visa", payment_request.supported_card_networks()[0]); |
| 168 EXPECT_EQ("mastercard", payment_request.supported_card_networks()[1]); | 170 EXPECT_EQ("mastercard", payment_request.supported_card_networks()[1]); |
| 169 } | 171 } |
| 170 | 172 |
| 171 // Test that only specifying basic-card means that all are supported. | 173 // Test that only specifying basic-card means that all are supported. |
| 172 TEST_F(PaymentRequestTest, SupportedMethods_OnlyBasicCard) { | 174 TEST_F(PaymentRequestTest, SupportedMethods_OnlyBasicCard) { |
| 173 web::PaymentRequest web_payment_request; | 175 web::PaymentRequest web_payment_request; |
| 174 autofill::TestPersonalDataManager personal_data_manager; | 176 autofill::TestPersonalDataManager personal_data_manager; |
| 175 | 177 |
| 176 payments::PaymentMethodData method_datum1; | 178 PaymentMethodData method_datum1; |
| 177 method_datum1.supported_methods.push_back("basic-card"); | 179 method_datum1.supported_methods.push_back("basic-card"); |
| 178 web_payment_request.method_data.push_back(method_datum1); | 180 web_payment_request.method_data.push_back(method_datum1); |
| 179 | 181 |
| 180 TestPaymentRequest payment_request(web_payment_request, | 182 TestPaymentRequest payment_request(web_payment_request, |
| 181 &personal_data_manager); | 183 &personal_data_manager); |
| 182 | 184 |
| 183 // All of the basic card networks are supported. | 185 // All of the basic card networks are supported. |
| 184 ASSERT_EQ(8U, payment_request.supported_card_networks().size()); | 186 ASSERT_EQ(8U, payment_request.supported_card_networks().size()); |
| 185 EXPECT_EQ("amex", payment_request.supported_card_networks()[0]); | 187 EXPECT_EQ("amex", payment_request.supported_card_networks()[0]); |
| 186 EXPECT_EQ("diners", payment_request.supported_card_networks()[1]); | 188 EXPECT_EQ("diners", payment_request.supported_card_networks()[1]); |
| 187 EXPECT_EQ("discover", payment_request.supported_card_networks()[2]); | 189 EXPECT_EQ("discover", payment_request.supported_card_networks()[2]); |
| 188 EXPECT_EQ("jcb", payment_request.supported_card_networks()[3]); | 190 EXPECT_EQ("jcb", payment_request.supported_card_networks()[3]); |
| 189 EXPECT_EQ("mastercard", payment_request.supported_card_networks()[4]); | 191 EXPECT_EQ("mastercard", payment_request.supported_card_networks()[4]); |
| 190 EXPECT_EQ("mir", payment_request.supported_card_networks()[5]); | 192 EXPECT_EQ("mir", payment_request.supported_card_networks()[5]); |
| 191 EXPECT_EQ("unionpay", payment_request.supported_card_networks()[6]); | 193 EXPECT_EQ("unionpay", payment_request.supported_card_networks()[6]); |
| 192 EXPECT_EQ("visa", payment_request.supported_card_networks()[7]); | 194 EXPECT_EQ("visa", payment_request.supported_card_networks()[7]); |
| 193 } | 195 } |
| 194 | 196 |
| 195 // Test that specifying a method AND basic-card means that all are supported, | 197 // Test that specifying a method AND basic-card means that all are supported, |
| 196 // but with the method as first. | 198 // but with the method as first. |
| 197 TEST_F(PaymentRequestTest, SupportedMethods_BasicCard_WithSpecificMethod) { | 199 TEST_F(PaymentRequestTest, SupportedMethods_BasicCard_WithSpecificMethod) { |
| 198 web::PaymentRequest web_payment_request; | 200 web::PaymentRequest web_payment_request; |
| 199 autofill::TestPersonalDataManager personal_data_manager; | 201 autofill::TestPersonalDataManager personal_data_manager; |
| 200 | 202 |
| 201 payments::PaymentMethodData method_datum1; | 203 PaymentMethodData method_datum1; |
| 202 method_datum1.supported_methods.push_back("jcb"); | 204 method_datum1.supported_methods.push_back("jcb"); |
| 203 method_datum1.supported_methods.push_back("basic-card"); | 205 method_datum1.supported_methods.push_back("basic-card"); |
| 204 web_payment_request.method_data.push_back(method_datum1); | 206 web_payment_request.method_data.push_back(method_datum1); |
| 205 | 207 |
| 206 TestPaymentRequest payment_request(web_payment_request, | 208 TestPaymentRequest payment_request(web_payment_request, |
| 207 &personal_data_manager); | 209 &personal_data_manager); |
| 208 | 210 |
| 209 // All of the basic card networks are supported, but JCB is first because it | 211 // All of the basic card networks are supported, but JCB is first because it |
| 210 // was specified first. | 212 // was specified first. |
| 211 EXPECT_EQ(8u, payment_request.supported_card_networks().size()); | 213 EXPECT_EQ(8u, payment_request.supported_card_networks().size()); |
| 212 EXPECT_EQ("jcb", payment_request.supported_card_networks()[0]); | 214 EXPECT_EQ("jcb", payment_request.supported_card_networks()[0]); |
| 213 EXPECT_EQ("amex", payment_request.supported_card_networks()[1]); | 215 EXPECT_EQ("amex", payment_request.supported_card_networks()[1]); |
| 214 EXPECT_EQ("diners", payment_request.supported_card_networks()[2]); | 216 EXPECT_EQ("diners", payment_request.supported_card_networks()[2]); |
| 215 EXPECT_EQ("discover", payment_request.supported_card_networks()[3]); | 217 EXPECT_EQ("discover", payment_request.supported_card_networks()[3]); |
| 216 EXPECT_EQ("mastercard", payment_request.supported_card_networks()[4]); | 218 EXPECT_EQ("mastercard", payment_request.supported_card_networks()[4]); |
| 217 EXPECT_EQ("mir", payment_request.supported_card_networks()[5]); | 219 EXPECT_EQ("mir", payment_request.supported_card_networks()[5]); |
| 218 EXPECT_EQ("unionpay", payment_request.supported_card_networks()[6]); | 220 EXPECT_EQ("unionpay", payment_request.supported_card_networks()[6]); |
| 219 EXPECT_EQ("visa", payment_request.supported_card_networks()[7]); | 221 EXPECT_EQ("visa", payment_request.supported_card_networks()[7]); |
| 220 } | 222 } |
| 221 | 223 |
| 222 // Test that specifying basic-card with a supported network (with previous | 224 // Test that specifying basic-card with a supported network (with previous |
| 223 // supported methods) will work as expected | 225 // supported methods) will work as expected |
| 224 TEST_F(PaymentRequestTest, SupportedMethods_BasicCard_Overlap) { | 226 TEST_F(PaymentRequestTest, SupportedMethods_BasicCard_Overlap) { |
| 225 web::PaymentRequest web_payment_request; | 227 web::PaymentRequest web_payment_request; |
| 226 autofill::TestPersonalDataManager personal_data_manager; | 228 autofill::TestPersonalDataManager personal_data_manager; |
| 227 | 229 |
| 228 payments::PaymentMethodData method_datum1; | 230 PaymentMethodData method_datum1; |
| 229 method_datum1.supported_methods.push_back("mastercard"); | 231 method_datum1.supported_methods.push_back("mastercard"); |
| 230 method_datum1.supported_methods.push_back("visa"); | 232 method_datum1.supported_methods.push_back("visa"); |
| 231 web_payment_request.method_data.push_back(method_datum1); | 233 web_payment_request.method_data.push_back(method_datum1); |
| 232 payments::PaymentMethodData method_datum2; | 234 PaymentMethodData method_datum2; |
| 233 method_datum2.supported_methods.push_back("basic-card"); | 235 method_datum2.supported_methods.push_back("basic-card"); |
| 234 method_datum2.supported_networks.push_back("visa"); | 236 method_datum2.supported_networks.push_back("visa"); |
| 235 method_datum2.supported_networks.push_back("mastercard"); | 237 method_datum2.supported_networks.push_back("mastercard"); |
| 236 method_datum2.supported_networks.push_back("unionpay"); | 238 method_datum2.supported_networks.push_back("unionpay"); |
| 237 web_payment_request.method_data.push_back(method_datum2); | 239 web_payment_request.method_data.push_back(method_datum2); |
| 238 | 240 |
| 239 TestPaymentRequest payment_request(web_payment_request, | 241 TestPaymentRequest payment_request(web_payment_request, |
| 240 &personal_data_manager); | 242 &personal_data_manager); |
| 241 | 243 |
| 242 EXPECT_EQ(3u, payment_request.supported_card_networks().size()); | 244 EXPECT_EQ(3u, payment_request.supported_card_networks().size()); |
| 243 EXPECT_EQ("mastercard", payment_request.supported_card_networks()[0]); | 245 EXPECT_EQ("mastercard", payment_request.supported_card_networks()[0]); |
| 244 EXPECT_EQ("visa", payment_request.supported_card_networks()[1]); | 246 EXPECT_EQ("visa", payment_request.supported_card_networks()[1]); |
| 245 EXPECT_EQ("unionpay", payment_request.supported_card_networks()[2]); | 247 EXPECT_EQ("unionpay", payment_request.supported_card_networks()[2]); |
| 246 } | 248 } |
| 247 | 249 |
| 248 // Test that specifying basic-card with supported networks after specifying | 250 // Test that specifying basic-card with supported networks after specifying |
| 249 // some methods | 251 // some methods |
| 250 TEST_F(PaymentRequestTest, SupportedMethods_BasicCard_WithSupportedNetworks) { | 252 TEST_F(PaymentRequestTest, SupportedMethods_BasicCard_WithSupportedNetworks) { |
| 251 web::PaymentRequest web_payment_request; | 253 web::PaymentRequest web_payment_request; |
| 252 autofill::TestPersonalDataManager personal_data_manager; | 254 autofill::TestPersonalDataManager personal_data_manager; |
| 253 | 255 |
| 254 payments::PaymentMethodData method_datum1; | 256 PaymentMethodData method_datum1; |
| 255 method_datum1.supported_methods.push_back("basic-card"); | 257 method_datum1.supported_methods.push_back("basic-card"); |
| 256 method_datum1.supported_networks.push_back("visa"); | 258 method_datum1.supported_networks.push_back("visa"); |
| 257 method_datum1.supported_networks.push_back("unionpay"); | 259 method_datum1.supported_networks.push_back("unionpay"); |
| 258 web_payment_request.method_data.push_back(method_datum1); | 260 web_payment_request.method_data.push_back(method_datum1); |
| 259 | 261 |
| 260 TestPaymentRequest payment_request(web_payment_request, | 262 TestPaymentRequest payment_request(web_payment_request, |
| 261 &personal_data_manager); | 263 &personal_data_manager); |
| 262 | 264 |
| 263 // Only the specified networks are supported. | 265 // Only the specified networks are supported. |
| 264 EXPECT_EQ(2u, payment_request.supported_card_networks().size()); | 266 EXPECT_EQ(2u, payment_request.supported_card_networks().size()); |
| 265 EXPECT_EQ("visa", payment_request.supported_card_networks()[0]); | 267 EXPECT_EQ("visa", payment_request.supported_card_networks()[0]); |
| 266 EXPECT_EQ("unionpay", payment_request.supported_card_networks()[1]); | 268 EXPECT_EQ("unionpay", payment_request.supported_card_networks()[1]); |
| 267 } | 269 } |
| 268 | 270 |
| 269 // Tests that an autofill payment instrumnt e.g., credit cards can be added | 271 // Tests that an autofill payment instrumnt e.g., credit cards can be added |
| 270 // to the list of available payment methods. | 272 // to the list of available payment methods. |
| 271 TEST_F(PaymentRequestTest, AddAutofillPaymentInstrument) { | 273 TEST_F(PaymentRequestTest, AddAutofillPaymentInstrument) { |
| 272 web::PaymentRequest web_payment_request; | 274 web::PaymentRequest web_payment_request; |
| 273 payments::PaymentMethodData method_datum; | 275 PaymentMethodData method_datum; |
| 274 method_datum.supported_methods.push_back("basic-card"); | 276 method_datum.supported_methods.push_back("basic-card"); |
| 275 method_datum.supported_networks.push_back("visa"); | 277 method_datum.supported_networks.push_back("visa"); |
| 276 method_datum.supported_networks.push_back("amex"); | 278 method_datum.supported_networks.push_back("amex"); |
| 277 web_payment_request.method_data.push_back(method_datum); | 279 web_payment_request.method_data.push_back(method_datum); |
| 278 | 280 |
| 279 autofill::TestPersonalDataManager personal_data_manager; | 281 autofill::TestPersonalDataManager personal_data_manager; |
| 280 | 282 |
| 281 autofill::CreditCard credit_card_1 = autofill::test::GetCreditCard(); | 283 autofill::CreditCard credit_card_1 = autofill::test::GetCreditCard(); |
| 282 personal_data_manager.AddTestingCreditCard(&credit_card_1); | 284 personal_data_manager.AddTestingCreditCard(&credit_card_1); |
| 283 | 285 |
| 284 TestPaymentRequest payment_request(web_payment_request, | 286 TestPaymentRequest payment_request(web_payment_request, |
| 285 &personal_data_manager); | 287 &personal_data_manager); |
| 286 EXPECT_EQ(1U, payment_request.payment_methods().size()); | 288 EXPECT_EQ(1U, payment_request.payment_methods().size()); |
| 287 | 289 |
| 288 autofill::CreditCard credit_card_2 = autofill::test::GetCreditCard2(); | 290 autofill::CreditCard credit_card_2 = autofill::test::GetCreditCard2(); |
| 289 payments::AutofillPaymentInstrument* added_credit_card = | 291 AutofillPaymentInstrument* added_credit_card = |
| 290 payment_request.AddAutofillPaymentInstrument(credit_card_2); | 292 payment_request.AddAutofillPaymentInstrument(credit_card_2); |
| 291 | 293 |
| 292 EXPECT_EQ(2U, payment_request.payment_methods().size()); | 294 EXPECT_EQ(2U, payment_request.payment_methods().size()); |
| 293 EXPECT_EQ(credit_card_2, *added_credit_card->credit_card()); | 295 EXPECT_EQ(credit_card_2, *added_credit_card->credit_card()); |
| 294 } | 296 } |
| 295 | 297 |
| 296 // Tests that a profile can be added to the list of available profiles. | 298 // Tests that a profile can be added to the list of available profiles. |
| 297 TEST_F(PaymentRequestTest, AddAutofillProfile) { | 299 TEST_F(PaymentRequestTest, AddAutofillProfile) { |
| 298 web::PaymentRequest web_payment_request; | 300 web::PaymentRequest web_payment_request; |
| 299 web_payment_request.options = CreatePaymentOptions( | 301 web_payment_request.options = CreatePaymentOptions( |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 credit_card.SetExpirationYear(2016); // Expired. | 508 credit_card.SetExpirationYear(2016); // Expired. |
| 507 credit_card.set_billing_address_id(billing_address.guid()); | 509 credit_card.set_billing_address_id(billing_address.guid()); |
| 508 | 510 |
| 509 web::PaymentRequest web_payment_request = | 511 web::PaymentRequest web_payment_request = |
| 510 payment_request_test_util::CreateTestWebPaymentRequest(); | 512 payment_request_test_util::CreateTestWebPaymentRequest(); |
| 511 | 513 |
| 512 // credit_card is selected because expired cards are valid for payment. | 514 // credit_card is selected because expired cards are valid for payment. |
| 513 TestPaymentRequest payment_request(web_payment_request, | 515 TestPaymentRequest payment_request(web_payment_request, |
| 514 &personal_data_manager); | 516 &personal_data_manager); |
| 515 EXPECT_EQ(payment_request.selected_payment_method()->type(), | 517 EXPECT_EQ(payment_request.selected_payment_method()->type(), |
| 516 payments::PaymentInstrument::Type::AUTOFILL); | 518 PaymentInstrument::Type::AUTOFILL); |
| 517 payments::AutofillPaymentInstrument* payment_instrument = | 519 AutofillPaymentInstrument* payment_instrument = |
| 518 static_cast<payments::AutofillPaymentInstrument*>( | 520 static_cast<AutofillPaymentInstrument*>( |
| 519 payment_request.selected_payment_method()); | 521 payment_request.selected_payment_method()); |
| 520 EXPECT_EQ(credit_card.guid(), payment_instrument->credit_card()->guid()); | 522 EXPECT_EQ(credit_card.guid(), payment_instrument->credit_card()->guid()); |
| 521 } | 523 } |
| 522 | 524 |
| 523 // Test that loading complete payment methods works as expected. | 525 // Test that loading complete payment methods works as expected. |
| 524 TEST_F(PaymentRequestTest, SelectedPaymentMethod_Complete) { | 526 TEST_F(PaymentRequestTest, SelectedPaymentMethod_Complete) { |
| 525 autofill::TestPersonalDataManager personal_data_manager; | 527 autofill::TestPersonalDataManager personal_data_manager; |
| 526 autofill::AutofillProfile billing_address = autofill::test::GetFullProfile(); | 528 autofill::AutofillProfile billing_address = autofill::test::GetFullProfile(); |
| 527 personal_data_manager.AddTestingProfile(&billing_address); | 529 personal_data_manager.AddTestingProfile(&billing_address); |
| 528 autofill::CreditCard credit_card = autofill::test::GetCreditCard(); | 530 autofill::CreditCard credit_card = autofill::test::GetCreditCard(); |
| 529 credit_card.set_use_count(5U); | 531 credit_card.set_use_count(5U); |
| 530 personal_data_manager.AddTestingCreditCard(&credit_card); | 532 personal_data_manager.AddTestingCreditCard(&credit_card); |
| 531 credit_card.set_billing_address_id(billing_address.guid()); | 533 credit_card.set_billing_address_id(billing_address.guid()); |
| 532 autofill::CreditCard credit_card2 = autofill::test::GetCreditCard2(); | 534 autofill::CreditCard credit_card2 = autofill::test::GetCreditCard2(); |
| 533 credit_card2.set_use_count(15U); | 535 credit_card2.set_use_count(15U); |
| 534 personal_data_manager.AddTestingCreditCard(&credit_card2); | 536 personal_data_manager.AddTestingCreditCard(&credit_card2); |
| 535 credit_card2.set_billing_address_id(billing_address.guid()); | 537 credit_card2.set_billing_address_id(billing_address.guid()); |
| 536 | 538 |
| 537 web::PaymentRequest web_payment_request = | 539 web::PaymentRequest web_payment_request = |
| 538 payment_request_test_util::CreateTestWebPaymentRequest(); | 540 payment_request_test_util::CreateTestWebPaymentRequest(); |
| 539 | 541 |
| 540 // credit_card2 is selected because it has the most use count (Frecency | 542 // credit_card2 is selected because it has the most use count (Frecency |
| 541 // model). | 543 // model). |
| 542 TestPaymentRequest payment_request(web_payment_request, | 544 TestPaymentRequest payment_request(web_payment_request, |
| 543 &personal_data_manager); | 545 &personal_data_manager); |
| 544 payments::AutofillPaymentInstrument* payment_instrument = | 546 AutofillPaymentInstrument* payment_instrument = |
| 545 static_cast<payments::AutofillPaymentInstrument*>( | 547 static_cast<AutofillPaymentInstrument*>( |
| 546 payment_request.selected_payment_method()); | 548 payment_request.selected_payment_method()); |
| 547 EXPECT_EQ(credit_card2.guid(), payment_instrument->credit_card()->guid()); | 549 EXPECT_EQ(credit_card2.guid(), payment_instrument->credit_card()->guid()); |
| 548 } | 550 } |
| 549 | 551 |
| 550 // Test that loading incomplete payment methods works as expected. | 552 // Test that loading incomplete payment methods works as expected. |
| 551 TEST_F(PaymentRequestTest, SelectedPaymentMethod_Incomplete) { | 553 TEST_F(PaymentRequestTest, SelectedPaymentMethod_Incomplete) { |
| 552 autofill::TestPersonalDataManager personal_data_manager; | 554 autofill::TestPersonalDataManager personal_data_manager; |
| 553 autofill::AutofillProfile billing_address = autofill::test::GetFullProfile(); | 555 autofill::AutofillProfile billing_address = autofill::test::GetFullProfile(); |
| 554 personal_data_manager.AddTestingProfile(&billing_address); | 556 personal_data_manager.AddTestingProfile(&billing_address); |
| 555 autofill::CreditCard credit_card = autofill::test::GetCreditCard(); | 557 autofill::CreditCard credit_card = autofill::test::GetCreditCard(); |
| 556 credit_card.set_use_count(5U); | 558 credit_card.set_use_count(5U); |
| 557 personal_data_manager.AddTestingCreditCard(&credit_card); | 559 personal_data_manager.AddTestingCreditCard(&credit_card); |
| 558 credit_card.set_billing_address_id(billing_address.guid()); | 560 credit_card.set_billing_address_id(billing_address.guid()); |
| 559 autofill::CreditCard credit_card2 = autofill::test::GetCreditCard2(); | 561 autofill::CreditCard credit_card2 = autofill::test::GetCreditCard2(); |
| 560 credit_card2.set_use_count(15U); | 562 credit_card2.set_use_count(15U); |
| 561 personal_data_manager.AddTestingCreditCard(&credit_card2); | 563 personal_data_manager.AddTestingCreditCard(&credit_card2); |
| 562 | 564 |
| 563 web::PaymentRequest web_payment_request = | 565 web::PaymentRequest web_payment_request = |
| 564 payment_request_test_util::CreateTestWebPaymentRequest(); | 566 payment_request_test_util::CreateTestWebPaymentRequest(); |
| 565 | 567 |
| 566 // Even though credit_card2 has more use counts, credit_card is selected | 568 // Even though credit_card2 has more use counts, credit_card is selected |
| 567 // because it is complete. | 569 // because it is complete. |
| 568 TestPaymentRequest payment_request(web_payment_request, | 570 TestPaymentRequest payment_request(web_payment_request, |
| 569 &personal_data_manager); | 571 &personal_data_manager); |
| 570 payments::AutofillPaymentInstrument* payment_instrument = | 572 AutofillPaymentInstrument* payment_instrument = |
| 571 static_cast<payments::AutofillPaymentInstrument*>( | 573 static_cast<AutofillPaymentInstrument*>( |
| 572 payment_request.selected_payment_method()); | 574 payment_request.selected_payment_method()); |
| 573 EXPECT_EQ(credit_card.guid(), payment_instrument->credit_card()->guid()); | 575 EXPECT_EQ(credit_card.guid(), payment_instrument->credit_card()->guid()); |
| 574 } | 576 } |
| 575 | 577 |
| 576 // Test that the use counts of the data models are updated as expected when | 578 // Test that the use counts of the data models are updated as expected when |
| 577 // different autofill profiles are used as the shipping address and the contact | 579 // different autofill profiles are used as the shipping address and the contact |
| 578 // info. | 580 // info. |
| 579 TEST_F(PaymentRequestTest, RecordUseStats_RequestShippingAndContactInfo) { | 581 TEST_F(PaymentRequestTest, RecordUseStats_RequestShippingAndContactInfo) { |
| 580 MockTestPersonalDataManager personal_data_manager; | 582 MockTestPersonalDataManager personal_data_manager; |
| 581 // Add a profile that is incomplete for a contact info, but is used more | 583 // Add a profile that is incomplete for a contact info, but is used more |
| 582 // frequently so is selected as the default shipping address. | 584 // frequently so is selected as the default shipping address. |
| 583 autofill::AutofillProfile address = autofill::test::GetFullProfile(); | 585 autofill::AutofillProfile address = autofill::test::GetFullProfile(); |
| 584 address.SetInfo(autofill::AutofillType(autofill::EMAIL_ADDRESS), | 586 address.SetInfo(autofill::AutofillType(autofill::EMAIL_ADDRESS), |
| 585 base::string16(), "en-US"); | 587 base::string16(), "en-US"); |
| 586 address.set_use_count(10U); | 588 address.set_use_count(10U); |
| 587 personal_data_manager.AddTestingProfile(&address); | 589 personal_data_manager.AddTestingProfile(&address); |
| 588 autofill::AutofillProfile contact_info = autofill::test::GetFullProfile2(); | 590 autofill::AutofillProfile contact_info = autofill::test::GetFullProfile2(); |
| 589 contact_info.set_use_count(5U); | 591 contact_info.set_use_count(5U); |
| 590 personal_data_manager.AddTestingProfile(&contact_info); | 592 personal_data_manager.AddTestingProfile(&contact_info); |
| 591 autofill::CreditCard credit_card = autofill::test::GetCreditCard(); | 593 autofill::CreditCard credit_card = autofill::test::GetCreditCard(); |
| 592 personal_data_manager.AddTestingCreditCard(&credit_card); | 594 personal_data_manager.AddTestingCreditCard(&credit_card); |
| 593 credit_card.set_billing_address_id(address.guid()); | 595 credit_card.set_billing_address_id(address.guid()); |
| 594 | 596 |
| 595 web::PaymentRequest web_payment_request = | 597 web::PaymentRequest web_payment_request = |
| 596 payment_request_test_util::CreateTestWebPaymentRequest(); | 598 payment_request_test_util::CreateTestWebPaymentRequest(); |
| 597 | 599 |
| 598 TestPaymentRequest payment_request(web_payment_request, | 600 TestPaymentRequest payment_request(web_payment_request, |
| 599 &personal_data_manager); | 601 &personal_data_manager); |
| 600 payments::AutofillPaymentInstrument* payment_instrument = | 602 AutofillPaymentInstrument* payment_instrument = |
| 601 static_cast<payments::AutofillPaymentInstrument*>( | 603 static_cast<AutofillPaymentInstrument*>( |
| 602 payment_request.selected_payment_method()); | 604 payment_request.selected_payment_method()); |
| 603 EXPECT_EQ(address.guid(), | 605 EXPECT_EQ(address.guid(), |
| 604 payment_request.selected_shipping_profile()->guid()); | 606 payment_request.selected_shipping_profile()->guid()); |
| 605 EXPECT_EQ(contact_info.guid(), | 607 EXPECT_EQ(contact_info.guid(), |
| 606 payment_request.selected_contact_profile()->guid()); | 608 payment_request.selected_contact_profile()->guid()); |
| 607 EXPECT_EQ(credit_card.guid(), payment_instrument->credit_card()->guid()); | 609 EXPECT_EQ(credit_card.guid(), payment_instrument->credit_card()->guid()); |
| 608 | 610 |
| 609 EXPECT_CALL(personal_data_manager, RecordUseOf(GuidMatches(address.guid()))) | 611 EXPECT_CALL(personal_data_manager, RecordUseOf(GuidMatches(address.guid()))) |
| 610 .Times(1); | 612 .Times(1); |
| 611 EXPECT_CALL(personal_data_manager, | 613 EXPECT_CALL(personal_data_manager, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 626 personal_data_manager.AddTestingProfile(&address); | 628 personal_data_manager.AddTestingProfile(&address); |
| 627 autofill::CreditCard credit_card = autofill::test::GetCreditCard(); | 629 autofill::CreditCard credit_card = autofill::test::GetCreditCard(); |
| 628 personal_data_manager.AddTestingCreditCard(&credit_card); | 630 personal_data_manager.AddTestingCreditCard(&credit_card); |
| 629 credit_card.set_billing_address_id(address.guid()); | 631 credit_card.set_billing_address_id(address.guid()); |
| 630 | 632 |
| 631 web::PaymentRequest web_payment_request = | 633 web::PaymentRequest web_payment_request = |
| 632 payment_request_test_util::CreateTestWebPaymentRequest(); | 634 payment_request_test_util::CreateTestWebPaymentRequest(); |
| 633 | 635 |
| 634 TestPaymentRequest payment_request(web_payment_request, | 636 TestPaymentRequest payment_request(web_payment_request, |
| 635 &personal_data_manager); | 637 &personal_data_manager); |
| 636 payments::AutofillPaymentInstrument* payment_instrument = | 638 AutofillPaymentInstrument* payment_instrument = |
| 637 static_cast<payments::AutofillPaymentInstrument*>( | 639 static_cast<AutofillPaymentInstrument*>( |
| 638 payment_request.selected_payment_method()); | 640 payment_request.selected_payment_method()); |
| 639 EXPECT_EQ(address.guid(), | 641 EXPECT_EQ(address.guid(), |
| 640 payment_request.selected_shipping_profile()->guid()); | 642 payment_request.selected_shipping_profile()->guid()); |
| 641 EXPECT_EQ(address.guid(), payment_request.selected_contact_profile()->guid()); | 643 EXPECT_EQ(address.guid(), payment_request.selected_contact_profile()->guid()); |
| 642 EXPECT_EQ(credit_card.guid(), payment_instrument->credit_card()->guid()); | 644 EXPECT_EQ(credit_card.guid(), payment_instrument->credit_card()->guid()); |
| 643 | 645 |
| 644 // Even though |address| is used for contact info, shipping address, and | 646 // Even though |address| is used for contact info, shipping address, and |
| 645 // credit_card's billing address, the stats should be updated only once. | 647 // credit_card's billing address, the stats should be updated only once. |
| 646 EXPECT_CALL(personal_data_manager, RecordUseOf(GuidMatches(address.guid()))) | 648 EXPECT_CALL(personal_data_manager, RecordUseOf(GuidMatches(address.guid()))) |
| 647 .Times(1); | 649 .Times(1); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 663 credit_card.set_billing_address_id(address.guid()); | 665 credit_card.set_billing_address_id(address.guid()); |
| 664 | 666 |
| 665 web::PaymentRequest web_payment_request = | 667 web::PaymentRequest web_payment_request = |
| 666 payment_request_test_util::CreateTestWebPaymentRequest(); | 668 payment_request_test_util::CreateTestWebPaymentRequest(); |
| 667 web_payment_request.options.request_payer_name = false; | 669 web_payment_request.options.request_payer_name = false; |
| 668 web_payment_request.options.request_payer_email = false; | 670 web_payment_request.options.request_payer_email = false; |
| 669 web_payment_request.options.request_payer_phone = false; | 671 web_payment_request.options.request_payer_phone = false; |
| 670 | 672 |
| 671 TestPaymentRequest payment_request(web_payment_request, | 673 TestPaymentRequest payment_request(web_payment_request, |
| 672 &personal_data_manager); | 674 &personal_data_manager); |
| 673 payments::AutofillPaymentInstrument* payment_instrument = | 675 AutofillPaymentInstrument* payment_instrument = |
| 674 static_cast<payments::AutofillPaymentInstrument*>( | 676 static_cast<AutofillPaymentInstrument*>( |
| 675 payment_request.selected_payment_method()); | 677 payment_request.selected_payment_method()); |
| 676 EXPECT_EQ(address.guid(), | 678 EXPECT_EQ(address.guid(), |
| 677 payment_request.selected_shipping_profile()->guid()); | 679 payment_request.selected_shipping_profile()->guid()); |
| 678 EXPECT_EQ(nullptr, payment_request.selected_contact_profile()); | 680 EXPECT_EQ(nullptr, payment_request.selected_contact_profile()); |
| 679 EXPECT_EQ(credit_card.guid(), payment_instrument->credit_card()->guid()); | 681 EXPECT_EQ(credit_card.guid(), payment_instrument->credit_card()->guid()); |
| 680 | 682 |
| 681 EXPECT_CALL(personal_data_manager, RecordUseOf(GuidMatches(address.guid()))) | 683 EXPECT_CALL(personal_data_manager, RecordUseOf(GuidMatches(address.guid()))) |
| 682 .Times(1); | 684 .Times(1); |
| 683 EXPECT_CALL(personal_data_manager, | 685 EXPECT_CALL(personal_data_manager, |
| 684 RecordUseOf(GuidMatches(credit_card.guid()))) | 686 RecordUseOf(GuidMatches(credit_card.guid()))) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 696 autofill::CreditCard credit_card = autofill::test::GetCreditCard(); | 698 autofill::CreditCard credit_card = autofill::test::GetCreditCard(); |
| 697 personal_data_manager.AddTestingCreditCard(&credit_card); | 699 personal_data_manager.AddTestingCreditCard(&credit_card); |
| 698 credit_card.set_billing_address_id(address.guid()); | 700 credit_card.set_billing_address_id(address.guid()); |
| 699 | 701 |
| 700 web::PaymentRequest web_payment_request = | 702 web::PaymentRequest web_payment_request = |
| 701 payment_request_test_util::CreateTestWebPaymentRequest(); | 703 payment_request_test_util::CreateTestWebPaymentRequest(); |
| 702 web_payment_request.options.request_shipping = false; | 704 web_payment_request.options.request_shipping = false; |
| 703 | 705 |
| 704 TestPaymentRequest payment_request(web_payment_request, | 706 TestPaymentRequest payment_request(web_payment_request, |
| 705 &personal_data_manager); | 707 &personal_data_manager); |
| 706 payments::AutofillPaymentInstrument* payment_instrument = | 708 AutofillPaymentInstrument* payment_instrument = |
| 707 static_cast<payments::AutofillPaymentInstrument*>( | 709 static_cast<AutofillPaymentInstrument*>( |
| 708 payment_request.selected_payment_method()); | 710 payment_request.selected_payment_method()); |
| 709 EXPECT_EQ(nullptr, payment_request.selected_shipping_profile()); | 711 EXPECT_EQ(nullptr, payment_request.selected_shipping_profile()); |
| 710 EXPECT_EQ(address.guid(), payment_request.selected_contact_profile()->guid()); | 712 EXPECT_EQ(address.guid(), payment_request.selected_contact_profile()->guid()); |
| 711 EXPECT_EQ(credit_card.guid(), payment_instrument->credit_card()->guid()); | 713 EXPECT_EQ(credit_card.guid(), payment_instrument->credit_card()->guid()); |
| 712 | 714 |
| 713 EXPECT_CALL(personal_data_manager, RecordUseOf(GuidMatches(address.guid()))) | 715 EXPECT_CALL(personal_data_manager, RecordUseOf(GuidMatches(address.guid()))) |
| 714 .Times(1); | 716 .Times(1); |
| 715 EXPECT_CALL(personal_data_manager, | 717 EXPECT_CALL(personal_data_manager, |
| 716 RecordUseOf(GuidMatches(credit_card.guid()))) | 718 RecordUseOf(GuidMatches(credit_card.guid()))) |
| 717 .Times(1); | 719 .Times(1); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 731 | 733 |
| 732 web::PaymentRequest web_payment_request = | 734 web::PaymentRequest web_payment_request = |
| 733 payment_request_test_util::CreateTestWebPaymentRequest(); | 735 payment_request_test_util::CreateTestWebPaymentRequest(); |
| 734 web_payment_request.options.request_shipping = false; | 736 web_payment_request.options.request_shipping = false; |
| 735 web_payment_request.options.request_payer_name = false; | 737 web_payment_request.options.request_payer_name = false; |
| 736 web_payment_request.options.request_payer_email = false; | 738 web_payment_request.options.request_payer_email = false; |
| 737 web_payment_request.options.request_payer_phone = false; | 739 web_payment_request.options.request_payer_phone = false; |
| 738 | 740 |
| 739 TestPaymentRequest payment_request(web_payment_request, | 741 TestPaymentRequest payment_request(web_payment_request, |
| 740 &personal_data_manager); | 742 &personal_data_manager); |
| 741 payments::AutofillPaymentInstrument* payment_instrument = | 743 AutofillPaymentInstrument* payment_instrument = |
| 742 static_cast<payments::AutofillPaymentInstrument*>( | 744 static_cast<AutofillPaymentInstrument*>( |
| 743 payment_request.selected_payment_method()); | 745 payment_request.selected_payment_method()); |
| 744 EXPECT_EQ(nullptr, payment_request.selected_shipping_profile()); | 746 EXPECT_EQ(nullptr, payment_request.selected_shipping_profile()); |
| 745 EXPECT_EQ(nullptr, payment_request.selected_contact_profile()); | 747 EXPECT_EQ(nullptr, payment_request.selected_contact_profile()); |
| 746 EXPECT_EQ(credit_card.guid(), payment_instrument->credit_card()->guid()); | 748 EXPECT_EQ(credit_card.guid(), payment_instrument->credit_card()->guid()); |
| 747 | 749 |
| 748 EXPECT_CALL(personal_data_manager, RecordUseOf(GuidMatches(address.guid()))) | 750 EXPECT_CALL(personal_data_manager, RecordUseOf(GuidMatches(address.guid()))) |
| 749 .Times(0); | 751 .Times(0); |
| 750 EXPECT_CALL(personal_data_manager, | 752 EXPECT_CALL(personal_data_manager, |
| 751 RecordUseOf(GuidMatches(credit_card.guid()))) | 753 RecordUseOf(GuidMatches(credit_card.guid()))) |
| 752 .Times(1); | 754 .Times(1); |
| 753 | 755 |
| 754 payment_request.RecordUseStats(); | 756 payment_request.RecordUseStats(); |
| 755 } | 757 } |
| 758 |
| 759 } // namespace payments |
| OLD | NEW |