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

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

Issue 2970233002: [Payment Request] Adds a JourneyLogger instance to the PaymentRequest (Closed)
Patch Set: Initial 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/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"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/test/scoped_task_environment.h" 12 #include "base/test/scoped_task_environment.h"
13 #include "components/autofill/core/browser/autofill_profile.h" 13 #include "components/autofill/core/browser/autofill_profile.h"
14 #include "components/autofill/core/browser/autofill_test_utils.h" 14 #include "components/autofill/core/browser/autofill_test_utils.h"
15 #include "components/autofill/core/browser/credit_card.h" 15 #include "components/autofill/core/browser/credit_card.h"
16 #include "components/autofill/core/browser/test_personal_data_manager.h" 16 #include "components/autofill/core/browser/test_personal_data_manager.h"
17 #include "components/strings/grit/components_strings.h" 17 #include "components/strings/grit/components_strings.h"
18 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
18 #include "ios/chrome/browser/payments/payment_request_test_util.h" 19 #include "ios/chrome/browser/payments/payment_request_test_util.h"
19 #include "ios/chrome/browser/payments/test_payment_request.h" 20 #include "ios/chrome/browser/payments/test_payment_request.h"
20 #import "ios/chrome/browser/ui/autofill/cells/status_item.h" 21 #import "ios/chrome/browser/ui/autofill/cells/status_item.h"
21 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_detail_item .h" 22 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_detail_item .h"
22 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_footer_item .h" 23 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_footer_item .h"
23 #import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h " 24 #import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h "
24 #import "ios/chrome/browser/ui/payments/cells/autofill_profile_item.h" 25 #import "ios/chrome/browser/ui/payments/cells/autofill_profile_item.h"
25 #import "ios/chrome/browser/ui/payments/cells/page_info_item.h" 26 #import "ios/chrome/browser/ui/payments/cells/page_info_item.h"
26 #import "ios/chrome/browser/ui/payments/cells/payment_method_item.h" 27 #import "ios/chrome/browser/ui/payments/cells/payment_method_item.h"
27 #import "ios/chrome/browser/ui/payments/cells/payments_text_item.h" 28 #import "ios/chrome/browser/ui/payments/cells/payments_text_item.h"
28 #import "ios/chrome/browser/ui/payments/cells/price_item.h" 29 #import "ios/chrome/browser/ui/payments/cells/price_item.h"
29 #import "ios/chrome/browser/ui/payments/payment_request_view_controller_data_sou rce.h" 30 #import "ios/chrome/browser/ui/payments/payment_request_view_controller_data_sou rce.h"
30 #include "ios/chrome/grit/ios_strings.h" 31 #include "ios/chrome/grit/ios_strings.h"
31 #include "ios/web/public/payments/payment_request.h" 32 #include "ios/web/public/payments/payment_request.h"
33 #import "ios/web/public/test/fakes/test_web_state.h"
32 #include "testing/gtest/include/gtest/gtest.h" 34 #include "testing/gtest/include/gtest/gtest.h"
33 #include "ui/base/l10n/l10n_util.h" 35 #include "ui/base/l10n/l10n_util.h"
34 36
35 #if !defined(__has_feature) || !__has_feature(objc_arc) 37 #if !defined(__has_feature) || !__has_feature(objc_arc)
36 #error "This file requires ARC support." 38 #error "This file requires ARC support."
37 #endif 39 #endif
38 40
39 @interface TestPaymentRequestMediator 41 @interface TestPaymentRequestMediator
40 : NSObject<PaymentRequestViewControllerDataSource> 42 : NSObject<PaymentRequestViewControllerDataSource>
41 43
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 141
140 class PaymentRequestViewControllerTest : public CollectionViewControllerTest { 142 class PaymentRequestViewControllerTest : public CollectionViewControllerTest {
141 protected: 143 protected:
142 PaymentRequestViewControllerTest() 144 PaymentRequestViewControllerTest()
143 : autofill_profile_(autofill::test::GetFullProfile()), 145 : autofill_profile_(autofill::test::GetFullProfile()),
144 credit_card_(autofill::test::GetCreditCard()) { 146 credit_card_(autofill::test::GetCreditCard()) {
145 // Add testing profile and credit card to autofill::TestPersonalDataManager. 147 // Add testing profile and credit card to autofill::TestPersonalDataManager.
146 personal_data_manager_.AddTestingProfile(&autofill_profile_); 148 personal_data_manager_.AddTestingProfile(&autofill_profile_);
147 personal_data_manager_.AddTestingCreditCard(&credit_card_); 149 personal_data_manager_.AddTestingCreditCard(&credit_card_);
148 150
151 TestChromeBrowserState::Builder test_cbs_builder;
152 chrome_browser_state_ = test_cbs_builder.Build();
153
149 payment_request_ = base::MakeUnique<payments::TestPaymentRequest>( 154 payment_request_ = base::MakeUnique<payments::TestPaymentRequest>(
150 payment_request_test_util::CreateTestWebPaymentRequest(), 155 payment_request_test_util::CreateTestWebPaymentRequest(),
151 &personal_data_manager_); 156 chrome_browser_state_.get(), &web_state_, &personal_data_manager_);
152 157
153 mediator_ = [[TestPaymentRequestMediator alloc] init]; 158 mediator_ = [[TestPaymentRequestMediator alloc] init];
154 } 159 }
155 160
156 CollectionViewController* InstantiateController() override { 161 CollectionViewController* InstantiateController() override {
157 PaymentRequestViewController* viewController = 162 PaymentRequestViewController* viewController =
158 [[PaymentRequestViewController alloc] init]; 163 [[PaymentRequestViewController alloc] init];
159 [viewController setDataSource:mediator_]; 164 [viewController setDataSource:mediator_];
160 return viewController; 165 return viewController;
161 } 166 }
162 167
163 PaymentRequestViewController* GetPaymentRequestViewController() { 168 PaymentRequestViewController* GetPaymentRequestViewController() {
164 return base::mac::ObjCCastStrict<PaymentRequestViewController>( 169 return base::mac::ObjCCastStrict<PaymentRequestViewController>(
165 controller()); 170 controller());
166 } 171 }
167 172
168 base::test::ScopedTaskEnvironment scoped_task_evironment_; 173 base::test::ScopedTaskEnvironment scoped_task_evironment_;
169 174
170 autofill::AutofillProfile autofill_profile_; 175 autofill::AutofillProfile autofill_profile_;
171 autofill::CreditCard credit_card_; 176 autofill::CreditCard credit_card_;
177 web::TestWebState web_state_;
172 autofill::TestPersonalDataManager personal_data_manager_; 178 autofill::TestPersonalDataManager personal_data_manager_;
173 std::unique_ptr<payments::TestPaymentRequest> payment_request_; 179 std::unique_ptr<payments::TestPaymentRequest> payment_request_;
180 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_;
please use gerrit instead 2017/07/06 14:52:25 And so on..
Moe 2017/07/07 02:24:54 Done.
174 TestPaymentRequestMediator* mediator_; 181 TestPaymentRequestMediator* mediator_;
175 }; 182 };
176 183
177 // Tests that the correct items are displayed after loading the model. 184 // Tests that the correct items are displayed after loading the model.
178 TEST_F(PaymentRequestViewControllerTest, TestModel) { 185 TEST_F(PaymentRequestViewControllerTest, TestModel) {
179 CreateController(); 186 CreateController();
180 CheckController(); 187 CheckController();
181 CheckTitleWithId(IDS_PAYMENTS_TITLE); 188 CheckTitleWithId(IDS_PAYMENTS_TITLE);
182 189
183 [GetPaymentRequestViewController() loadModel]; 190 [GetPaymentRequestViewController() loadModel];
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 ASSERT_EQ(2U, static_cast<unsigned int>(NumberOfItemsInSection(0))); 349 ASSERT_EQ(2U, static_cast<unsigned int>(NumberOfItemsInSection(0)));
343 350
344 // The first item should be of type PageInfoItem. 351 // The first item should be of type PageInfoItem.
345 id item = GetCollectionViewItem(0, 0); 352 id item = GetCollectionViewItem(0, 0);
346 EXPECT_TRUE([item isMemberOfClass:[PageInfoItem class]]); 353 EXPECT_TRUE([item isMemberOfClass:[PageInfoItem class]]);
347 354
348 // The second item should be of type StatusItem. 355 // The second item should be of type StatusItem.
349 item = GetCollectionViewItem(0, 1); 356 item = GetCollectionViewItem(0, 1);
350 EXPECT_TRUE([item isMemberOfClass:[StatusItem class]]); 357 EXPECT_TRUE([item isMemberOfClass:[StatusItem class]]);
351 } 358 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698