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 "components/payments/core/payment_request_data_util.h" | 5 #include "components/payments/core/payment_request_data_util.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 } | 42 } |
43 | 43 |
44 // Tests that the basic card response constructed from a credit card with | 44 // Tests that the basic card response constructed from a credit card with |
45 // associated billing address has the right structure once serialized. | 45 // associated billing address has the right structure once serialized. |
46 TEST(PaymentRequestDataUtilTest, GetBasicCardResponseFromAutofillCreditCard) { | 46 TEST(PaymentRequestDataUtilTest, GetBasicCardResponseFromAutofillCreditCard) { |
47 autofill::AutofillProfile address = autofill::test::GetFullProfile(); | 47 autofill::AutofillProfile address = autofill::test::GetFullProfile(); |
48 autofill::CreditCard card = autofill::test::GetCreditCard(); | 48 autofill::CreditCard card = autofill::test::GetCreditCard(); |
49 card.set_billing_address_id(address.guid()); | 49 card.set_billing_address_id(address.guid()); |
50 std::unique_ptr<base::DictionaryValue> response_value = | 50 std::unique_ptr<base::DictionaryValue> response_value = |
51 payments::data_util::GetBasicCardResponseFromAutofillCreditCard( | 51 payments::data_util::GetBasicCardResponseFromAutofillCreditCard( |
52 card, base::ASCIIToUTF16("123"), | 52 card, base::ASCIIToUTF16("123"), address, "en-US") |
53 std::vector<autofill::AutofillProfile*>{&address}, "en-US") | |
54 .ToDictionaryValue(); | 53 .ToDictionaryValue(); |
55 std::string json_response; | 54 std::string json_response; |
56 base::JSONWriter::Write(*response_value, &json_response); | 55 base::JSONWriter::Write(*response_value, &json_response); |
57 EXPECT_EQ( | 56 EXPECT_EQ( |
58 "{\"billingAddress\":" | 57 "{\"billingAddress\":" |
59 "{\"addressLine\":[\"666 Erebus St.\",\"Apt 8\"]," | 58 "{\"addressLine\":[\"666 Erebus St.\",\"Apt 8\"]," |
60 "\"city\":\"Elysium\"," | 59 "\"city\":\"Elysium\"," |
61 "\"country\":\"US\"," | 60 "\"country\":\"US\"," |
62 "\"organization\":\"Underworld\"," | 61 "\"organization\":\"Underworld\"," |
63 "\"phone\":\"16502111111\"," | 62 "\"phone\":\"16502111111\"," |
(...skipping 22 matching lines...) Expand all Loading... |
86 // Tests that the phone numbers are correctly formatted to display to the user. | 85 // Tests that the phone numbers are correctly formatted to display to the user. |
87 TEST(PaymentRequestDataUtilTest, FormatPhoneForDisplay) { | 86 TEST(PaymentRequestDataUtilTest, FormatPhoneForDisplay) { |
88 EXPECT_EQ("+1 515-123-1234", | 87 EXPECT_EQ("+1 515-123-1234", |
89 payments::data_util::FormatPhoneForDisplay("5151231234", "US")); | 88 payments::data_util::FormatPhoneForDisplay("5151231234", "US")); |
90 EXPECT_EQ("+33 1 42 68 53 00", | 89 EXPECT_EQ("+33 1 42 68 53 00", |
91 payments::data_util::FormatPhoneForDisplay("142685300", "FR")); | 90 payments::data_util::FormatPhoneForDisplay("142685300", "FR")); |
92 } | 91 } |
93 | 92 |
94 } // namespace data_util | 93 } // namespace data_util |
95 } // namespace payments | 94 } // namespace payments |
OLD | NEW |