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

Unified Diff: ios/chrome/browser/ui/autofill/cells/storage_switch_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/storage_switch_item_unittest.mm
diff --git a/ios/chrome/browser/ui/autofill/cells/storage_switch_item_unittest.mm b/ios/chrome/browser/ui/autofill/cells/storage_switch_item_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..bb2aed40e2c10096f4fb55006cb5047c20fe1466
--- /dev/null
+++ b/ios/chrome/browser/ui/autofill/cells/storage_switch_item_unittest.mm
@@ -0,0 +1,56 @@
+// 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/storage_switch_item.h"
+
+#include "base/mac/foundation_util.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+namespace {
+
+// Tests that the label and switch values are set properly after a call to
+// |configureCell:|.
+TEST(StorageSwitchItemTest, ConfigureCell) {
+ StorageSwitchItem* item = [[StorageSwitchItem alloc] initWithType:0];
+ item.on = YES;
+
+ id cell = [[[item cellClass] alloc] init];
+ ASSERT_TRUE([cell isMemberOfClass:[StorageSwitchCell class]]);
+
+ StorageSwitchCell* switchCell =
+ base::mac::ObjCCastStrict<StorageSwitchCell>(cell);
+ EXPECT_TRUE(switchCell.textLabel.text);
+ EXPECT_FALSE(switchCell.switchView.on);
+
+ [item configureCell:cell];
+ EXPECT_TRUE(switchCell.switchView.on);
+}
+
+TEST(StorageSwitchItemTest, PrepareForReuseClearsActions) {
+ StorageSwitchCell* cell = [[StorageSwitchCell alloc] init];
+ UIButton* tooltipButton = cell.tooltipButton;
+ UISwitch* switchView = cell.switchView;
+ NSArray* target = [NSArray array];
+
+ EXPECT_EQ(0U, [[tooltipButton allTargets] count]);
+ EXPECT_EQ(0U, [[switchView allTargets] count]);
+ [tooltipButton addTarget:target
+ action:@selector(count)
+ forControlEvents:UIControlEventTouchUpInside];
+ [switchView addTarget:target
+ action:@selector(count)
+ forControlEvents:UIControlEventValueChanged];
+ EXPECT_EQ(1U, [[tooltipButton allTargets] count]);
+ EXPECT_EQ(1U, [[switchView allTargets] count]);
+
+ [cell prepareForReuse];
+ EXPECT_EQ(0U, [[tooltipButton allTargets] count]);
+ EXPECT_EQ(0U, [[switchView allTargets] count]);
+}
+
+} // namespace
« no previous file with comments | « ios/chrome/browser/ui/autofill/cells/storage_switch_item.mm ('k') | ios/chrome/browser/ui/autofill/storage_switch_tooltip.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698