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

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

Issue 2284393002: Add ClearHistory() to ContentSuggestionsService and its providers (Closed)
Patch Set: msramek@'s comments and filter. Created 4 years, 3 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 void FireCategoryStatusChangedWithCurrentStatus(Category category) { 93 void FireCategoryStatusChangedWithCurrentStatus(Category category) {
94 observer()->OnCategoryStatusChanged(this, category, 94 observer()->OnCategoryStatusChanged(this, category,
95 statuses_[category.id()]); 95 statuses_[category.id()]);
96 } 96 }
97 97
98 void FireSuggestionInvalidated(Category category, 98 void FireSuggestionInvalidated(Category category,
99 const std::string& suggestion_id) { 99 const std::string& suggestion_id) {
100 observer()->OnSuggestionInvalidated(this, category, suggestion_id); 100 observer()->OnSuggestionInvalidated(this, category, suggestion_id);
101 } 101 }
102 102
103 MOCK_METHOD3(ClearHistory,
104 void(base::Time begin,
105 base::Time end,
106 base::Callback<bool(const GURL& url)> filter));
103 MOCK_METHOD1(ClearCachedSuggestions, void(Category category)); 107 MOCK_METHOD1(ClearCachedSuggestions, void(Category category));
104 MOCK_METHOD2(GetDismissedSuggestionsForDebugging, 108 MOCK_METHOD2(GetDismissedSuggestionsForDebugging,
105 void(Category category, 109 void(Category category,
106 const DismissedSuggestionsCallback& callback)); 110 const DismissedSuggestionsCallback& callback));
107 MOCK_METHOD1(ClearDismissedSuggestionsForDebugging, void(Category category)); 111 MOCK_METHOD1(ClearDismissedSuggestionsForDebugging, void(Category category));
108 MOCK_METHOD1(DismissSuggestion, void(const std::string& suggestion_id)); 112 MOCK_METHOD1(DismissSuggestion, void(const std::string& suggestion_id));
109 MOCK_METHOD2(FetchSuggestionImage, 113 MOCK_METHOD2(FetchSuggestionImage,
110 void(const std::string& suggestion_id, 114 void(const std::string& suggestion_id,
111 const ImageFetchedCallback& callback)); 115 const ImageFetchedCallback& callback));
112 116
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 562
559 // Same thing, but now the bookmarks category updates "naturally". 563 // Same thing, but now the bookmarks category updates "naturally".
560 bookmarks_provider->FireSuggestionsChanged(bookmarks, {1, 2}); 564 bookmarks_provider->FireSuggestionsChanged(bookmarks, {1, 2});
561 EXPECT_THAT(service()->GetCategories(), ElementsAre(bookmarks, remote)); 565 EXPECT_THAT(service()->GetCategories(), ElementsAre(bookmarks, remote));
562 bookmarks_provider->FireSuggestionsChanged(bookmarks, {1}); 566 bookmarks_provider->FireSuggestionsChanged(bookmarks, {1});
563 EXPECT_THAT(service()->GetCategories(), ElementsAre(bookmarks, remote)); 567 EXPECT_THAT(service()->GetCategories(), ElementsAre(bookmarks, remote));
564 bookmarks_provider->FireSuggestionsChanged(bookmarks, std::vector<int>()); 568 bookmarks_provider->FireSuggestionsChanged(bookmarks, std::vector<int>());
565 EXPECT_THAT(service()->GetCategories(), ElementsAre(remote, bookmarks)); 569 EXPECT_THAT(service()->GetCategories(), ElementsAre(remote, bookmarks));
566 } 570 }
567 571
572 TEST_F(ContentSuggestionsServiceTest, ShouldForwardClearHistory) {
573 Category category = FromKnownCategory(KnownCategories::DOWNLOADS);
574 MockProvider* provider = RegisterProvider(category);
575 base::Time begin = base::Time::FromTimeT(123),
576 end = base::Time::FromTimeT(456);
577 EXPECT_CALL(*provider, ClearHistory(begin, end, _));
578 base::Callback<bool(const GURL& url)> filter;
579 service()->ClearHistory(begin, end, filter);
580 }
581
568 } // namespace ntp_snippets 582 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698