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

Unified Diff: ios/chrome/browser/content_suggestions/content_suggestions_category_wrapper_unittest.mm

Issue 2689953003: Add Category wrapper for ContentSuggestions on iOS (Closed)
Patch Set: Add include Created 3 years, 10 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/content_suggestions/content_suggestions_category_wrapper_unittest.mm
diff --git a/ios/chrome/browser/content_suggestions/content_suggestions_category_wrapper_unittest.mm b/ios/chrome/browser/content_suggestions/content_suggestions_category_wrapper_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..9f06ba86ec53ecfa79cab4483cee9ea17678a384
--- /dev/null
+++ b/ios/chrome/browser/content_suggestions/content_suggestions_category_wrapper_unittest.mm
@@ -0,0 +1,49 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
stkhapugin 2017/02/13 12:19:18 Excellent unit tests, thank you.
gambard 2017/02/13 14:51:41 :)
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ios/chrome/browser/content_suggestions/content_suggestions_category_wrapper.h"
+
+#include "components/ntp_snippets/category.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+// Tests that the category returned by the wrapper is the one given in the
+// initializer.
+TEST(ContentSuggestionsCategoryWrapperTest, GetCategory) {
+ ntp_snippets::Category category = ntp_snippets::Category::FromIDValue(2);
+ ContentSuggestionsCategoryWrapper* wrapper =
+ [[ContentSuggestionsCategoryWrapper alloc] initWithCategory:category];
+
+ EXPECT_EQ(category, wrapper.category);
+}
+
+// Tests that two wrappers created with equal categories are equal.
+TEST(ContentSuggestionsCategoryWrapperTest, AreWrappersEqual) {
+ ntp_snippets::Category category = ntp_snippets::Category::FromIDValue(2);
+ ContentSuggestionsCategoryWrapper* wrapper =
+ [[ContentSuggestionsCategoryWrapper alloc] initWithCategory:category];
+ ntp_snippets::Category category2 = ntp_snippets::Category::FromIDValue(2);
+ ContentSuggestionsCategoryWrapper* wrapper2 =
+ [[ContentSuggestionsCategoryWrapper alloc] initWithCategory:category2];
+ ASSERT_EQ(category, category2);
+
+ EXPECT_TRUE([wrapper isEqual:wrapper2]);
+ EXPECT_EQ(wrapper.hash, wrapper2.hash);
+}
+
+// Tests that two wrappers created with different categories are not equal.
+TEST(ContentSuggestionsCategoryWrapperTest, AreWrappersDifferent) {
+ ntp_snippets::Category category = ntp_snippets::Category::FromIDValue(2);
+ ContentSuggestionsCategoryWrapper* wrapper =
+ [[ContentSuggestionsCategoryWrapper alloc] initWithCategory:category];
+ ntp_snippets::Category category2 = ntp_snippets::Category::FromIDValue(3);
+ ContentSuggestionsCategoryWrapper* wrapper2 =
+ [[ContentSuggestionsCategoryWrapper alloc] initWithCategory:category2];
+ ASSERT_NE(category, category2);
+
+ EXPECT_FALSE([wrapper isEqual:wrapper2]);
+}
lpromero 2017/02/13 12:34:55 Add a test that exercises the class check in the i
gambard 2017/02/13 14:51:41 Done.

Powered by Google App Engine
This is Rietveld 408576698