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