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/billing_address_selection_mediator.h" | 5 #import "ios/chrome/browser/ui/payments/billing_address_selection_mediator.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/test/scoped_task_environment.h" | 9 #include "base/test/scoped_task_environment.h" |
10 #include "components/autofill/core/browser/autofill_profile.h" | 10 #include "components/autofill/core/browser/autofill_profile.h" |
11 #include "components/autofill/core/browser/autofill_test_utils.h" | 11 #include "components/autofill/core/browser/autofill_test_utils.h" |
12 #include "components/autofill/core/browser/test_personal_data_manager.h" | 12 #include "components/autofill/core/browser/test_personal_data_manager.h" |
13 #include "components/payments/core/payments_profile_comparator.h" | 13 #include "components/payments/core/payments_profile_comparator.h" |
14 #include "ios/chrome/browser/application_context.h" | |
15 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" | 14 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.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/payments/payment_request_util.h" | 16 #import "ios/chrome/browser/payments/payment_request_util.h" |
18 #include "ios/chrome/browser/payments/test_payment_request.h" | 17 #include "ios/chrome/browser/payments/test_payment_request.h" |
19 #import "ios/chrome/browser/ui/payments/cells/autofill_profile_item.h" | 18 #import "ios/chrome/browser/ui/payments/cells/autofill_profile_item.h" |
20 #import "ios/web/public/test/fakes/test_web_state.h" | 19 #import "ios/web/public/test/fakes/test_web_state.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
22 #include "testing/platform_test.h" | 21 #include "testing/platform_test.h" |
23 #include "third_party/ocmock/gtest_support.h" | 22 #include "third_party/ocmock/gtest_support.h" |
24 | 23 |
(...skipping 27 matching lines...) Expand all Loading... |
52 // Add testing profiles to autofill::TestPersonalDataManager. | 51 // Add testing profiles to autofill::TestPersonalDataManager. |
53 personal_data_manager_.AddTestingProfile(&autofill_profile_1_); | 52 personal_data_manager_.AddTestingProfile(&autofill_profile_1_); |
54 personal_data_manager_.AddTestingProfile(&autofill_profile_2_); | 53 personal_data_manager_.AddTestingProfile(&autofill_profile_2_); |
55 personal_data_manager_.AddTestingProfile(&autofill_profile_3_); | 54 personal_data_manager_.AddTestingProfile(&autofill_profile_3_); |
56 personal_data_manager_.AddTestingProfile(&autofill_profile_4_); | 55 personal_data_manager_.AddTestingProfile(&autofill_profile_4_); |
57 | 56 |
58 payment_request_ = base::MakeUnique<payments::TestPaymentRequest>( | 57 payment_request_ = base::MakeUnique<payments::TestPaymentRequest>( |
59 payment_request_test_util::CreateTestWebPaymentRequest(), | 58 payment_request_test_util::CreateTestWebPaymentRequest(), |
60 chrome_browser_state_.get(), &web_state_, &personal_data_manager_); | 59 chrome_browser_state_.get(), &web_state_, &personal_data_manager_); |
61 profile_comparator_ = base::MakeUnique<FakePaymentsProfileComparator>( | 60 profile_comparator_ = base::MakeUnique<FakePaymentsProfileComparator>( |
62 GetApplicationContext()->GetApplicationLocale(), | 61 payment_request_->GetApplicationLocale(), *payment_request_.get()); |
63 *payment_request_.get()); | |
64 payment_request_->SetProfileComparator(profile_comparator_.get()); | 62 payment_request_->SetProfileComparator(profile_comparator_.get()); |
65 } | 63 } |
66 | 64 |
67 void SetUp() override { | 65 void SetUp() override { |
68 mediator_ = [[BillingAddressSelectionMediator alloc] | 66 mediator_ = [[BillingAddressSelectionMediator alloc] |
69 initWithPaymentRequest:payment_request_.get() | 67 initWithPaymentRequest:payment_request_.get() |
70 selectedBillingProfile:payment_request_->billing_profiles()[1]]; | 68 selectedBillingProfile:payment_request_->billing_profiles()[1]]; |
71 } | 69 } |
72 | 70 |
73 BillingAddressSelectionMediator* GetMediator() { return mediator_; } | 71 BillingAddressSelectionMediator* GetMediator() { return mediator_; } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 selectedBillingProfile:nil]; | 175 selectedBillingProfile:nil]; |
178 | 176 |
179 NSArray<CollectionViewItem*>* selectable_items = | 177 NSArray<CollectionViewItem*>* selectable_items = |
180 [GetMediator() selectableItems]; | 178 [GetMediator() selectableItems]; |
181 | 179 |
182 ASSERT_EQ(4U, selectable_items.count); | 180 ASSERT_EQ(4U, selectable_items.count); |
183 | 181 |
184 // The selected item index must be invalid. | 182 // The selected item index must be invalid. |
185 EXPECT_EQ(NSUIntegerMax, GetMediator().selectedItemIndex); | 183 EXPECT_EQ(NSUIntegerMax, GetMediator().selectedItemIndex); |
186 } | 184 } |
OLD | NEW |