| 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/payment_request_view_controller.h" | 5 #import "ios/chrome/browser/ui/payments/payment_request_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 "components/autofill/core/browser/autofill_profile.h" | 9 #include "components/autofill/core/browser/autofill_profile.h" |
| 10 #include "components/autofill/core/browser/autofill_test_utils.h" | 10 #include "components/autofill/core/browser/autofill_test_utils.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 item = GetCollectionViewItem(3, 0); | 107 item = GetCollectionViewItem(3, 0); |
| 108 EXPECT_TRUE([item isMemberOfClass:[AutofillProfileItem class]]); | 108 EXPECT_TRUE([item isMemberOfClass:[AutofillProfileItem class]]); |
| 109 } | 109 } |
| 110 | 110 |
| 111 // Tests that the correct items are displayed after loading the model, when | 111 // Tests that the correct items are displayed after loading the model, when |
| 112 // there are no display items. | 112 // there are no display items. |
| 113 TEST_F(PaymentRequestViewControllerTest, TestModelNoDisplayItem) { | 113 TEST_F(PaymentRequestViewControllerTest, TestModelNoDisplayItem) { |
| 114 CreateController(); | 114 CreateController(); |
| 115 CheckController(); | 115 CheckController(); |
| 116 | 116 |
| 117 payment_request_->set_payment_details(web::PaymentDetails()); | 117 payment_request_->UpdatePaymentDetails(web::PaymentDetails()); |
| 118 [GetPaymentRequestViewController() loadModel]; | 118 [GetPaymentRequestViewController() loadModel]; |
| 119 | 119 |
| 120 // The only item in the Summary section should stil be of type PriceItem, but | 120 // The only item in the Summary section should stil be of type PriceItem, but |
| 121 // without an accessory view. | 121 // without an accessory view. |
| 122 ASSERT_EQ(1U, static_cast<unsigned int>(NumberOfItemsInSection(0))); | 122 ASSERT_EQ(1U, static_cast<unsigned int>(NumberOfItemsInSection(0))); |
| 123 id item = GetCollectionViewItem(0, 0); | 123 id item = GetCollectionViewItem(0, 0); |
| 124 EXPECT_TRUE([item isMemberOfClass:[PriceItem class]]); | 124 EXPECT_TRUE([item isMemberOfClass:[PriceItem class]]); |
| 125 PriceItem* price_item = item; | 125 PriceItem* price_item = item; |
| 126 EXPECT_EQ(MDCCollectionViewCellAccessoryNone, price_item.accessoryType); | 126 EXPECT_EQ(MDCCollectionViewCellAccessoryNone, price_item.accessoryType); |
| 127 } | 127 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 145 EXPECT_EQ(MDCCollectionViewCellAccessoryNone, detail_item.accessoryType); | 145 EXPECT_EQ(MDCCollectionViewCellAccessoryNone, detail_item.accessoryType); |
| 146 } | 146 } |
| 147 | 147 |
| 148 // Tests that the correct items are displayed after loading the model, when | 148 // Tests that the correct items are displayed after loading the model, when |
| 149 // there is no selected shipping option. | 149 // there is no selected shipping option. |
| 150 TEST_F(PaymentRequestViewControllerTest, TestModelNoSelectedShippingOption) { | 150 TEST_F(PaymentRequestViewControllerTest, TestModelNoSelectedShippingOption) { |
| 151 CreateController(); | 151 CreateController(); |
| 152 CheckController(); | 152 CheckController(); |
| 153 | 153 |
| 154 // Resetting the payment details should reset the selected shipping option. | 154 // Resetting the payment details should reset the selected shipping option. |
| 155 payment_request_->set_payment_details(web::PaymentDetails()); | 155 payment_request_->UpdatePaymentDetails(web::PaymentDetails()); |
| 156 [GetPaymentRequestViewController() loadModel]; | 156 [GetPaymentRequestViewController() loadModel]; |
| 157 | 157 |
| 158 // There should still be two items in the Shipping section. | 158 // There should still be two items in the Shipping section. |
| 159 ASSERT_EQ(2U, static_cast<unsigned int>(NumberOfItemsInSection(1))); | 159 ASSERT_EQ(2U, static_cast<unsigned int>(NumberOfItemsInSection(1))); |
| 160 | 160 |
| 161 // The second one should be of type CollectionViewDetailItem. | 161 // The second one should be of type CollectionViewDetailItem. |
| 162 id item = GetCollectionViewItem(1, 1); | 162 id item = GetCollectionViewItem(1, 1); |
| 163 EXPECT_TRUE([item isMemberOfClass:[CollectionViewDetailItem class]]); | 163 EXPECT_TRUE([item isMemberOfClass:[CollectionViewDetailItem class]]); |
| 164 CollectionViewDetailItem* detail_item = item; | 164 CollectionViewDetailItem* detail_item = item; |
| 165 EXPECT_EQ(MDCCollectionViewCellAccessoryDisclosureIndicator, | 165 EXPECT_EQ(MDCCollectionViewCellAccessoryDisclosureIndicator, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 194 [GetPaymentRequestViewController() loadModel]; | 194 [GetPaymentRequestViewController() loadModel]; |
| 195 | 195 |
| 196 ASSERT_EQ(1, NumberOfSections()); | 196 ASSERT_EQ(1, NumberOfSections()); |
| 197 // There should be only one item. | 197 // There should be only one item. |
| 198 ASSERT_EQ(1U, static_cast<unsigned int>(NumberOfItemsInSection(0))); | 198 ASSERT_EQ(1U, static_cast<unsigned int>(NumberOfItemsInSection(0))); |
| 199 | 199 |
| 200 // The item should be of type StatusItem. | 200 // The item should be of type StatusItem. |
| 201 id item = GetCollectionViewItem(0, 0); | 201 id item = GetCollectionViewItem(0, 0); |
| 202 EXPECT_TRUE([item isMemberOfClass:[StatusItem class]]); | 202 EXPECT_TRUE([item isMemberOfClass:[StatusItem class]]); |
| 203 } | 203 } |
| OLD | NEW |