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

Side by Side Diff: components/ntp_snippets/bookmarks/bookmark_suggestions_provider.cc

Issue 2618243004: Add a unit test for the BookmarkSuggestionsProvider. (Closed)
Patch Set: renamed MockProvider and updated tests comments about expected behavior Created 3 years, 11 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/bookmarks/bookmark_suggestions_provider.h" 5 #include "components/ntp_snippets/bookmarks/bookmark_suggestions_provider.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 std::vector<ContentSuggestion> suggestions; 298 std::vector<ContentSuggestion> suggestions;
299 for (const BookmarkNode* bookmark : bookmarks) { 299 for (const BookmarkNode* bookmark : bookmarks) {
300 ConvertBookmark(*bookmark, &suggestions); 300 ConvertBookmark(*bookmark, &suggestions);
301 } 301 }
302 302
303 if (suggestions.empty()) { 303 if (suggestions.empty()) {
304 end_of_list_last_visit_date_ = threshold_time; 304 end_of_list_last_visit_date_ = threshold_time;
305 } else { 305 } else {
306 end_of_list_last_visit_date_ = suggestions.back().publish_date(); 306 end_of_list_last_visit_date_ = suggestions.back().publish_date();
307 } 307 }
308
309 observer()->OnNewSuggestions(this, provided_category_, 308 observer()->OnNewSuggestions(this, provided_category_,
310 std::move(suggestions)); 309 std::move(suggestions));
311 } 310 }
312 311
313 void BookmarkSuggestionsProvider::FetchBookmarks() { 312 void BookmarkSuggestionsProvider::FetchBookmarks() {
314 if (bookmark_model_->loaded()) { 313 if (bookmark_model_->loaded()) {
315 FetchBookmarksInternal(); 314 FetchBookmarksInternal();
316 } else { 315 } else {
317 fetch_requested_ = true; 316 fetch_requested_ = true;
318 } 317 }
319 } 318 }
320 319
321 void BookmarkSuggestionsProvider::NotifyStatusChanged( 320 void BookmarkSuggestionsProvider::NotifyStatusChanged(
322 CategoryStatus new_status) { 321 CategoryStatus new_status) {
323 if (category_status_ == new_status) { 322 if (category_status_ == new_status) {
324 return; 323 return;
325 } 324 }
326 category_status_ = new_status; 325 category_status_ = new_status;
327 observer()->OnCategoryStatusChanged(this, provided_category_, new_status); 326 observer()->OnCategoryStatusChanged(this, provided_category_, new_status);
328 } 327 }
329 328
330 } // namespace ntp_snippets 329 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/BUILD.gn ('k') | components/ntp_snippets/bookmarks/bookmark_suggestions_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698