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

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

Issue 2774663002: [Remote suggestions] Refactor the scheduler (Closed)
Patch Set: Marc's nits #2 Created 3 years, 8 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 <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
17 #include "base/time/default_clock.h"
17 #include "components/ntp_snippets/category_info.h" 18 #include "components/ntp_snippets/category_info.h"
18 #include "components/ntp_snippets/category_rankers/constant_category_ranker.h" 19 #include "components/ntp_snippets/category_rankers/constant_category_ranker.h"
19 #include "components/ntp_snippets/category_rankers/fake_category_ranker.h" 20 #include "components/ntp_snippets/category_rankers/fake_category_ranker.h"
20 #include "components/ntp_snippets/category_rankers/mock_category_ranker.h" 21 #include "components/ntp_snippets/category_rankers/mock_category_ranker.h"
21 #include "components/ntp_snippets/category_status.h" 22 #include "components/ntp_snippets/category_status.h"
22 #include "components/ntp_snippets/content_suggestion.h" 23 #include "components/ntp_snippets/content_suggestion.h"
23 #include "components/ntp_snippets/content_suggestions_provider.h" 24 #include "components/ntp_snippets/content_suggestions_provider.h"
24 #include "components/ntp_snippets/mock_content_suggestions_provider.h" 25 #include "components/ntp_snippets/mock_content_suggestions_provider.h"
25 #include "components/ntp_snippets/user_classifier.h" 26 #include "components/ntp_snippets/user_classifier.h"
26 #include "components/prefs/testing_pref_service.h" 27 #include "components/prefs/testing_pref_service.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 140
140 protected: 141 protected:
141 void RegisterPrefs() { 142 void RegisterPrefs() {
142 ContentSuggestionsService::RegisterProfilePrefs(pref_service_->registry()); 143 ContentSuggestionsService::RegisterProfilePrefs(pref_service_->registry());
143 UserClassifier::RegisterProfilePrefs(pref_service_->registry()); 144 UserClassifier::RegisterProfilePrefs(pref_service_->registry());
144 } 145 }
145 146
146 void CreateContentSuggestionsService( 147 void CreateContentSuggestionsService(
147 ContentSuggestionsService::State enabled) { 148 ContentSuggestionsService::State enabled) {
148 ASSERT_FALSE(service_); 149 ASSERT_FALSE(service_);
150
151 // TODO(jkrcal): Replace by a mock.
152 auto user_classifier = base::MakeUnique<UserClassifier>(
153 pref_service_.get(), base::MakeUnique<base::DefaultClock>());
154
149 service_ = base::MakeUnique<ContentSuggestionsService>( 155 service_ = base::MakeUnique<ContentSuggestionsService>(
150 enabled, /*signin_manager=*/nullptr, /*history_service=*/nullptr, 156 enabled, /*signin_manager=*/nullptr, /*history_service=*/nullptr,
151 pref_service_.get(), std::move(category_ranker_)); 157 pref_service_.get(), std::move(category_ranker_),
158 std::move(user_classifier), /*scheduler=*/nullptr);
152 } 159 }
153 160
154 void ResetService() { 161 void ResetService() {
155 service_->Shutdown(); 162 service_->Shutdown();
156 service_.reset(); 163 service_.reset();
157 CreateContentSuggestionsService(ContentSuggestionsService::State::ENABLED); 164 CreateContentSuggestionsService(ContentSuggestionsService::State::ENABLED);
158 } 165 }
159 166
160 ContentSuggestionsService* service() { return service_.get(); } 167 ContentSuggestionsService* service() { return service_.get(); }
161 168
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 Category category = Category::FromKnownCategory(KnownCategories::BOOKMARKS); 807 Category category = Category::FromKnownCategory(KnownCategories::BOOKMARKS);
801 MockContentSuggestionsProvider* provider = 808 MockContentSuggestionsProvider* provider =
802 MakeRegisteredMockProvider(category); 809 MakeRegisteredMockProvider(category);
803 provider->FireCategoryStatusChangedWithCurrentStatus(category); 810 provider->FireCategoryStatusChangedWithCurrentStatus(category);
804 811
805 EXPECT_CALL(*raw_mock_ranker, OnCategoryDismissed(category)); 812 EXPECT_CALL(*raw_mock_ranker, OnCategoryDismissed(category));
806 service()->DismissCategory(category); 813 service()->DismissCategory(category);
807 } 814 }
808 815
809 } // namespace ntp_snippets 816 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698