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

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

Issue 2421463002: FetchMore functionality backend (Closed)
Patch Set: ID set reference, Optional callback, ... (2466863003 comments). Created 4 years, 1 month 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
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 } 81 }
82 82
83 void FireSuggestionInvalidated(const ContentSuggestion::ID& suggestion_id) { 83 void FireSuggestionInvalidated(const ContentSuggestion::ID& suggestion_id) {
84 observer()->OnSuggestionInvalidated(this, suggestion_id); 84 observer()->OnSuggestionInvalidated(this, suggestion_id);
85 } 85 }
86 86
87 MOCK_METHOD3(ClearHistory, 87 MOCK_METHOD3(ClearHistory,
88 void(base::Time begin, 88 void(base::Time begin,
89 base::Time end, 89 base::Time end,
90 const base::Callback<bool(const GURL& url)>& filter)); 90 const base::Callback<bool(const GURL& url)>& filter));
91 MOCK_METHOD3(Fetch,
92 void(const Category&,
93 const std::set<std::string>&,
94 FetchingCallback));
91 MOCK_METHOD1(ClearCachedSuggestions, void(Category category)); 95 MOCK_METHOD1(ClearCachedSuggestions, void(Category category));
92 MOCK_METHOD2(GetDismissedSuggestionsForDebugging, 96 MOCK_METHOD2(GetDismissedSuggestionsForDebugging,
93 void(Category category, 97 void(Category category,
94 const DismissedSuggestionsCallback& callback)); 98 const DismissedSuggestionsCallback& callback));
95 MOCK_METHOD1(ClearDismissedSuggestionsForDebugging, void(Category category)); 99 MOCK_METHOD1(ClearDismissedSuggestionsForDebugging, void(Category category));
96 MOCK_METHOD1(DismissSuggestion, 100 MOCK_METHOD1(DismissSuggestion,
97 void(const ContentSuggestion::ID& suggestion_id)); 101 void(const ContentSuggestion::ID& suggestion_id));
98 MOCK_METHOD2(FetchSuggestionImage, 102 MOCK_METHOD2(FetchSuggestionImage,
99 void(const ContentSuggestion::ID& suggestion_id, 103 void(const ContentSuggestion::ID& suggestion_id,
100 const ImageFetchedCallback& callback)); 104 const ImageFetchedCallback& callback));
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 TEST_F(ContentSuggestionsServiceTest, ShouldForwardClearHistory) { 572 TEST_F(ContentSuggestionsServiceTest, ShouldForwardClearHistory) {
569 Category category = FromKnownCategory(KnownCategories::DOWNLOADS); 573 Category category = FromKnownCategory(KnownCategories::DOWNLOADS);
570 MockProvider* provider = RegisterProvider(category); 574 MockProvider* provider = RegisterProvider(category);
571 base::Time begin = base::Time::FromTimeT(123), 575 base::Time begin = base::Time::FromTimeT(123),
572 end = base::Time::FromTimeT(456); 576 end = base::Time::FromTimeT(456);
573 EXPECT_CALL(*provider, ClearHistory(begin, end, _)); 577 EXPECT_CALL(*provider, ClearHistory(begin, end, _));
574 base::Callback<bool(const GURL& url)> filter; 578 base::Callback<bool(const GURL& url)> filter;
575 service()->ClearHistory(begin, end, filter); 579 service()->ClearHistory(begin, end, filter);
576 } 580 }
577 581
582 TEST_F(ContentSuggestionsServiceTest, ShouldForwardFetch) {
583 Category category = FromKnownCategory(KnownCategories::ARTICLES);
584 std::set<std::string> known_suggestions;
585 MockProvider* provider = RegisterProvider(category);
586 provider->FireCategoryStatusChangedWithCurrentStatus(category);
587 EXPECT_CALL(*provider, Fetch(category, known_suggestions, _));
588 service()->Fetch(category, known_suggestions,
589 ContentSuggestionsService::FetchingCallback());
590 }
591
578 TEST_F(ContentSuggestionsServiceTest, DismissAndRestoreCategory) { 592 TEST_F(ContentSuggestionsServiceTest, DismissAndRestoreCategory) {
579 // Register a category with one suggestion. 593 // Register a category with one suggestion.
580 Category category = FromKnownCategory(KnownCategories::ARTICLES); 594 Category category = FromKnownCategory(KnownCategories::ARTICLES);
581 MockProvider* provider = RegisterProvider(category); 595 MockProvider* provider = RegisterProvider(category);
582 provider->FireCategoryStatusChangedWithCurrentStatus(category); 596 provider->FireCategoryStatusChangedWithCurrentStatus(category);
583 provider->FireSuggestionsChanged(category, CreateSuggestions(category, {42})); 597 provider->FireSuggestionsChanged(category, CreateSuggestions(category, {42}));
584 598
585 EXPECT_THAT(service()->GetCategories(), ElementsAre(category)); 599 EXPECT_THAT(service()->GetCategories(), ElementsAre(category));
586 EXPECT_THAT(service()->GetCategoryStatus(category), 600 EXPECT_THAT(service()->GetCategoryStatus(category),
587 Eq(CategoryStatus::AVAILABLE)); 601 Eq(CategoryStatus::AVAILABLE));
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 provider = RegisterProvider(category); 697 provider = RegisterProvider(category);
684 provider->FireCategoryStatusChangedWithCurrentStatus(category); 698 provider->FireCategoryStatusChangedWithCurrentStatus(category);
685 EXPECT_TRUE(service()->IsCategoryDismissed(category)); 699 EXPECT_TRUE(service()->IsCategoryDismissed(category));
686 700
687 service()->RestoreDismissedCategories(); 701 service()->RestoreDismissedCategories();
688 EXPECT_FALSE(service()->IsCategoryDismissed(category)); 702 EXPECT_FALSE(service()->IsCategoryDismissed(category));
689 EXPECT_THAT(providers().find(category)->second, Eq(provider)); 703 EXPECT_THAT(providers().find(category)->second, Eq(provider));
690 } 704 }
691 705
692 } // namespace ntp_snippets 706 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698