OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import "ios/chrome/browser/payments/cells/payment_method_item.h" |
| 6 |
| 7 #import "ios/chrome/browser/ui/collection_view/cells/test_utils.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "testing/gtest_mac.h" |
| 10 |
| 11 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 12 #error "This file requires ARC support." |
| 13 #endif |
| 14 |
| 15 namespace { |
| 16 |
| 17 // Tests that the labels and image are set properly after a call to |
| 18 // |configureCell:|. |
| 19 TEST(PaymentMethodItemTest, TextLabels) { |
| 20 PaymentMethodItem* item = [[PaymentMethodItem alloc] initWithType:0]; |
| 21 |
| 22 NSString* methodID = @"BobPay - ****-6789"; |
| 23 NSString* methodDetail = @"Bobs Your Uncle III, esq."; |
| 24 UIImage* methodTypeIcon = ios_internal::CollectionViewTestImage(); |
| 25 MDCCollectionViewCellAccessoryType accessoryType = |
| 26 MDCCollectionViewCellAccessoryDisclosureIndicator; |
| 27 |
| 28 item.methodID = methodID; |
| 29 item.methodDetail = methodDetail; |
| 30 item.methodTypeIcon = methodTypeIcon; |
| 31 item.accessoryType = accessoryType; |
| 32 |
| 33 id cell = [[[item cellClass] alloc] init]; |
| 34 ASSERT_TRUE([cell isMemberOfClass:[PaymentMethodCell class]]); |
| 35 |
| 36 PaymentMethodCell* paymentMethodCell = cell; |
| 37 EXPECT_FALSE(paymentMethodCell.methodIDLabel.text); |
| 38 EXPECT_FALSE(paymentMethodCell.methodDetailLabel.text); |
| 39 EXPECT_FALSE(paymentMethodCell.methodTypeIconView.image); |
| 40 EXPECT_EQ(paymentMethodCell.accessoryType, |
| 41 MDCCollectionViewCellAccessoryNone); |
| 42 |
| 43 [item configureCell:paymentMethodCell]; |
| 44 EXPECT_NSEQ(methodID, paymentMethodCell.methodIDLabel.text); |
| 45 EXPECT_NSEQ(methodDetail, paymentMethodCell.methodDetailLabel.text); |
| 46 EXPECT_NSEQ(methodTypeIcon, paymentMethodCell.methodTypeIconView.image); |
| 47 EXPECT_EQ(paymentMethodCell.accessoryType, |
| 48 MDCCollectionViewCellAccessoryDisclosureIndicator); |
| 49 } |
| 50 |
| 51 } // namespace |
OLD | NEW |