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

Side by Side Diff: components/ntp_snippets/remote/ntp_snippets_service_unittest.cc

Issue 2406573002: 📰 Persist category dismissals (Closed)
Patch Set: fix test 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/remote/ntp_snippets_service.h" 5 #include "components/ntp_snippets/remote/ntp_snippets_service.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 FakeContentSuggestionsProviderObserver() 303 FakeContentSuggestionsProviderObserver()
304 : loaded_(base::WaitableEvent::ResetPolicy::MANUAL, 304 : loaded_(base::WaitableEvent::ResetPolicy::MANUAL,
305 base::WaitableEvent::InitialState::NOT_SIGNALED) {} 305 base::WaitableEvent::InitialState::NOT_SIGNALED) {}
306 306
307 void OnNewSuggestions(ContentSuggestionsProvider* provider, 307 void OnNewSuggestions(ContentSuggestionsProvider* provider,
308 Category category, 308 Category category,
309 std::vector<ContentSuggestion> suggestions) override { 309 std::vector<ContentSuggestion> suggestions) override {
310 suggestions_[category] = std::move(suggestions); 310 suggestions_[category] = std::move(suggestions);
311 } 311 }
312 312
313 void OnNewSuggestionBatch(ContentSuggestionsProvider* provider,
314 SuggestionBatch suggestions) override {
315 for (auto it = suggestions.begin(); it != suggestions.end(); ++it) {
316 suggestions_[it->first] = std::move(it->second);
317 }
318 }
319
313 void OnCategoryStatusChanged(ContentSuggestionsProvider* provider, 320 void OnCategoryStatusChanged(ContentSuggestionsProvider* provider,
314 Category category, 321 Category category,
315 CategoryStatus new_status) override { 322 CategoryStatus new_status) override {
316 if (category.IsKnownCategory(KnownCategories::ARTICLES) && 323 if (category.IsKnownCategory(KnownCategories::ARTICLES) &&
317 IsCategoryStatusAvailable(new_status)) { 324 IsCategoryStatusAvailable(new_status)) {
318 loaded_.Signal(); 325 loaded_.Signal();
319 } 326 }
320 statuses_[category] = new_status; 327 statuses_[category] = new_status;
321 } 328 }
322 329
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 base::StringPrintf("http://localhost/snippet-id-%d", i))); 1279 base::StringPrintf("http://localhost/snippet-id-%d", i)));
1273 } 1280 }
1274 LoadFromJSONString(service.get(), GetTestJson(suggestions)); 1281 LoadFromJSONString(service.get(), GetTestJson(suggestions));
1275 // TODO(tschumann): We should probably trim out any additional results and 1282 // TODO(tschumann): We should probably trim out any additional results and
1276 // only serve the MaxSnippetCount items. 1283 // only serve the MaxSnippetCount items.
1277 EXPECT_THAT(service->GetSnippetsForTesting(articles_category()), 1284 EXPECT_THAT(service->GetSnippetsForTesting(articles_category()),
1278 SizeIs(service->GetMaxSnippetCountForTesting() + 1)); 1285 SizeIs(service->GetMaxSnippetCountForTesting() + 1));
1279 } 1286 }
1280 1287
1281 } // namespace ntp_snippets 1288 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698