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

Unified Diff: ios/chrome/browser/ui/content_suggestions/content_suggestions_footer_item_unittest.mm

Issue 2749543002: Add a footer item for the Content Suggestions (Closed)
Patch Set: Fix gn Created 3 years, 9 months 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/content_suggestions/content_suggestions_footer_item_unittest.mm
diff --git a/ios/chrome/browser/ui/content_suggestions/content_suggestions_footer_item_unittest.mm b/ios/chrome/browser/ui/content_suggestions/content_suggestions_footer_item_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..f26c69bd62364a55e35a6c5dd11c23db93ab5735
--- /dev/null
+++ b/ios/chrome/browser/ui/content_suggestions/content_suggestions_footer_item_unittest.mm
@@ -0,0 +1,64 @@
+// Copyright 2017 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/content_suggestions/content_suggestions_footer_item.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+#import "third_party/ocmock/OCMock/OCMock.h"
+#import "third_party/ocmock/gtest_support.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+namespace {
+
+// Tests that configureCell: sets the title of the button and the action.
+TEST(ContentSuggestionsFooterItemTest, CellIsConfigured) {
+ // Setup.
+ NSString* title = @"testTitle";
+ __block BOOL hasBeenCalled = NO;
+ ProceduralBlock block = ^void() {
+ hasBeenCalled = YES;
+ };
+ ContentSuggestionsFooterItem* item =
+ [[ContentSuggestionsFooterItem alloc] initWithType:0
+ title:title
+ block:block];
+ ContentSuggestionsFooterCell* cell = [[[item cellClass] alloc] init];
+ ASSERT_EQ([ContentSuggestionsFooterCell class], [cell class]);
+ ASSERT_EQ(nil, [cell.button titleForState:UIControlStateNormal]);
+
+ // Action.
+ [item configureCell:cell];
+
+ // Tests.
+ ASSERT_EQ(title, [cell.button titleForState:UIControlStateNormal]);
+ ASSERT_FALSE(hasBeenCalled);
+ [cell.button sendActionsForControlEvents:UIControlEventTouchUpInside];
+ ASSERT_TRUE(hasBeenCalled);
+}
+
+// Tests that when the cell is reused the button's block is removed.
+TEST(ContentSuggestionsFooterItemTest, ReuseCell) {
+ __block BOOL hasBeenCalled = NO;
+ ProceduralBlock block = ^void() {
+ hasBeenCalled = YES;
+ };
+ ContentSuggestionsFooterItem* item =
+ [[ContentSuggestionsFooterItem alloc] initWithType:0
+ title:@""
+ block:block];
+ ContentSuggestionsFooterCell* cell = [[[item cellClass] alloc] init];
+ [item configureCell:cell];
+
+ // Action.
+ [cell prepareForReuse];
+
+ // Test.
+ ASSERT_FALSE(hasBeenCalled);
+ [cell.button sendActionsForControlEvents:UIControlEventTouchUpInside];
+ ASSERT_FALSE(hasBeenCalled);
+}
+}
« no previous file with comments | « ios/chrome/browser/ui/content_suggestions/content_suggestions_footer_item.mm ('k') | ios/chrome/browser/ui/settings/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698