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

Side by Side Diff: ios/chrome/browser/ui/settings/cells/account_control_item_unittest.mm

Issue 2589583003: Upstream Chrome on iOS source code [7/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 unified diff | Download patch
OLDNEW
(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/settings/cells/account_control_item.h"
6
7 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.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 // Tests that the cell is properly configured with image and texts after a call
16 // to |configureCell:|. All other cell decorations are default.
17 TEST(AccountControlItemTest, ConfigureCellDefault) {
18 AccountControlItem* item = [[AccountControlItem alloc] initWithType:0];
19 UIImage* image = [[UIImage alloc] init];
20 NSString* mainText = @"Main text";
21 NSString* detailText = @"Detail text";
22
23 item.image = image;
24 item.text = mainText;
25 item.detailText = detailText;
26
27 id cell = [[[item cellClass] alloc] init];
28 ASSERT_TRUE([cell isMemberOfClass:[AccountControlCell class]]);
29
30 AccountControlCell* accountCell = cell;
31 [accountCell prepareForReuse];
32 EXPECT_FALSE(accountCell.imageView.image);
33 EXPECT_FALSE(accountCell.textLabel.text);
34 EXPECT_FALSE(accountCell.detailTextLabel.text);
35 EXPECT_EQ(MDCCollectionViewCellAccessoryNone, accountCell.accessoryType);
36 EXPECT_NSEQ([[MDCPalette greyPalette] tint700],
37 accountCell.detailTextLabel.textColor);
38
39 [item configureCell:cell];
40 EXPECT_NSEQ(image, accountCell.imageView.image);
41 EXPECT_NSEQ(mainText, accountCell.textLabel.text);
42 EXPECT_NSEQ(detailText, accountCell.detailTextLabel.text);
43 EXPECT_EQ(MDCCollectionViewCellAccessoryNone, accountCell.accessoryType);
44 EXPECT_NSEQ([[MDCPalette greyPalette] tint700],
45 accountCell.detailTextLabel.textColor);
46 }
47
48 // Tests that the cell is properly configured with error and an accessory after
49 // a call to |configureCell:|.
50 TEST(AccountControlItemTest, ConfigureCellWithErrorAndAccessory) {
51 AccountControlItem* item = [[AccountControlItem alloc] initWithType:0];
52 UIImage* image = [[UIImage alloc] init];
53 NSString* mainText = @"Main text";
54 NSString* detailText = @"Detail text";
55
56 item.image = image;
57 item.text = mainText;
58 item.detailText = detailText;
59 item.accessoryType = MDCCollectionViewCellAccessoryCheckmark;
60 item.shouldDisplayError = YES;
61
62 id cell = [[[item cellClass] alloc] init];
63 ASSERT_TRUE([cell isMemberOfClass:[AccountControlCell class]]);
64
65 AccountControlCell* accountCell = cell;
66 [accountCell prepareForReuse];
67 EXPECT_FALSE(accountCell.imageView.image);
68 EXPECT_FALSE(accountCell.textLabel.text);
69 EXPECT_FALSE(accountCell.detailTextLabel.text);
70 EXPECT_EQ(MDCCollectionViewCellAccessoryNone, accountCell.accessoryType);
71 EXPECT_NSEQ([[MDCPalette greyPalette] tint700],
72 accountCell.detailTextLabel.textColor);
73
74 [item configureCell:cell];
75 EXPECT_NSEQ(image, accountCell.imageView.image);
76 EXPECT_NSEQ(mainText, accountCell.textLabel.text);
77 EXPECT_NSEQ(detailText, accountCell.detailTextLabel.text);
78 EXPECT_EQ(MDCCollectionViewCellAccessoryCheckmark, accountCell.accessoryType);
79 EXPECT_NSEQ([[MDCPalette cr_redPalette] tint700],
80 accountCell.detailTextLabel.textColor);
81 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698