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

Side by Side Diff: components/payments/core/payment_request_data_util_unittest.cc

Issue 2842463002: [Payments] Normalize billing address for response on Desktop. (Closed)
Patch Set: Addressed moe's comments Created 3 years, 8 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 unified diff | Download patch
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « components/payments/core/payment_request_data_util.cc ('k') | ios/chrome/browser/ui/payments/payment_request_coordinator.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698