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

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

Issue 2406573002: 📰 Persist category dismissals (Closed)
Patch Set: fix nits 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 CategoryFactoryTest()
19 : unused_remote_category_id_(
20 static_cast<int>(KnownCategories::LAST_KNOWN_REMOTE_CATEGORY) + 1) {
21 }
19 22
20 int GetUnusedRemoteCategoryID() { return unused_remote_category_id_++; } 23 int GetUnusedRemoteCategoryID() { return unused_remote_category_id_++; }
21 24
22 bool CompareCategories(const Category& left, const Category& right) { 25 bool CompareCategories(const Category& left, const Category& right) {
23 return factory()->CompareCategories(left, right); 26 return factory()->CompareCategories(left, right);
24 } 27 }
25 28
26 void AddDummyRemoteCategories(int quantity) { 29 void AddDummyRemoteCategories(int quantity) {
27 for (int i = 0; i < quantity; ++i) { 30 for (int i = 0; i < quantity; ++i) {
28 factory()->FromRemoteCategory(GetUnusedRemoteCategoryID()); 31 factory()->FromRemoteCategory(GetUnusedRemoteCategoryID());
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 AddDummyRemoteCategories(3); 120 AddDummyRemoteCategories(3);
118 121
119 EXPECT_TRUE(CompareCategories(consequtive_first, consequtive_second)); 122 EXPECT_TRUE(CompareCategories(consequtive_first, consequtive_second));
120 EXPECT_FALSE(CompareCategories(consequtive_second, consequtive_first)); 123 EXPECT_FALSE(CompareCategories(consequtive_second, consequtive_first));
121 124
122 EXPECT_TRUE(CompareCategories(nonconsequtive_first, nonconsequtive_second)); 125 EXPECT_TRUE(CompareCategories(nonconsequtive_first, nonconsequtive_second));
123 EXPECT_FALSE(CompareCategories(nonconsequtive_second, nonconsequtive_first)); 126 EXPECT_FALSE(CompareCategories(nonconsequtive_second, nonconsequtive_first));
124 } 127 }
125 128
126 } // namespace ntp_snippets 129 } // 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