| 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/payments/payment_method_selection_view_controller.h" | 5 #import "ios/chrome/browser/payments/payment_method_selection_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 "components/autofill/core/browser/autofill_test_utils.h" | 9 #include "components/autofill/core/browser/autofill_test_utils.h" |
| 10 #include "components/autofill/core/browser/credit_card.h" | 10 #include "components/autofill/core/browser/credit_card.h" |
| 11 #include "components/autofill/core/browser/test_personal_data_manager.h" | 11 #include "components/autofill/core/browser/test_personal_data_manager.h" |
| 12 #include "components/strings/grit/components_strings.h" |
| 12 #import "ios/chrome/browser/payments/cells/payment_method_item.h" | 13 #import "ios/chrome/browser/payments/cells/payment_method_item.h" |
| 13 #import "ios/chrome/browser/payments/cells/payments_text_item.h" | 14 #import "ios/chrome/browser/payments/cells/payments_text_item.h" |
| 14 #include "ios/chrome/browser/payments/payment_request.h" | 15 #include "ios/chrome/browser/payments/payment_request.h" |
| 15 #import "ios/chrome/browser/payments/payment_request_test_util.h" | 16 #import "ios/chrome/browser/payments/payment_request_test_util.h" |
| 16 #import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h
" | 17 #import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h
" |
| 17 #include "ios/chrome/grit/ios_strings.h" | 18 #include "ios/chrome/grit/ios_strings.h" |
| 18 #include "ios/web/public/payments/payment_request.h" | 19 #include "ios/web/public/payments/payment_request.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 21 |
| 21 #if !defined(__has_feature) || !__has_feature(objc_arc) | 22 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 std::unique_ptr<autofill::CreditCard> credit_card2_; | 57 std::unique_ptr<autofill::CreditCard> credit_card2_; |
| 57 std::unique_ptr<autofill::TestPersonalDataManager> personal_data_manager_; | 58 std::unique_ptr<autofill::TestPersonalDataManager> personal_data_manager_; |
| 58 std::unique_ptr<PaymentRequest> payment_request_; | 59 std::unique_ptr<PaymentRequest> payment_request_; |
| 59 }; | 60 }; |
| 60 | 61 |
| 61 // Tests that the correct number of items are displayed after loading the model | 62 // Tests that the correct number of items are displayed after loading the model |
| 62 // and that the correct item appears to be selected. | 63 // and that the correct item appears to be selected. |
| 63 TEST_F(PaymentMethodSelectionViewControllerTest, TestModel) { | 64 TEST_F(PaymentMethodSelectionViewControllerTest, TestModel) { |
| 64 CreateController(); | 65 CreateController(); |
| 65 CheckController(); | 66 CheckController(); |
| 66 CheckTitleWithId(IDS_IOS_PAYMENT_REQUEST_METHOD_SELECTION_TITLE); | 67 CheckTitleWithId(IDS_PAYMENTS_METHOD_OF_PAYMENT_LABEL); |
| 67 | 68 |
| 68 [GetPaymentMethodSelectionViewController() loadModel]; | 69 [GetPaymentMethodSelectionViewController() loadModel]; |
| 69 | 70 |
| 70 ASSERT_EQ(1, NumberOfSections()); | 71 ASSERT_EQ(1, NumberOfSections()); |
| 71 // One item for each of payment method plus 1 for the add button. | 72 // One item for each of payment method plus 1 for the add button. |
| 72 ASSERT_EQ(3U, static_cast<unsigned int>(NumberOfItemsInSection(0))); | 73 ASSERT_EQ(3U, static_cast<unsigned int>(NumberOfItemsInSection(0))); |
| 73 | 74 |
| 74 // The first two items should be of type PaymentMethodItem. The first one | 75 // The first two items should be of type PaymentMethodItem. The first one |
| 75 // should appear to be selected. | 76 // should appear to be selected. |
| 76 id item = GetCollectionViewItem(0, 0); | 77 id item = GetCollectionViewItem(0, 0); |
| 77 EXPECT_TRUE([item isMemberOfClass:[PaymentMethodItem class]]); | 78 EXPECT_TRUE([item isMemberOfClass:[PaymentMethodItem class]]); |
| 78 PaymentMethodItem* payment_method_item = item; | 79 PaymentMethodItem* payment_method_item = item; |
| 79 EXPECT_EQ(MDCCollectionViewCellAccessoryCheckmark, | 80 EXPECT_EQ(MDCCollectionViewCellAccessoryCheckmark, |
| 80 payment_method_item.accessoryType); | 81 payment_method_item.accessoryType); |
| 81 | 82 |
| 82 item = GetCollectionViewItem(0, 1); | 83 item = GetCollectionViewItem(0, 1); |
| 83 EXPECT_TRUE([item isMemberOfClass:[PaymentMethodItem class]]); | 84 EXPECT_TRUE([item isMemberOfClass:[PaymentMethodItem class]]); |
| 84 payment_method_item = item; | 85 payment_method_item = item; |
| 85 EXPECT_EQ(MDCCollectionViewCellAccessoryNone, | 86 EXPECT_EQ(MDCCollectionViewCellAccessoryNone, |
| 86 payment_method_item.accessoryType); | 87 payment_method_item.accessoryType); |
| 87 | 88 |
| 88 // The last item should be of type TextAndMessageItem. | 89 // The last item should be of type TextAndMessageItem. |
| 89 item = GetCollectionViewItem(0, 2); | 90 item = GetCollectionViewItem(0, 2); |
| 90 EXPECT_TRUE([item isMemberOfClass:[PaymentsTextItem class]]); | 91 EXPECT_TRUE([item isMemberOfClass:[PaymentsTextItem class]]); |
| 91 } | 92 } |
| OLD | NEW |