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