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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/settings/cells/native_app_item_unittest.mm
diff --git a/ios/chrome/browser/ui/settings/cells/native_app_item_unittest.mm b/ios/chrome/browser/ui/settings/cells/native_app_item_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..b841ba0d6972d1cce9d599fe1a56653f24a07317
--- /dev/null
+++ b/ios/chrome/browser/ui/settings/cells/native_app_item_unittest.mm
@@ -0,0 +1,77 @@
+// 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/native_app_item.h"
+
+#import "ios/chrome/browser/ui/collection_view/cells/test_utils.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
+
+namespace {
+
+// Tests that the name, icon and state are honoured after a call to
+// |configureCell:|.
+TEST(NativeAppItemTest, ConfigureCell) {
+ NativeAppItem* item = [[NativeAppItem alloc] initWithType:0];
+ NSString* text = @"Test Switch";
+ UIImage* image = ios_internal::CollectionViewTestImage();
+
+ item.name = text;
+ item.icon = image;
+
+ id cell = [[[item cellClass] alloc] init];
+ ASSERT_TRUE([cell isMemberOfClass:[NativeAppCell class]]);
+
+ NativeAppCell* appCell = static_cast<NativeAppCell*>(cell);
+ EXPECT_FALSE(appCell.nameLabel.text);
+ EXPECT_TRUE(appCell.iconImageView.image);
+ EXPECT_NE(image, appCell.iconImageView.image);
+ EXPECT_FALSE(appCell.accessoryView);
+
+ [item configureCell:cell];
+ EXPECT_NSEQ(text, appCell.nameLabel.text);
+ EXPECT_NSEQ(image, appCell.iconImageView.image);
+ EXPECT_EQ((UIView*)appCell.switchControl, appCell.accessoryView);
+ EXPECT_FALSE(appCell.switchControl.on);
+}
+
+// Tests that the NativeAppItemSwitchOff configures the cell with a switch,
+// turned off.
+TEST(NativeAppItemTest, State_SwitchOff) {
+ NativeAppItem* item = [[NativeAppItem alloc] initWithType:0];
+ item.state = NativeAppItemSwitchOff;
+ NativeAppCell* appCell = [[[item cellClass] alloc] init];
+ [item configureCell:appCell];
+
+ EXPECT_EQ((UIView*)appCell.switchControl, appCell.accessoryView);
+ EXPECT_FALSE(appCell.switchControl.on);
+}
+
+// Tests that the NativeAppItemSwitchOn configures the cell with a switch,
+// turned on.
+TEST(NativeAppItemTest, State_SwitchOn) {
+ NativeAppItem* item = [[NativeAppItem alloc] initWithType:0];
+ item.state = NativeAppItemSwitchOn;
+ NativeAppCell* appCell = [[[item cellClass] alloc] init];
+ [item configureCell:appCell];
+
+ EXPECT_EQ((UIView*)appCell.switchControl, appCell.accessoryView);
+ EXPECT_TRUE(appCell.switchControl.on);
+}
+
+// Tests that the NativeAppItemInstall configures the cell with a button.
+TEST(NativeAppItemTest, State_Install) {
+ NativeAppItem* item = [[NativeAppItem alloc] initWithType:0];
+ item.state = NativeAppItemInstall;
+ NativeAppCell* appCell = [[[item cellClass] alloc] init];
+ [item configureCell:appCell];
+
+ EXPECT_EQ((UIView*)appCell.installButton, appCell.accessoryView);
+}
+
+} // namespace
« 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