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

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

Issue 2421463002: FetchMore functionality backend (Closed)
Patch Set: NTBR. Rebasing a lot. 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_METHOD2(FetchMore, void(const Category&, const FetchedMoreCallback&));
91 MOCK_METHOD1(ClearCachedSuggestions, void(Category category)); 92 MOCK_METHOD1(ClearCachedSuggestions, void(Category category));
92 MOCK_METHOD2(GetDismissedSuggestionsForDebugging, 93 MOCK_METHOD2(GetDismissedSuggestionsForDebugging,
93 void(Category category, 94 void(Category category,
94 const DismissedSuggestionsCallback& callback)); 95 const DismissedSuggestionsCallback& callback));
95 MOCK_METHOD1(ClearDismissedSuggestionsForDebugging, void(Category category)); 96 MOCK_METHOD1(ClearDismissedSuggestionsForDebugging, void(Category category));
96 MOCK_METHOD1(DismissSuggestion, 97 MOCK_METHOD1(DismissSuggestion,
97 void(const ContentSuggestion::ID& suggestion_id)); 98 void(const ContentSuggestion::ID& suggestion_id));
98 MOCK_METHOD2(FetchSuggestionImage, 99 MOCK_METHOD2(FetchSuggestionImage,
99 void(const ContentSuggestion::ID& suggestion_id, 100 void(const ContentSuggestion::ID& suggestion_id,
100 const ImageFetchedCallback& callback)); 101 const ImageFetchedCallback& callback));
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 TEST_F(ContentSuggestionsServiceTest, ShouldForwardClearHistory) { 569 TEST_F(ContentSuggestionsServiceTest, ShouldForwardClearHistory) {
569 Category category = FromKnownCategory(KnownCategories::DOWNLOADS); 570 Category category = FromKnownCategory(KnownCategories::DOWNLOADS);
570 MockProvider* provider = RegisterProvider(category); 571 MockProvider* provider = RegisterProvider(category);
571 base::Time begin = base::Time::FromTimeT(123), 572 base::Time begin = base::Time::FromTimeT(123),
572 end = base::Time::FromTimeT(456); 573 end = base::Time::FromTimeT(456);
573 EXPECT_CALL(*provider, ClearHistory(begin, end, _)); 574 EXPECT_CALL(*provider, ClearHistory(begin, end, _));
574 base::Callback<bool(const GURL& url)> filter; 575 base::Callback<bool(const GURL& url)> filter;
575 service()->ClearHistory(begin, end, filter); 576 service()->ClearHistory(begin, end, filter);
576 } 577 }
577 578
579 TEST_F(ContentSuggestionsServiceTest, ShouldForwardFetchMore) {
580 Category category = FromKnownCategory(KnownCategories::ARTICLES);
581 MockProvider* provider = RegisterProvider(category);
582 provider->FireCategoryStatusChangedWithCurrentStatus(category);
583 EXPECT_CALL(*provider, FetchMore(category, _));
584 service()->FetchMore(category,
585 ContentSuggestionsService::FetchedMoreCallback());
586 }
587
578 TEST_F(ContentSuggestionsServiceTest, DismissAndRestoreCategory) { 588 TEST_F(ContentSuggestionsServiceTest, DismissAndRestoreCategory) {
579 // Register a category with one suggestion. 589 // Register a category with one suggestion.
580 Category category = FromKnownCategory(KnownCategories::ARTICLES); 590 Category category = FromKnownCategory(KnownCategories::ARTICLES);
581 MockProvider* provider = RegisterProvider(category); 591 MockProvider* provider = RegisterProvider(category);
582 provider->FireCategoryStatusChangedWithCurrentStatus(category); 592 provider->FireCategoryStatusChangedWithCurrentStatus(category);
583 provider->FireSuggestionsChanged(category, CreateSuggestions(category, {42})); 593 provider->FireSuggestionsChanged(category, CreateSuggestions(category, {42}));
584 594
585 EXPECT_THAT(service()->GetCategories(), ElementsAre(category)); 595 EXPECT_THAT(service()->GetCategories(), ElementsAre(category));
586 EXPECT_THAT(service()->GetCategoryStatus(category), 596 EXPECT_THAT(service()->GetCategoryStatus(category),
587 Eq(CategoryStatus::AVAILABLE)); 597 Eq(CategoryStatus::AVAILABLE));
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 provider = RegisterProvider(category); 693 provider = RegisterProvider(category);
684 provider->FireCategoryStatusChangedWithCurrentStatus(category); 694 provider->FireCategoryStatusChangedWithCurrentStatus(category);
685 EXPECT_TRUE(service()->IsCategoryDismissed(category)); 695 EXPECT_TRUE(service()->IsCategoryDismissed(category));
686 696
687 service()->RestoreDismissedCategories(); 697 service()->RestoreDismissedCategories();
688 EXPECT_FALSE(service()->IsCategoryDismissed(category)); 698 EXPECT_FALSE(service()->IsCategoryDismissed(category));
689 EXPECT_THAT(providers().find(category)->second, Eq(provider)); 699 EXPECT_THAT(providers().find(category)->second, Eq(provider));
690 } 700 }
691 701
692 } // namespace ntp_snippets 702 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698