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

Side by Side Diff: ios/chrome/browser/ui/payments/payment_request_mediator_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_mediator.h" 5 #import "ios/chrome/browser/ui/payments/payment_request_mediator.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 16 matching lines...) Expand all
27 #include "ios/chrome/browser/payments/test_payment_request.h" 27 #include "ios/chrome/browser/payments/test_payment_request.h"
28 #include "ios/chrome/browser/signin/fake_signin_manager_builder.h" 28 #include "ios/chrome/browser/signin/fake_signin_manager_builder.h"
29 #include "ios/chrome/browser/signin/signin_manager_factory.h" 29 #include "ios/chrome/browser/signin/signin_manager_factory.h"
30 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_detail_item .h" 30 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_detail_item .h"
31 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_footer_item .h" 31 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_footer_item .h"
32 #import "ios/chrome/browser/ui/payments/cells/autofill_profile_item.h" 32 #import "ios/chrome/browser/ui/payments/cells/autofill_profile_item.h"
33 #import "ios/chrome/browser/ui/payments/cells/payment_method_item.h" 33 #import "ios/chrome/browser/ui/payments/cells/payment_method_item.h"
34 #import "ios/chrome/browser/ui/payments/cells/payments_text_item.h" 34 #import "ios/chrome/browser/ui/payments/cells/payments_text_item.h"
35 #import "ios/chrome/browser/ui/payments/cells/price_item.h" 35 #import "ios/chrome/browser/ui/payments/cells/price_item.h"
36 #include "ios/web/public/payments/payment_request.h" 36 #include "ios/web/public/payments/payment_request.h"
37 #import "ios/web/public/test/fakes/test_web_state.h"
37 #include "testing/gtest/include/gtest/gtest.h" 38 #include "testing/gtest/include/gtest/gtest.h"
38 #include "testing/platform_test.h" 39 #include "testing/platform_test.h"
39 #include "ui/base/l10n/l10n_util.h" 40 #include "ui/base/l10n/l10n_util.h"
40 41
41 #if !defined(__has_feature) || !__has_feature(objc_arc) 42 #if !defined(__has_feature) || !__has_feature(objc_arc)
42 #error "This file requires ARC support." 43 #error "This file requires ARC support."
43 #endif 44 #endif
44 45
45 namespace { 46 namespace {
46 using ::payments::GetShippingOptionSectionString; 47 using ::payments::GetShippingOptionSectionString;
(...skipping 14 matching lines...) Expand all
61 credit_card_.set_billing_address_id(autofill_profile_.guid()); 62 credit_card_.set_billing_address_id(autofill_profile_.guid());
62 personal_data_manager_.AddTestingCreditCard(&credit_card_); 63 personal_data_manager_.AddTestingCreditCard(&credit_card_);
63 64
64 TestChromeBrowserState::Builder test_cbs_builder; 65 TestChromeBrowserState::Builder test_cbs_builder;
65 test_cbs_builder.AddTestingFactory(ios::SigninManagerFactory::GetInstance(), 66 test_cbs_builder.AddTestingFactory(ios::SigninManagerFactory::GetInstance(),
66 &ios::BuildFakeSigninManager); 67 &ios::BuildFakeSigninManager);
67 chrome_browser_state_ = test_cbs_builder.Build(); 68 chrome_browser_state_ = test_cbs_builder.Build();
68 69
69 payment_request_ = base::MakeUnique<payments::TestPaymentRequest>( 70 payment_request_ = base::MakeUnique<payments::TestPaymentRequest>(
70 payment_request_test_util::CreateTestWebPaymentRequest(), 71 payment_request_test_util::CreateTestWebPaymentRequest(),
71 chrome_browser_state_.get(), &personal_data_manager_); 72 chrome_browser_state_.get(), &web_state_, &personal_data_manager_);
72 payment_request_->SetPrefService(pref_service_.get()); 73 payment_request_->SetPrefService(pref_service_.get());
73 74
74 mediator_ = [[PaymentRequestMediator alloc] 75 mediator_ = [[PaymentRequestMediator alloc]
75 initWithPaymentRequest:payment_request_.get()]; 76 initWithPaymentRequest:payment_request_.get()];
76 } 77 }
77 78
78 PaymentRequestMediator* GetPaymentRequestMediator() { return mediator_; } 79 PaymentRequestMediator* GetPaymentRequestMediator() { return mediator_; }
79 80
80 base::test::ScopedTaskEnvironment scoped_task_evironment_; 81 base::test::ScopedTaskEnvironment scoped_task_evironment_;
81 82
82 autofill::AutofillProfile autofill_profile_; 83 autofill::AutofillProfile autofill_profile_;
83 autofill::CreditCard credit_card_; 84 autofill::CreditCard credit_card_;
85 web::TestWebState web_state_;
84 std::unique_ptr<PrefService> pref_service_; 86 std::unique_ptr<PrefService> pref_service_;
85 autofill::TestPersonalDataManager personal_data_manager_; 87 autofill::TestPersonalDataManager personal_data_manager_;
86 std::unique_ptr<payments::TestPaymentRequest> payment_request_; 88 std::unique_ptr<payments::TestPaymentRequest> payment_request_;
87 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; 89 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_;
88 PaymentRequestMediator* mediator_; 90 PaymentRequestMediator* mediator_;
89 }; 91 };
90 92
91 // Tests whether payment can be completed when expected. 93 // Tests whether payment can be completed when expected.
92 TEST_F(PaymentRequestMediatorTest, TestCanPay) { 94 TEST_F(PaymentRequestMediatorTest, TestCanPay) {
93 EXPECT_TRUE(payment_request_->selected_payment_method()); 95 EXPECT_TRUE(payment_request_->selected_payment_method());
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 signin_manager->SignOut(signin_metrics::SIGNOUT_TEST, 476 signin_manager->SignOut(signin_metrics::SIGNOUT_TEST,
475 signin_metrics::SignoutDelete::IGNORE_METRIC); 477 signin_metrics::SignoutDelete::IGNORE_METRIC);
476 478
477 // The signed in state has no effect on the footer text if the first 479 // The signed in state has no effect on the footer text if the first
478 // transaction has completed. 480 // transaction has completed.
479 footer_item = base::mac::ObjCCastStrict<CollectionViewFooterItem>(item); 481 footer_item = base::mac::ObjCCastStrict<CollectionViewFooterItem>(item);
480 EXPECT_TRUE([footer_item.text 482 EXPECT_TRUE([footer_item.text
481 isEqualToString:l10n_util::GetNSString( 483 isEqualToString:l10n_util::GetNSString(
482 IDS_PAYMENTS_CARD_AND_ADDRESS_SETTINGS)]); 484 IDS_PAYMENTS_CARD_AND_ADDRESS_SETTINGS)]);
483 } 485 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698