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/content_suggestions_service_unittest.cc

Issue 2194203002: Make ContentSuggestionsService recognize new/removed categories (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@renaming
Patch Set: Marc's comments 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"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 69
70 Observer* observer() { return observer_; } 70 Observer* observer() { return observer_; }
71 71
72 void SetObserver(Observer* observer) override { observer_ = observer; } 72 void SetObserver(Observer* observer) override { observer_ = observer; }
73 73
74 CategoryStatus GetCategoryStatus(Category category) { 74 CategoryStatus GetCategoryStatus(Category category) {
75 return statuses_[category.id()]; 75 return statuses_[category.id()];
76 } 76 }
77 77
78 void FireSuggestionsChanged(Category category, std::vector<int> numbers) { 78 void FireSuggestionsChanged(Category category, std::vector<int> numbers) {
79 observer_->OnNewSuggestions(category, CreateSuggestions(numbers)); 79 observer_->OnNewSuggestions(this, category, CreateSuggestions(numbers));
80 } 80 }
81 81
82 void FireCategoryStatusChanged(Category category, CategoryStatus new_status) { 82 void FireCategoryStatusChanged(Category category, CategoryStatus new_status) {
83 statuses_[category.id()] = new_status; 83 statuses_[category.id()] = new_status;
84 observer_->OnCategoryStatusChanged(category, new_status); 84 observer_->OnCategoryStatusChanged(this, category, new_status);
85 } 85 }
86 86
87 void FireShutdown() { 87 void FireShutdown() {
88 observer_->OnProviderShutdown(this); 88 observer_->OnProviderShutdown(this);
89 observer_ = nullptr; 89 observer_ = nullptr;
90 } 90 }
91 91
92 MOCK_METHOD0(ClearCachedSuggestionsForDebugging, void()); 92 MOCK_METHOD0(ClearCachedSuggestionsForDebugging, void());
93 MOCK_METHOD0(ClearDismissedSuggestionsForDebugging, void()); 93 MOCK_METHOD0(ClearDismissedSuggestionsForDebugging, void());
94 MOCK_METHOD1(DismissSuggestion, void(const std::string& suggestion_id)); 94 MOCK_METHOD1(DismissSuggestion, void(const std::string& suggestion_id));
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 for (int number : numbers) { 149 for (int number : numbers) {
150 ADD_FAILURE() << "Suggestion number " << number 150 ADD_FAILURE() << "Suggestion number " << number
151 << " not present, though expected"; 151 << " not present, though expected";
152 } 152 }
153 } 153 }
154 154
155 const std::map<Category, 155 const std::map<Category,
156 ContentSuggestionsProvider*, 156 ContentSuggestionsProvider*,
157 ContentSuggestionsService::CompareCategoriesByID>& 157 ContentSuggestionsService::CompareCategoriesByID>&
158 providers() { 158 providers() {
159 return service()->providers_; 159 return service()->providers_by_category_;
160 } 160 }
161 161
162 CategoryFactory* category_factory() { return service()->category_factory(); } 162 CategoryFactory* category_factory() { return service()->category_factory(); }
163 163
164 Category FromKnownCategory(KnownCategories known_category) { 164 Category FromKnownCategory(KnownCategories known_category) {
165 return service()->category_factory()->FromKnownCategory(known_category); 165 return service()->category_factory()->FromKnownCategory(known_category);
166 } 166 }
167 167
168 MOCK_METHOD2(OnImageFetched, 168 MOCK_METHOD2(OnImageFetched,
169 void(const std::string& suggestion_id, const gfx::Image&)); 169 void(const std::string& suggestion_id, const gfx::Image&));
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 Eq(CategoryStatus::NOT_PROVIDED)); 400 Eq(CategoryStatus::NOT_PROVIDED));
401 401
402 // Shutdown the service 402 // Shutdown the service
403 EXPECT_CALL(observer, ContentSuggestionsServiceShutdown()); 403 EXPECT_CALL(observer, ContentSuggestionsServiceShutdown());
404 service()->Shutdown(); 404 service()->Shutdown();
405 service()->RemoveObserver(&observer); 405 service()->RemoveObserver(&observer);
406 // The service will receive two Shutdown() calls. 406 // The service will receive two Shutdown() calls.
407 } 407 }
408 408
409 } // namespace ntp_snippets 409 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/content_suggestions_service.cc ('k') | components/ntp_snippets/ntp_snippets_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698