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

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: Put the status-change notification back in RegisterProvider() 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 305 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

Powered by Google App Engine
This is Rietveld 408576698