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

Side by Side Diff: ios/chrome/browser/ui/payments/payment_items_display_view_controller_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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_items_display_view_controller.h" 5 #import "ios/chrome/browser/ui/payments/payment_items_display_view_controller.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/test_personal_data_manager.h" 10 #include "components/autofill/core/browser/test_personal_data_manager.h"
(...skipping 28 matching lines...) Expand all
39 - (NSArray<CollectionViewItem*>*)lineItems { 39 - (NSArray<CollectionViewItem*>*)lineItems {
40 return @[ [[PriceItem alloc] init] ]; 40 return @[ [[PriceItem alloc] init] ];
41 } 41 }
42 42
43 @end 43 @end
44 44
45 class PaymentRequestPaymentItemsDisplayViewControllerTest 45 class PaymentRequestPaymentItemsDisplayViewControllerTest
46 : public CollectionViewControllerTest { 46 : public CollectionViewControllerTest {
47 protected: 47 protected:
48 CollectionViewController* InstantiateController() override { 48 CollectionViewController* InstantiateController() override {
49 payment_request_ = base::MakeUnique<TestPaymentRequest>( 49 payment_request_ = base::MakeUnique<payments::TestPaymentRequest>(
50 payment_request_test_util::CreateTestWebPaymentRequest(), 50 payment_request_test_util::CreateTestWebPaymentRequest(),
51 &personal_data_manager_); 51 &personal_data_manager_);
52 mediator_ = [[TestPaymentItemsDisplayMediator alloc] init]; 52 mediator_ = [[TestPaymentItemsDisplayMediator alloc] init];
53 PaymentItemsDisplayViewController* viewController = [ 53 PaymentItemsDisplayViewController* viewController = [
54 [PaymentItemsDisplayViewController alloc] initWithPayButtonEnabled:YES]; 54 [PaymentItemsDisplayViewController alloc] initWithPayButtonEnabled:YES];
55 [viewController setDataSource:mediator_]; 55 [viewController setDataSource:mediator_];
56 return viewController; 56 return viewController;
57 } 57 }
58 58
59 PaymentItemsDisplayViewController* GetPaymentItemsViewController() { 59 PaymentItemsDisplayViewController* GetPaymentItemsViewController() {
60 return base::mac::ObjCCastStrict<PaymentItemsDisplayViewController>( 60 return base::mac::ObjCCastStrict<PaymentItemsDisplayViewController>(
61 controller()); 61 controller());
62 } 62 }
63 63
64 base::test::ScopedTaskEnvironment scoped_task_evironment_; 64 base::test::ScopedTaskEnvironment scoped_task_evironment_;
65 65
66 autofill::TestPersonalDataManager personal_data_manager_; 66 autofill::TestPersonalDataManager personal_data_manager_;
67 std::unique_ptr<TestPaymentRequest> payment_request_; 67 std::unique_ptr<payments::TestPaymentRequest> payment_request_;
68 TestPaymentItemsDisplayMediator* mediator_ = nil; 68 TestPaymentItemsDisplayMediator* mediator_ = nil;
69 }; 69 };
70 70
71 // Tests that the correct number of items are displayed after loading the model. 71 // Tests that the correct number of items are displayed after loading the model.
72 TEST_F(PaymentRequestPaymentItemsDisplayViewControllerTest, TestModel) { 72 TEST_F(PaymentRequestPaymentItemsDisplayViewControllerTest, TestModel) {
73 CreateController(); 73 CreateController();
74 CheckController(); 74 CheckController();
75 CheckTitleWithId(IDS_PAYMENTS_ORDER_SUMMARY_LABEL); 75 CheckTitleWithId(IDS_PAYMENTS_ORDER_SUMMARY_LABEL);
76 76
77 [GetPaymentItemsViewController() loadModel]; 77 [GetPaymentItemsViewController() loadModel];
78 78
79 ASSERT_EQ(1, NumberOfSections()); 79 ASSERT_EQ(1, NumberOfSections());
80 // There should be one item for the total and another one for sub-total. 80 // There should be one item for the total and another one for sub-total.
81 ASSERT_EQ(2U, static_cast<unsigned int>(NumberOfItemsInSection(0))); 81 ASSERT_EQ(2U, static_cast<unsigned int>(NumberOfItemsInSection(0)));
82 82
83 // They both should be of type PriceItem. 83 // They both should be of type PriceItem.
84 id item = GetCollectionViewItem(0, 0); 84 id item = GetCollectionViewItem(0, 0);
85 EXPECT_TRUE([item isMemberOfClass:[PriceItem class]]); 85 EXPECT_TRUE([item isMemberOfClass:[PriceItem class]]);
86 item = GetCollectionViewItem(0, 1); 86 item = GetCollectionViewItem(0, 1);
87 EXPECT_TRUE([item isMemberOfClass:[PriceItem class]]); 87 EXPECT_TRUE([item isMemberOfClass:[PriceItem class]]);
88 } 88 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698