| 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/payments/payment_request_error_view_controller.h" | 5 #import "ios/chrome/browser/payments/payment_request_error_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/strings/grit/components_strings.h" |
| 9 #import "ios/chrome/browser/payments/cells/payments_text_item.h" | 10 #import "ios/chrome/browser/payments/cells/payments_text_item.h" |
| 10 #import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h
" | 11 #import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h
" |
| 11 #include "ios/chrome/grit/ios_strings.h" | 12 #include "ios/chrome/grit/ios_strings.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 14 |
| 14 class PaymentRequestErrorViewControllerTest | 15 class PaymentRequestErrorViewControllerTest |
| 15 : public CollectionViewControllerTest { | 16 : public CollectionViewControllerTest { |
| 16 protected: | 17 protected: |
| 17 CollectionViewController* NewController() override NS_RETURNS_RETAINED { | 18 CollectionViewController* NewController() override NS_RETURNS_RETAINED { |
| 18 return [[PaymentRequestErrorViewController alloc] init]; | 19 return [[PaymentRequestErrorViewController alloc] init]; |
| 19 } | 20 } |
| 20 | 21 |
| 21 PaymentRequestErrorViewController* GetPaymentRequestErrorViewController() { | 22 PaymentRequestErrorViewController* GetPaymentRequestErrorViewController() { |
| 22 return base::mac::ObjCCastStrict<PaymentRequestErrorViewController>( | 23 return base::mac::ObjCCastStrict<PaymentRequestErrorViewController>( |
| 23 controller()); | 24 controller()); |
| 24 } | 25 } |
| 25 }; | 26 }; |
| 26 | 27 |
| 27 // Tests that the correct number of items are displayed after loading the model. | 28 // Tests that the correct number of items are displayed after loading the model. |
| 28 TEST_F(PaymentRequestErrorViewControllerTest, TestModel) { | 29 TEST_F(PaymentRequestErrorViewControllerTest, TestModel) { |
| 29 CreateController(); | 30 CreateController(); |
| 30 CheckController(); | 31 CheckController(); |
| 31 CheckTitleWithId(IDS_IOS_PAYMENT_REQUEST_TITLE); | 32 CheckTitleWithId(IDS_PAYMENTS_TITLE); |
| 32 | 33 |
| 33 [GetPaymentRequestErrorViewController() loadModel]; | 34 [GetPaymentRequestErrorViewController() loadModel]; |
| 34 | 35 |
| 35 ASSERT_EQ(1, NumberOfSections()); | 36 ASSERT_EQ(1, NumberOfSections()); |
| 36 // There should be one item for the error message. | 37 // There should be one item for the error message. |
| 37 ASSERT_EQ(1U, static_cast<unsigned int>(NumberOfItemsInSection(0))); | 38 ASSERT_EQ(1U, static_cast<unsigned int>(NumberOfItemsInSection(0))); |
| 38 | 39 |
| 39 // They item should be of type PriceItem. | 40 // They item should be of type PriceItem. |
| 40 id item = GetCollectionViewItem(0, 0); | 41 id item = GetCollectionViewItem(0, 0); |
| 41 EXPECT_TRUE([item isMemberOfClass:[PaymentsTextItem class]]); | 42 EXPECT_TRUE([item isMemberOfClass:[PaymentsTextItem class]]); |
| 42 } | 43 } |
| OLD | NEW |