Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Unified Diff: ios/chrome/browser/ui/autofill/cells/cvc_item_unittest.mm

Issue 2586993002: Upstream Chrome on iOS source code [3/11]. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/autofill/cells/cvc_item_unittest.mm
diff --git a/ios/chrome/browser/ui/autofill/cells/cvc_item_unittest.mm b/ios/chrome/browser/ui/autofill/cells/cvc_item_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..d6ee18bf466b606a5f323837d08ffb3a7e1ba643
--- /dev/null
+++ b/ios/chrome/browser/ui/autofill/cells/cvc_item_unittest.mm
@@ -0,0 +1,70 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ios/chrome/browser/ui/autofill/cells/cvc_item.h"
+
+#include "base/mac/foundation_util.h"
+#include "components/grit/components_scaled_resources.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/gtest_mac.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+@interface CVCCell (Private)
+@property(nonatomic, strong) UIView* dateContainerView;
+@end
+
+namespace {
+
+// Tests that the cell subviews are set properly after a call to
+// |configureCell:| in the different states possible.
+TEST(CVCItemTest, ConfigureCell) {
+ CVCItem* item = [[CVCItem alloc] initWithType:0];
+ NSString* instructionsText = @"Instructions Test Text";
+ NSString* errorMessage = @"Test Error Message";
+ NSString* monthText = @"01";
+ NSString* yearText = @"01";
+ NSString* CVCText = @"123";
+
+ item.instructionsText = instructionsText;
+ item.errorMessage = errorMessage;
+ item.monthText = monthText;
+ item.yearText = yearText;
+ item.CVCText = CVCText;
+ item.CVCImageResourceID = IDR_CREDIT_CARD_CVC_HINT_AMEX;
+
+ id cell = [[[item cellClass] alloc] init];
+ ASSERT_TRUE([cell isMemberOfClass:[CVCCell class]]);
+
+ CVCCell* CVC = base::mac::ObjCCastStrict<CVCCell>(cell);
+ EXPECT_EQ(0U, CVC.instructionsTextLabel.text.length);
+ EXPECT_EQ(0U, CVC.errorLabel.text.length);
+ EXPECT_EQ(0U, CVC.monthInput.text.length);
+ EXPECT_EQ(0U, CVC.yearInput.text.length);
+ EXPECT_EQ(0U, CVC.CVCInput.text.length);
+ EXPECT_NSEQ(nil, CVC.CVCImageView.image);
+
+ [item configureCell:CVC];
+ EXPECT_NSEQ(instructionsText, CVC.instructionsTextLabel.text);
+ EXPECT_NSEQ(errorMessage, CVC.errorLabel.text);
+ EXPECT_NSEQ(monthText, CVC.monthInput.text);
+ EXPECT_NSEQ(yearText, CVC.yearInput.text);
+ EXPECT_NSEQ(CVCText, CVC.CVCInput.text);
+ EXPECT_NSNE(nil, CVC.CVCImageView.image);
+ EXPECT_TRUE(CVC.dateContainerView.hidden);
+ EXPECT_TRUE(CVC.buttonForNewCard.hidden);
+
+ item.showDateInput = YES;
+ [item configureCell:CVC];
+ EXPECT_FALSE(CVC.dateContainerView.hidden);
+ EXPECT_TRUE(CVC.buttonForNewCard.hidden);
+
+ item.showNewCardButton = YES;
+ [item configureCell:CVC];
+ EXPECT_FALSE(CVC.buttonForNewCard.hidden);
+}
+
+} // namespace
« no previous file with comments | « ios/chrome/browser/ui/autofill/cells/cvc_item.mm ('k') | ios/chrome/browser/ui/autofill/cells/status_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698