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

Side by Side Diff: components/ntp_snippets/category_factory_unittest.cc

Issue 2406573002: 📰 Persist category dismissals (Closed)
Patch Set: rebase, address comments, add test Created 4 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/ntp_snippets/category_factory.h" 5 #include "components/ntp_snippets/category_factory.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "components/ntp_snippets/category.h" 10 #include "components/ntp_snippets/category.h"
11 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace ntp_snippets { 14 namespace ntp_snippets {
15 15
16 class CategoryFactoryTest : public testing::Test { 16 class CategoryFactoryTest : public testing::Test {
17 public: 17 public:
18 CategoryFactoryTest() : unused_remote_category_id_(1) {} 18 // Note: uses 2 as first remote category id as 1 is used for |ARTICLES|
19 CategoryFactoryTest() : unused_remote_category_id_(2) {}
Bernhard Bauer 2016/10/17 16:52:04 Nit: You could just use ARTICLES + 1 :)
dgn 2016/10/17 17:12:29 Done. Added LAST_KNOWN_REMOTE_CATEGORY for this.
19 20
20 int GetUnusedRemoteCategoryID() { return unused_remote_category_id_++; } 21 int GetUnusedRemoteCategoryID() { return unused_remote_category_id_++; }
21 22
22 bool CompareCategories(const Category& left, const Category& right) { 23 bool CompareCategories(const Category& left, const Category& right) {
23 return factory()->CompareCategories(left, right); 24 return factory()->CompareCategories(left, right);
24 } 25 }
25 26
26 void AddDummyRemoteCategories(int quantity) { 27 void AddDummyRemoteCategories(int quantity) {
27 for (int i = 0; i < quantity; ++i) { 28 for (int i = 0; i < quantity; ++i) {
28 factory()->FromRemoteCategory(GetUnusedRemoteCategoryID()); 29 factory()->FromRemoteCategory(GetUnusedRemoteCategoryID());
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 AddDummyRemoteCategories(3); 118 AddDummyRemoteCategories(3);
118 119
119 EXPECT_TRUE(CompareCategories(consequtive_first, consequtive_second)); 120 EXPECT_TRUE(CompareCategories(consequtive_first, consequtive_second));
120 EXPECT_FALSE(CompareCategories(consequtive_second, consequtive_first)); 121 EXPECT_FALSE(CompareCategories(consequtive_second, consequtive_first));
121 122
122 EXPECT_TRUE(CompareCategories(nonconsequtive_first, nonconsequtive_second)); 123 EXPECT_TRUE(CompareCategories(nonconsequtive_first, nonconsequtive_second));
123 EXPECT_FALSE(CompareCategories(nonconsequtive_second, nonconsequtive_first)); 124 EXPECT_FALSE(CompareCategories(nonconsequtive_second, nonconsequtive_first));
124 } 125 }
125 126
126 } // namespace ntp_snippets 127 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/category_factory.cc ('k') | components/ntp_snippets/content_suggestions_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698