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

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

Issue 2207493002: Add CategoryInfo for meta information of content suggestions Categories (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DCHECK against empty base::Optional<CategoryInfo> in SnippetsInternals Created 4 years, 4 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/content_suggestions_service.h" 5 #include "components/ntp_snippets/content_suggestions_service.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/utf_string_conversions.h"
17 #include "components/ntp_snippets/category_info.h"
16 #include "components/ntp_snippets/category_status.h" 18 #include "components/ntp_snippets/category_status.h"
17 #include "components/ntp_snippets/content_suggestion.h" 19 #include "components/ntp_snippets/content_suggestion.h"
18 #include "components/ntp_snippets/content_suggestions_provider.h" 20 #include "components/ntp_snippets/content_suggestions_provider.h"
19 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
20 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
21 #include "ui/gfx/image/image.h" 23 #include "ui/gfx/image/image.h"
22 24
23 using testing::ByRef; 25 using testing::ByRef;
24 using testing::Const; 26 using testing::Const;
25 using testing::ElementsAre; 27 using testing::ElementsAre;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 } 66 }
65 67
66 std::vector<Category> GetProvidedCategories() override { 68 std::vector<Category> GetProvidedCategories() override {
67 return provided_categories_; 69 return provided_categories_;
68 } 70 }
69 71
70 CategoryStatus GetCategoryStatus(Category category) { 72 CategoryStatus GetCategoryStatus(Category category) {
71 return statuses_[category.id()]; 73 return statuses_[category.id()];
72 } 74 }
73 75
76 CategoryInfo GetCategoryInfo(Category category) {
77 return CategoryInfo(base::ASCIIToUTF16("Section title"),
78 ContentSuggestionsCardLayout::FULL_CARD);
79 }
80
74 void FireSuggestionsChanged(Category category, std::vector<int> numbers) { 81 void FireSuggestionsChanged(Category category, std::vector<int> numbers) {
75 observer()->OnNewSuggestions(this, category, CreateSuggestions(numbers)); 82 observer()->OnNewSuggestions(this, category, CreateSuggestions(numbers));
76 } 83 }
77 84
78 void FireCategoryStatusChanged(Category category, CategoryStatus new_status) { 85 void FireCategoryStatusChanged(Category category, CategoryStatus new_status) {
79 statuses_[category.id()] = new_status; 86 statuses_[category.id()] = new_status;
80 observer()->OnCategoryStatusChanged(this, category, new_status); 87 observer()->OnCategoryStatusChanged(this, category, new_status);
81 } 88 }
82 89
83 MOCK_METHOD1(ClearCachedSuggestionsForDebugging, void(Category category)); 90 MOCK_METHOD1(ClearCachedSuggestionsForDebugging, void(Category category));
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 Mock::VerifyAndClearExpectations(&observer); 359 Mock::VerifyAndClearExpectations(&observer);
353 360
354 // Shutdown the service 361 // Shutdown the service
355 EXPECT_CALL(observer, ContentSuggestionsServiceShutdown()); 362 EXPECT_CALL(observer, ContentSuggestionsServiceShutdown());
356 service()->Shutdown(); 363 service()->Shutdown();
357 service()->RemoveObserver(&observer); 364 service()->RemoveObserver(&observer);
358 // The service will receive two Shutdown() calls. 365 // The service will receive two Shutdown() calls.
359 } 366 }
360 367
361 } // namespace ntp_snippets 368 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/content_suggestions_service.cc ('k') | components/ntp_snippets/ntp_snippets_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698