| 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 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
| 8 | 8 |
| 9 #include "base/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 139 |
| 140 class PaymentRequestViewControllerTest : public CollectionViewControllerTest { | 140 class PaymentRequestViewControllerTest : public CollectionViewControllerTest { |
| 141 protected: | 141 protected: |
| 142 PaymentRequestViewControllerTest() | 142 PaymentRequestViewControllerTest() |
| 143 : autofill_profile_(autofill::test::GetFullProfile()), | 143 : autofill_profile_(autofill::test::GetFullProfile()), |
| 144 credit_card_(autofill::test::GetCreditCard()) { | 144 credit_card_(autofill::test::GetCreditCard()) { |
| 145 // Add testing profile and credit card to autofill::TestPersonalDataManager. | 145 // Add testing profile and credit card to autofill::TestPersonalDataManager. |
| 146 personal_data_manager_.AddTestingProfile(&autofill_profile_); | 146 personal_data_manager_.AddTestingProfile(&autofill_profile_); |
| 147 personal_data_manager_.AddTestingCreditCard(&credit_card_); | 147 personal_data_manager_.AddTestingCreditCard(&credit_card_); |
| 148 | 148 |
| 149 payment_request_ = base::MakeUnique<TestPaymentRequest>( | 149 payment_request_ = base::MakeUnique<payments::TestPaymentRequest>( |
| 150 payment_request_test_util::CreateTestWebPaymentRequest(), | 150 payment_request_test_util::CreateTestWebPaymentRequest(), |
| 151 &personal_data_manager_); | 151 &personal_data_manager_); |
| 152 | 152 |
| 153 mediator_ = [[TestPaymentRequestMediator alloc] init]; | 153 mediator_ = [[TestPaymentRequestMediator alloc] init]; |
| 154 } | 154 } |
| 155 | 155 |
| 156 CollectionViewController* InstantiateController() override { | 156 CollectionViewController* InstantiateController() override { |
| 157 PaymentRequestViewController* viewController = | 157 PaymentRequestViewController* viewController = |
| 158 [[PaymentRequestViewController alloc] init]; | 158 [[PaymentRequestViewController alloc] init]; |
| 159 [viewController setDataSource:mediator_]; | 159 [viewController setDataSource:mediator_]; |
| 160 return viewController; | 160 return viewController; |
| 161 } | 161 } |
| 162 | 162 |
| 163 PaymentRequestViewController* GetPaymentRequestViewController() { | 163 PaymentRequestViewController* GetPaymentRequestViewController() { |
| 164 return base::mac::ObjCCastStrict<PaymentRequestViewController>( | 164 return base::mac::ObjCCastStrict<PaymentRequestViewController>( |
| 165 controller()); | 165 controller()); |
| 166 } | 166 } |
| 167 | 167 |
| 168 base::test::ScopedTaskEnvironment scoped_task_evironment_; | 168 base::test::ScopedTaskEnvironment scoped_task_evironment_; |
| 169 | 169 |
| 170 autofill::AutofillProfile autofill_profile_; | 170 autofill::AutofillProfile autofill_profile_; |
| 171 autofill::CreditCard credit_card_; | 171 autofill::CreditCard credit_card_; |
| 172 autofill::TestPersonalDataManager personal_data_manager_; | 172 autofill::TestPersonalDataManager personal_data_manager_; |
| 173 std::unique_ptr<TestPaymentRequest> payment_request_; | 173 std::unique_ptr<payments::TestPaymentRequest> payment_request_; |
| 174 TestPaymentRequestMediator* mediator_; | 174 TestPaymentRequestMediator* mediator_; |
| 175 }; | 175 }; |
| 176 | 176 |
| 177 // Tests that the correct items are displayed after loading the model. | 177 // Tests that the correct items are displayed after loading the model. |
| 178 TEST_F(PaymentRequestViewControllerTest, TestModel) { | 178 TEST_F(PaymentRequestViewControllerTest, TestModel) { |
| 179 CreateController(); | 179 CreateController(); |
| 180 CheckController(); | 180 CheckController(); |
| 181 CheckTitleWithId(IDS_PAYMENTS_TITLE); | 181 CheckTitleWithId(IDS_PAYMENTS_TITLE); |
| 182 | 182 |
| 183 [GetPaymentRequestViewController() loadModel]; | 183 [GetPaymentRequestViewController() loadModel]; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 ASSERT_EQ(2U, static_cast<unsigned int>(NumberOfItemsInSection(0))); | 342 ASSERT_EQ(2U, static_cast<unsigned int>(NumberOfItemsInSection(0))); |
| 343 | 343 |
| 344 // The first item should be of type PageInfoItem. | 344 // The first item should be of type PageInfoItem. |
| 345 id item = GetCollectionViewItem(0, 0); | 345 id item = GetCollectionViewItem(0, 0); |
| 346 EXPECT_TRUE([item isMemberOfClass:[PageInfoItem class]]); | 346 EXPECT_TRUE([item isMemberOfClass:[PageInfoItem class]]); |
| 347 | 347 |
| 348 // The second item should be of type StatusItem. | 348 // The second item should be of type StatusItem. |
| 349 item = GetCollectionViewItem(0, 1); | 349 item = GetCollectionViewItem(0, 1); |
| 350 EXPECT_TRUE([item isMemberOfClass:[StatusItem class]]); | 350 EXPECT_TRUE([item isMemberOfClass:[StatusItem class]]); |
| 351 } | 351 } |
| OLD | NEW |