Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1055)

Side by Side Diff: ios/chrome/browser/ui/payments/billing_address_selection_mediator_unittest.mm

Issue 2965073002: [Payment Request] Moves PaymentRequest into the payments namespace (Closed)
Patch Set: rebase Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 PaymentRequestBillingAddressSelectionMediatorTest() 44 PaymentRequestBillingAddressSelectionMediatorTest()
45 : autofill_profile_1_(autofill::test::GetFullProfile()), 45 : autofill_profile_1_(autofill::test::GetFullProfile()),
46 autofill_profile_2_(autofill::test::GetFullProfile2()), 46 autofill_profile_2_(autofill::test::GetFullProfile2()),
47 autofill_profile_3_(autofill::test::GetIncompleteProfile1()), 47 autofill_profile_3_(autofill::test::GetIncompleteProfile1()),
48 autofill_profile_4_(autofill::test::GetIncompleteProfile2()) { 48 autofill_profile_4_(autofill::test::GetIncompleteProfile2()) {
49 // Add testing profiles to autofill::TestPersonalDataManager. 49 // Add testing profiles to autofill::TestPersonalDataManager.
50 personal_data_manager_.AddTestingProfile(&autofill_profile_1_); 50 personal_data_manager_.AddTestingProfile(&autofill_profile_1_);
51 personal_data_manager_.AddTestingProfile(&autofill_profile_2_); 51 personal_data_manager_.AddTestingProfile(&autofill_profile_2_);
52 personal_data_manager_.AddTestingProfile(&autofill_profile_3_); 52 personal_data_manager_.AddTestingProfile(&autofill_profile_3_);
53 personal_data_manager_.AddTestingProfile(&autofill_profile_4_); 53 personal_data_manager_.AddTestingProfile(&autofill_profile_4_);
54 payment_request_ = base::MakeUnique<TestPaymentRequest>( 54 payment_request_ = base::MakeUnique<payments::TestPaymentRequest>(
55 payment_request_test_util::CreateTestWebPaymentRequest(), 55 payment_request_test_util::CreateTestWebPaymentRequest(),
56 &personal_data_manager_); 56 &personal_data_manager_);
57 profile_comparator_ = base::MakeUnique<FakePaymentsProfileComparator>( 57 profile_comparator_ = base::MakeUnique<FakePaymentsProfileComparator>(
58 GetApplicationContext()->GetApplicationLocale(), 58 GetApplicationContext()->GetApplicationLocale(),
59 *payment_request_.get()); 59 *payment_request_.get());
60 payment_request_->SetProfileComparator(profile_comparator_.get()); 60 payment_request_->SetProfileComparator(profile_comparator_.get());
61 } 61 }
62 62
63 void SetUp() override { 63 void SetUp() override {
64 mediator_ = [[BillingAddressSelectionMediator alloc] 64 mediator_ = [[BillingAddressSelectionMediator alloc]
65 initWithPaymentRequest:payment_request_.get() 65 initWithPaymentRequest:payment_request_.get()
66 selectedBillingProfile:payment_request_->billing_profiles()[1]]; 66 selectedBillingProfile:payment_request_->billing_profiles()[1]];
67 } 67 }
68 68
69 BillingAddressSelectionMediator* GetMediator() { return mediator_; } 69 BillingAddressSelectionMediator* GetMediator() { return mediator_; }
70 70
71 base::test::ScopedTaskEnvironment scoped_task_evironment_; 71 base::test::ScopedTaskEnvironment scoped_task_evironment_;
72 72
73 BillingAddressSelectionMediator* mediator_; 73 BillingAddressSelectionMediator* mediator_;
74 74
75 autofill::AutofillProfile autofill_profile_1_; 75 autofill::AutofillProfile autofill_profile_1_;
76 autofill::AutofillProfile autofill_profile_2_; 76 autofill::AutofillProfile autofill_profile_2_;
77 autofill::AutofillProfile autofill_profile_3_; 77 autofill::AutofillProfile autofill_profile_3_;
78 autofill::AutofillProfile autofill_profile_4_; 78 autofill::AutofillProfile autofill_profile_4_;
79 autofill::TestPersonalDataManager personal_data_manager_; 79 autofill::TestPersonalDataManager personal_data_manager_;
80 std::unique_ptr<TestPaymentRequest> payment_request_; 80 std::unique_ptr<payments::TestPaymentRequest> payment_request_;
81 std::unique_ptr<FakePaymentsProfileComparator> profile_comparator_; 81 std::unique_ptr<FakePaymentsProfileComparator> profile_comparator_;
82 }; 82 };
83 83
84 // Tests that the expected selectable items are created and that the index of 84 // Tests that the expected selectable items are created and that the index of
85 // the selected item is properly set. 85 // the selected item is properly set.
86 TEST_F(PaymentRequestBillingAddressSelectionMediatorTest, TestSelectableItems) { 86 TEST_F(PaymentRequestBillingAddressSelectionMediatorTest, TestSelectableItems) {
87 NSArray<CollectionViewItem*>* selectable_items = 87 NSArray<CollectionViewItem*>* selectable_items =
88 [GetMediator() selectableItems]; 88 [GetMediator() selectableItems];
89 89
90 ASSERT_EQ(4U, selectable_items.count); 90 ASSERT_EQ(4U, selectable_items.count);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 selectedBillingProfile:nil]; 171 selectedBillingProfile:nil];
172 172
173 NSArray<CollectionViewItem*>* selectable_items = 173 NSArray<CollectionViewItem*>* selectable_items =
174 [GetMediator() selectableItems]; 174 [GetMediator() selectableItems];
175 175
176 ASSERT_EQ(4U, selectable_items.count); 176 ASSERT_EQ(4U, selectable_items.count);
177 177
178 // The selected item index must be invalid. 178 // The selected item index must be invalid.
179 EXPECT_EQ(NSUIntegerMax, GetMediator().selectedItemIndex); 179 EXPECT_EQ(NSUIntegerMax, GetMediator().selectedItemIndex);
180 } 180 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698