| 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 "components/autofill/core/browser/test_personal_data_manager.h" | 8 #include "components/autofill/core/browser/test_personal_data_manager.h" |
| 9 #include "components/payments/currency_formatter.h" | 9 #include "components/payments/currency_formatter.h" |
| 10 #include "ios/chrome/browser/application_context.h" | 10 #include "ios/chrome/browser/application_context.h" |
| 11 #include "ios/web/public/payments/payment_request.h" | 11 #include "ios/web/public/payments/payment_request.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 15 #error "This file requires ARC support." |
| 16 #endif |
| 17 |
| 14 // Tests that the payments::CurrencyFormatter is constructed with the correct | 18 // Tests that the payments::CurrencyFormatter is constructed with the correct |
| 15 // currency code and currency system. | 19 // currency code and currency system. |
| 16 TEST(PaymentRequestTest, CreatesCurrencyFormatterCorrectly) { | 20 TEST(PaymentRequestTest, CreatesCurrencyFormatterCorrectly) { |
| 17 ASSERT_EQ("en", GetApplicationContext()->GetApplicationLocale()); | 21 ASSERT_EQ("en", GetApplicationContext()->GetApplicationLocale()); |
| 18 | 22 |
| 19 autofill::TestPersonalDataManager personal_data_manager; | 23 autofill::TestPersonalDataManager personal_data_manager; |
| 20 | 24 |
| 21 std::unique_ptr<web::PaymentRequest> web_payment_request = | 25 std::unique_ptr<web::PaymentRequest> web_payment_request = |
| 22 base::MakeUnique<web::PaymentRequest>(); | 26 base::MakeUnique<web::PaymentRequest>(); |
| 23 web_payment_request->details.total.amount.currency = | 27 web_payment_request->details.total.amount.currency = |
| (...skipping 18 matching lines...) Expand all Loading... |
| 42 web_payment_request->details.total.amount.currency_system = | 46 web_payment_request->details.total.amount.currency_system = |
| 43 base::ASCIIToUTF16("NOT_ISO4217"); | 47 base::ASCIIToUTF16("NOT_ISO4217"); |
| 44 web_payment_request->details.total.amount.currency = | 48 web_payment_request->details.total.amount.currency = |
| 45 base::ASCIIToUTF16("USD"); | 49 base::ASCIIToUTF16("USD"); |
| 46 PaymentRequest payment_request3(std::move(web_payment_request), | 50 PaymentRequest payment_request3(std::move(web_payment_request), |
| 47 &personal_data_manager); | 51 &personal_data_manager); |
| 48 currency_formatter = payment_request3.GetOrCreateCurrencyFormatter(); | 52 currency_formatter = payment_request3.GetOrCreateCurrencyFormatter(); |
| 49 ASSERT_EQ(base::UTF8ToUTF16("55.00"), currency_formatter->Format("55.00")); | 53 ASSERT_EQ(base::UTF8ToUTF16("55.00"), currency_formatter->Format("55.00")); |
| 50 ASSERT_EQ("USD", currency_formatter->formatted_currency_code()); | 54 ASSERT_EQ("USD", currency_formatter->formatted_currency_code()); |
| 51 } | 55 } |
| OLD | NEW |