Index: ios/chrome/browser/ui/settings/cells/account_control_item_unittest.mm |
diff --git a/ios/chrome/browser/ui/settings/cells/account_control_item_unittest.mm b/ios/chrome/browser/ui/settings/cells/account_control_item_unittest.mm |
new file mode 100644 |
index 0000000000000000000000000000000000000000..bff55004ad5f256f02d2094e590eb9c2a1ca54a3 |
--- /dev/null |
+++ b/ios/chrome/browser/ui/settings/cells/account_control_item_unittest.mm |
@@ -0,0 +1,81 @@ |
+// 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/settings/cells/account_control_item.h" |
+ |
+#import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.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 |
+ |
+// Tests that the cell is properly configured with image and texts after a call |
+// to |configureCell:|. All other cell decorations are default. |
+TEST(AccountControlItemTest, ConfigureCellDefault) { |
+ AccountControlItem* item = [[AccountControlItem alloc] initWithType:0]; |
+ UIImage* image = [[UIImage alloc] init]; |
+ NSString* mainText = @"Main text"; |
+ NSString* detailText = @"Detail text"; |
+ |
+ item.image = image; |
+ item.text = mainText; |
+ item.detailText = detailText; |
+ |
+ id cell = [[[item cellClass] alloc] init]; |
+ ASSERT_TRUE([cell isMemberOfClass:[AccountControlCell class]]); |
+ |
+ AccountControlCell* accountCell = cell; |
+ [accountCell prepareForReuse]; |
+ EXPECT_FALSE(accountCell.imageView.image); |
+ EXPECT_FALSE(accountCell.textLabel.text); |
+ EXPECT_FALSE(accountCell.detailTextLabel.text); |
+ EXPECT_EQ(MDCCollectionViewCellAccessoryNone, accountCell.accessoryType); |
+ EXPECT_NSEQ([[MDCPalette greyPalette] tint700], |
+ accountCell.detailTextLabel.textColor); |
+ |
+ [item configureCell:cell]; |
+ EXPECT_NSEQ(image, accountCell.imageView.image); |
+ EXPECT_NSEQ(mainText, accountCell.textLabel.text); |
+ EXPECT_NSEQ(detailText, accountCell.detailTextLabel.text); |
+ EXPECT_EQ(MDCCollectionViewCellAccessoryNone, accountCell.accessoryType); |
+ EXPECT_NSEQ([[MDCPalette greyPalette] tint700], |
+ accountCell.detailTextLabel.textColor); |
+} |
+ |
+// Tests that the cell is properly configured with error and an accessory after |
+// a call to |configureCell:|. |
+TEST(AccountControlItemTest, ConfigureCellWithErrorAndAccessory) { |
+ AccountControlItem* item = [[AccountControlItem alloc] initWithType:0]; |
+ UIImage* image = [[UIImage alloc] init]; |
+ NSString* mainText = @"Main text"; |
+ NSString* detailText = @"Detail text"; |
+ |
+ item.image = image; |
+ item.text = mainText; |
+ item.detailText = detailText; |
+ item.accessoryType = MDCCollectionViewCellAccessoryCheckmark; |
+ item.shouldDisplayError = YES; |
+ |
+ id cell = [[[item cellClass] alloc] init]; |
+ ASSERT_TRUE([cell isMemberOfClass:[AccountControlCell class]]); |
+ |
+ AccountControlCell* accountCell = cell; |
+ [accountCell prepareForReuse]; |
+ EXPECT_FALSE(accountCell.imageView.image); |
+ EXPECT_FALSE(accountCell.textLabel.text); |
+ EXPECT_FALSE(accountCell.detailTextLabel.text); |
+ EXPECT_EQ(MDCCollectionViewCellAccessoryNone, accountCell.accessoryType); |
+ EXPECT_NSEQ([[MDCPalette greyPalette] tint700], |
+ accountCell.detailTextLabel.textColor); |
+ |
+ [item configureCell:cell]; |
+ EXPECT_NSEQ(image, accountCell.imageView.image); |
+ EXPECT_NSEQ(mainText, accountCell.textLabel.text); |
+ EXPECT_NSEQ(detailText, accountCell.detailTextLabel.text); |
+ EXPECT_EQ(MDCCollectionViewCellAccessoryCheckmark, accountCell.accessoryType); |
+ EXPECT_NSEQ([[MDCPalette cr_redPalette] tint700], |
+ accountCell.detailTextLabel.textColor); |
+} |