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/ui/autofill/cells/cvc_item.h" |
| 6 |
| 7 #include "base/mac/foundation_util.h" |
| 8 #include "components/grit/components_scaled_resources.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "testing/gtest_mac.h" |
| 11 |
| 12 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 13 #error "This file requires ARC support." |
| 14 #endif |
| 15 |
| 16 @interface CVCCell (Private) |
| 17 @property(nonatomic, strong) UIView* dateContainerView; |
| 18 @end |
| 19 |
| 20 namespace { |
| 21 |
| 22 // Tests that the cell subviews are set properly after a call to |
| 23 // |configureCell:| in the different states possible. |
| 24 TEST(CVCItemTest, ConfigureCell) { |
| 25 CVCItem* item = [[CVCItem alloc] initWithType:0]; |
| 26 NSString* instructionsText = @"Instructions Test Text"; |
| 27 NSString* errorMessage = @"Test Error Message"; |
| 28 NSString* monthText = @"01"; |
| 29 NSString* yearText = @"01"; |
| 30 NSString* CVCText = @"123"; |
| 31 |
| 32 item.instructionsText = instructionsText; |
| 33 item.errorMessage = errorMessage; |
| 34 item.monthText = monthText; |
| 35 item.yearText = yearText; |
| 36 item.CVCText = CVCText; |
| 37 item.CVCImageResourceID = IDR_CREDIT_CARD_CVC_HINT_AMEX; |
| 38 |
| 39 id cell = [[[item cellClass] alloc] init]; |
| 40 ASSERT_TRUE([cell isMemberOfClass:[CVCCell class]]); |
| 41 |
| 42 CVCCell* CVC = base::mac::ObjCCastStrict<CVCCell>(cell); |
| 43 EXPECT_EQ(0U, CVC.instructionsTextLabel.text.length); |
| 44 EXPECT_EQ(0U, CVC.errorLabel.text.length); |
| 45 EXPECT_EQ(0U, CVC.monthInput.text.length); |
| 46 EXPECT_EQ(0U, CVC.yearInput.text.length); |
| 47 EXPECT_EQ(0U, CVC.CVCInput.text.length); |
| 48 EXPECT_NSEQ(nil, CVC.CVCImageView.image); |
| 49 |
| 50 [item configureCell:CVC]; |
| 51 EXPECT_NSEQ(instructionsText, CVC.instructionsTextLabel.text); |
| 52 EXPECT_NSEQ(errorMessage, CVC.errorLabel.text); |
| 53 EXPECT_NSEQ(monthText, CVC.monthInput.text); |
| 54 EXPECT_NSEQ(yearText, CVC.yearInput.text); |
| 55 EXPECT_NSEQ(CVCText, CVC.CVCInput.text); |
| 56 EXPECT_NSNE(nil, CVC.CVCImageView.image); |
| 57 EXPECT_TRUE(CVC.dateContainerView.hidden); |
| 58 EXPECT_TRUE(CVC.buttonForNewCard.hidden); |
| 59 |
| 60 item.showDateInput = YES; |
| 61 [item configureCell:CVC]; |
| 62 EXPECT_FALSE(CVC.dateContainerView.hidden); |
| 63 EXPECT_TRUE(CVC.buttonForNewCard.hidden); |
| 64 |
| 65 item.showNewCardButton = YES; |
| 66 [item configureCell:CVC]; |
| 67 EXPECT_FALSE(CVC.buttonForNewCard.hidden); |
| 68 } |
| 69 |
| 70 } // namespace |
OLD | NEW |