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

Side by Side Diff: ios/chrome/browser/ui/settings/cells/native_app_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/native_app_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 name, icon and state are honoured after a call to
18 // |configureCell:|.
19 TEST(NativeAppItemTest, ConfigureCell) {
20 NativeAppItem* item = [[NativeAppItem alloc] initWithType:0];
21 NSString* text = @"Test Switch";
22 UIImage* image = ios_internal::CollectionViewTestImage();
23
24 item.name = text;
25 item.icon = image;
26
27 id cell = [[[item cellClass] alloc] init];
28 ASSERT_TRUE([cell isMemberOfClass:[NativeAppCell class]]);
29
30 NativeAppCell* appCell = static_cast<NativeAppCell*>(cell);
31 EXPECT_FALSE(appCell.nameLabel.text);
32 EXPECT_TRUE(appCell.iconImageView.image);
33 EXPECT_NE(image, appCell.iconImageView.image);
34 EXPECT_FALSE(appCell.accessoryView);
35
36 [item configureCell:cell];
37 EXPECT_NSEQ(text, appCell.nameLabel.text);
38 EXPECT_NSEQ(image, appCell.iconImageView.image);
39 EXPECT_EQ((UIView*)appCell.switchControl, appCell.accessoryView);
40 EXPECT_FALSE(appCell.switchControl.on);
41 }
42
43 // Tests that the NativeAppItemSwitchOff configures the cell with a switch,
44 // turned off.
45 TEST(NativeAppItemTest, State_SwitchOff) {
46 NativeAppItem* item = [[NativeAppItem alloc] initWithType:0];
47 item.state = NativeAppItemSwitchOff;
48 NativeAppCell* appCell = [[[item cellClass] alloc] init];
49 [item configureCell:appCell];
50
51 EXPECT_EQ((UIView*)appCell.switchControl, appCell.accessoryView);
52 EXPECT_FALSE(appCell.switchControl.on);
53 }
54
55 // Tests that the NativeAppItemSwitchOn configures the cell with a switch,
56 // turned on.
57 TEST(NativeAppItemTest, State_SwitchOn) {
58 NativeAppItem* item = [[NativeAppItem alloc] initWithType:0];
59 item.state = NativeAppItemSwitchOn;
60 NativeAppCell* appCell = [[[item cellClass] alloc] init];
61 [item configureCell:appCell];
62
63 EXPECT_EQ((UIView*)appCell.switchControl, appCell.accessoryView);
64 EXPECT_TRUE(appCell.switchControl.on);
65 }
66
67 // Tests that the NativeAppItemInstall configures the cell with a button.
68 TEST(NativeAppItemTest, State_Install) {
69 NativeAppItem* item = [[NativeAppItem alloc] initWithType:0];
70 item.state = NativeAppItemInstall;
71 NativeAppCell* appCell = [[[item cellClass] alloc] init];
72 [item configureCell:appCell];
73
74 EXPECT_EQ((UIView*)appCell.installButton, appCell.accessoryView);
75 }
76
77 } // namespace
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/settings/cells/native_app_item.mm ('k') | ios/chrome/browser/ui/settings/cells/passphrase_error_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698