| 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/contact_info_selection_mediator.h" | 5 #import "ios/chrome/browser/ui/payments/contact_info_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" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 } // namespace | 29 } // namespace |
| 30 | 30 |
| 31 class PaymentRequestContactInfoSelectionMediatorTest : public PlatformTest { | 31 class PaymentRequestContactInfoSelectionMediatorTest : public PlatformTest { |
| 32 protected: | 32 protected: |
| 33 PaymentRequestContactInfoSelectionMediatorTest() | 33 PaymentRequestContactInfoSelectionMediatorTest() |
| 34 : autofill_profile_1_(autofill::test::GetFullProfile()), | 34 : autofill_profile_1_(autofill::test::GetFullProfile()), |
| 35 autofill_profile_2_(autofill::test::GetFullProfile2()) { | 35 autofill_profile_2_(autofill::test::GetFullProfile2()) { |
| 36 // Add testing profiles to autofill::TestPersonalDataManager. | 36 // Add testing profiles to autofill::TestPersonalDataManager. |
| 37 personal_data_manager_.AddTestingProfile(&autofill_profile_1_); | 37 personal_data_manager_.AddTestingProfile(&autofill_profile_1_); |
| 38 personal_data_manager_.AddTestingProfile(&autofill_profile_2_); | 38 personal_data_manager_.AddTestingProfile(&autofill_profile_2_); |
| 39 payment_request_ = base::MakeUnique<TestPaymentRequest>( | 39 payment_request_ = base::MakeUnique<payments::TestPaymentRequest>( |
| 40 payment_request_test_util::CreateTestWebPaymentRequest(), | 40 payment_request_test_util::CreateTestWebPaymentRequest(), |
| 41 &personal_data_manager_); | 41 &personal_data_manager_); |
| 42 // Override the selected contact profile. | 42 // Override the selected contact profile. |
| 43 payment_request_->set_selected_contact_profile( | 43 payment_request_->set_selected_contact_profile( |
| 44 payment_request_->contact_profiles()[1]); | 44 payment_request_->contact_profiles()[1]); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void SetUp() override { | 47 void SetUp() override { |
| 48 mediator_ = [[ContactInfoSelectionMediator alloc] | 48 mediator_ = [[ContactInfoSelectionMediator alloc] |
| 49 initWithPaymentRequest:payment_request_.get()]; | 49 initWithPaymentRequest:payment_request_.get()]; |
| 50 } | 50 } |
| 51 | 51 |
| 52 ContactInfoSelectionMediator* GetMediator() { return mediator_; } | 52 ContactInfoSelectionMediator* GetMediator() { return mediator_; } |
| 53 | 53 |
| 54 base::test::ScopedTaskEnvironment scoped_task_evironment_; | 54 base::test::ScopedTaskEnvironment scoped_task_evironment_; |
| 55 | 55 |
| 56 ContactInfoSelectionMediator* mediator_; | 56 ContactInfoSelectionMediator* mediator_; |
| 57 | 57 |
| 58 autofill::AutofillProfile autofill_profile_1_; | 58 autofill::AutofillProfile autofill_profile_1_; |
| 59 autofill::AutofillProfile autofill_profile_2_; | 59 autofill::AutofillProfile autofill_profile_2_; |
| 60 autofill::TestPersonalDataManager personal_data_manager_; | 60 autofill::TestPersonalDataManager personal_data_manager_; |
| 61 std::unique_ptr<TestPaymentRequest> payment_request_; | 61 std::unique_ptr<payments::TestPaymentRequest> payment_request_; |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 // Tests that the expected selectable items are created and that the index of | 64 // Tests that the expected selectable items are created and that the index of |
| 65 // the selected item is properly set. | 65 // the selected item is properly set. |
| 66 TEST_F(PaymentRequestContactInfoSelectionMediatorTest, TestSelectableItems) { | 66 TEST_F(PaymentRequestContactInfoSelectionMediatorTest, TestSelectableItems) { |
| 67 NSArray<CollectionViewItem*>* selectable_items = | 67 NSArray<CollectionViewItem*>* selectable_items = |
| 68 [GetMediator() selectableItems]; | 68 [GetMediator() selectableItems]; |
| 69 | 69 |
| 70 // There must be two selectable items. | 70 // There must be two selectable items. |
| 71 ASSERT_EQ(2U, selectable_items.count); | 71 ASSERT_EQ(2U, selectable_items.count); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 168 |
| 169 item = [selectable_items objectAtIndex:0]; | 169 item = [selectable_items objectAtIndex:0]; |
| 170 DCHECK([item isKindOfClass:[AutofillProfileItem class]]); | 170 DCHECK([item isKindOfClass:[AutofillProfileItem class]]); |
| 171 profile_item = base::mac::ObjCCastStrict<AutofillProfileItem>(item); | 171 profile_item = base::mac::ObjCCastStrict<AutofillProfileItem>(item); |
| 172 EXPECT_NE(nil, profile_item.name); | 172 EXPECT_NE(nil, profile_item.name); |
| 173 EXPECT_NE(nil, profile_item.email); | 173 EXPECT_NE(nil, profile_item.email); |
| 174 EXPECT_EQ(nil, profile_item.phoneNumber); | 174 EXPECT_EQ(nil, profile_item.phoneNumber); |
| 175 EXPECT_EQ(nil, profile_item.address); | 175 EXPECT_EQ(nil, profile_item.address); |
| 176 EXPECT_EQ(nil, profile_item.notification); | 176 EXPECT_EQ(nil, profile_item.notification); |
| 177 } | 177 } |
| OLD | NEW |