| 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 #import "ios/chrome/browser/ui/payments/payment_request_view_controller.h" | 5 #import "ios/chrome/browser/ui/payments/payment_request_view_controller.h" |
| 6 | 6 |
| 7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | |
| 10 #include "components/autofill/core/browser/autofill_profile.h" | 9 #include "components/autofill/core/browser/autofill_profile.h" |
| 11 #include "components/autofill/core/browser/autofill_test_utils.h" | 10 #include "components/autofill/core/browser/autofill_test_utils.h" |
| 12 #include "components/autofill/core/browser/credit_card.h" | 11 #include "components/autofill/core/browser/credit_card.h" |
| 13 #include "components/autofill/core/browser/test_personal_data_manager.h" | 12 #include "components/autofill/core/browser/test_personal_data_manager.h" |
| 14 #include "components/strings/grit/components_strings.h" | 13 #include "components/strings/grit/components_strings.h" |
| 15 #include "ios/chrome/browser/payments/payment_request.h" | 14 #include "ios/chrome/browser/payments/payment_request.h" |
| 16 #include "ios/chrome/browser/payments/payment_request_test_util.h" | 15 #include "ios/chrome/browser/payments/payment_request_test_util.h" |
| 17 #import "ios/chrome/browser/ui/autofill/cells/status_item.h" | 16 #import "ios/chrome/browser/ui/autofill/cells/status_item.h" |
| 18 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_detail_item
.h" | 17 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_detail_item
.h" |
| 19 #import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h
" | 18 #import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h
" |
| 20 #import "ios/chrome/browser/ui/payments/cells/autofill_profile_item.h" | 19 #import "ios/chrome/browser/ui/payments/cells/autofill_profile_item.h" |
| 21 #import "ios/chrome/browser/ui/payments/cells/page_info_item.h" | 20 #import "ios/chrome/browser/ui/payments/cells/page_info_item.h" |
| 22 #import "ios/chrome/browser/ui/payments/cells/payment_method_item.h" | 21 #import "ios/chrome/browser/ui/payments/cells/payment_method_item.h" |
| 23 #import "ios/chrome/browser/ui/payments/cells/payments_text_item.h" | 22 #import "ios/chrome/browser/ui/payments/cells/payments_text_item.h" |
| 24 #import "ios/chrome/browser/ui/payments/cells/price_item.h" | 23 #import "ios/chrome/browser/ui/payments/cells/price_item.h" |
| 25 #include "ios/chrome/grit/ios_strings.h" | 24 #include "ios/chrome/grit/ios_strings.h" |
| 26 #include "ios/web/public/payments/payment_request.h" | 25 #include "ios/web/public/payments/payment_request.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 28 #include "ui/base/l10n/l10n_util.h" | |
| 29 | 27 |
| 30 #if !defined(__has_feature) || !__has_feature(objc_arc) | 28 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 31 #error "This file requires ARC support." | 29 #error "This file requires ARC support." |
| 32 #endif | 30 #endif |
| 33 | 31 |
| 34 class PaymentRequestViewControllerTest : public CollectionViewControllerTest { | 32 class PaymentRequestViewControllerTest : public CollectionViewControllerTest { |
| 35 protected: | 33 protected: |
| 36 PaymentRequestViewControllerTest() | 34 PaymentRequestViewControllerTest() |
| 37 : autofill_profile_(autofill::test::GetFullProfile()), | 35 : autofill_profile_(autofill::test::GetFullProfile()), |
| 38 credit_card_(autofill::test::GetCreditCard()) { | 36 credit_card_(autofill::test::GetCreditCard()) { |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 [GetPaymentRequestViewController() loadModel]; | 194 [GetPaymentRequestViewController() loadModel]; |
| 197 | 195 |
| 198 ASSERT_EQ(1, NumberOfSections()); | 196 ASSERT_EQ(1, NumberOfSections()); |
| 199 // There should be only one item. | 197 // There should be only one item. |
| 200 ASSERT_EQ(1U, static_cast<unsigned int>(NumberOfItemsInSection(0))); | 198 ASSERT_EQ(1U, static_cast<unsigned int>(NumberOfItemsInSection(0))); |
| 201 | 199 |
| 202 // The item should be of type StatusItem. | 200 // The item should be of type StatusItem. |
| 203 id item = GetCollectionViewItem(0, 0); | 201 id item = GetCollectionViewItem(0, 0); |
| 204 EXPECT_TRUE([item isMemberOfClass:[StatusItem class]]); | 202 EXPECT_TRUE([item isMemberOfClass:[StatusItem class]]); |
| 205 } | 203 } |
| 206 | |
| 207 TEST_F(PaymentRequestViewControllerTest, TestSignedInStringFormatting) { | |
| 208 const std::string unformattedString = l10n_util::GetStringUTF8( | |
| 209 IDS_PAYMENTS_CARD_AND_ADDRESS_SETTINGS_SIGNED_IN); | |
| 210 const std::string formattedString = l10n_util::GetStringFUTF8( | |
| 211 IDS_PAYMENTS_CARD_AND_ADDRESS_SETTINGS_SIGNED_IN, | |
| 212 base::ASCIIToUTF16("example@gmail.com")); | |
| 213 | |
| 214 EXPECT_NE(unformattedString, formattedString); | |
| 215 } | |
| OLD | NEW |