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

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

Issue 2421463002: FetchMore functionality backend (Closed)
Patch Set: Strategy pattern to handle differences in fetching procedure. 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 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } 78 }
79 79
80 void FireSuggestionInvalidated(const ContentSuggestion::ID& suggestion_id) { 80 void FireSuggestionInvalidated(const ContentSuggestion::ID& suggestion_id) {
81 observer()->OnSuggestionInvalidated(this, suggestion_id); 81 observer()->OnSuggestionInvalidated(this, suggestion_id);
82 } 82 }
83 83
84 MOCK_METHOD3(ClearHistory, 84 MOCK_METHOD3(ClearHistory,
85 void(base::Time begin, 85 void(base::Time begin,
86 base::Time end, 86 base::Time end,
87 const base::Callback<bool(const GURL& url)>& filter)); 87 const base::Callback<bool(const GURL& url)>& filter));
88 MOCK_METHOD0(FetchMore, void());
88 MOCK_METHOD1(ClearCachedSuggestions, void(Category category)); 89 MOCK_METHOD1(ClearCachedSuggestions, void(Category category));
89 MOCK_METHOD2(GetDismissedSuggestionsForDebugging, 90 MOCK_METHOD2(GetDismissedSuggestionsForDebugging,
90 void(Category category, 91 void(Category category,
91 const DismissedSuggestionsCallback& callback)); 92 const DismissedSuggestionsCallback& callback));
92 MOCK_METHOD1(ClearDismissedSuggestionsForDebugging, void(Category category)); 93 MOCK_METHOD1(ClearDismissedSuggestionsForDebugging, void(Category category));
93 MOCK_METHOD1(DismissSuggestion, 94 MOCK_METHOD1(DismissSuggestion,
94 void(const ContentSuggestion::ID& suggestion_id)); 95 void(const ContentSuggestion::ID& suggestion_id));
95 MOCK_METHOD2(FetchSuggestionImage, 96 MOCK_METHOD2(FetchSuggestionImage,
96 void(const ContentSuggestion::ID& suggestion_id, 97 void(const ContentSuggestion::ID& suggestion_id,
97 const ImageFetchedCallback& callback)); 98 const ImageFetchedCallback& callback));
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 TEST_F(ContentSuggestionsServiceTest, ShouldForwardClearHistory) { 600 TEST_F(ContentSuggestionsServiceTest, ShouldForwardClearHistory) {
600 Category category = FromKnownCategory(KnownCategories::DOWNLOADS); 601 Category category = FromKnownCategory(KnownCategories::DOWNLOADS);
601 MockProvider* provider = RegisterProvider(category); 602 MockProvider* provider = RegisterProvider(category);
602 base::Time begin = base::Time::FromTimeT(123), 603 base::Time begin = base::Time::FromTimeT(123),
603 end = base::Time::FromTimeT(456); 604 end = base::Time::FromTimeT(456);
604 EXPECT_CALL(*provider, ClearHistory(begin, end, _)); 605 EXPECT_CALL(*provider, ClearHistory(begin, end, _));
605 base::Callback<bool(const GURL& url)> filter; 606 base::Callback<bool(const GURL& url)> filter;
606 service()->ClearHistory(begin, end, filter); 607 service()->ClearHistory(begin, end, filter);
607 } 608 }
608 609
610 TEST_F(ContentSuggestionsServiceTest, ShouldForwardFetchMore) {
611 Category category = FromKnownCategory(KnownCategories::ARTICLES);
612 MockProvider* provider = RegisterProvider(category);
613 provider->FireCategoryStatusChangedWithCurrentStatus(category);
614 EXPECT_CALL(*provider, FetchMore());
615 service()->FetchMore(category);
616 }
617
609 TEST_F(ContentSuggestionsServiceTest, DismissAndRestoreCategory) { 618 TEST_F(ContentSuggestionsServiceTest, DismissAndRestoreCategory) {
610 // Register a category with one suggestion. 619 // Register a category with one suggestion.
611 Category category = FromKnownCategory(KnownCategories::ARTICLES); 620 Category category = FromKnownCategory(KnownCategories::ARTICLES);
612 MockProvider* provider = RegisterProvider(category); 621 MockProvider* provider = RegisterProvider(category);
613 provider->FireCategoryStatusChangedWithCurrentStatus(category); 622 provider->FireCategoryStatusChangedWithCurrentStatus(category);
614 provider->FireSuggestionsChanged(category, CreateSuggestions(category, {42})); 623 provider->FireSuggestionsChanged(category, CreateSuggestions(category, {42}));
615 624
616 EXPECT_THAT(service()->GetCategories(), ElementsAre(category)); 625 EXPECT_THAT(service()->GetCategories(), ElementsAre(category));
617 EXPECT_THAT(service()->GetCategoryStatus(category), 626 EXPECT_THAT(service()->GetCategoryStatus(category),
618 Eq(CategoryStatus::AVAILABLE)); 627 Eq(CategoryStatus::AVAILABLE));
(...skipping 17 matching lines...) Expand all
636 645
637 EXPECT_THAT(service()->GetCategories(), ElementsAre(category)); 646 EXPECT_THAT(service()->GetCategories(), ElementsAre(category));
638 EXPECT_THAT(service()->GetCategoryStatus(category), 647 EXPECT_THAT(service()->GetCategoryStatus(category),
639 Eq(CategoryStatus::AVAILABLE)); 648 Eq(CategoryStatus::AVAILABLE));
640 EXPECT_THAT(service()->GetSuggestionsForCategory(category), IsEmpty()); 649 EXPECT_THAT(service()->GetSuggestionsForCategory(category), IsEmpty());
641 EXPECT_THAT(providers().count(category), Eq(1ul)); 650 EXPECT_THAT(providers().count(category), Eq(1ul));
642 EXPECT_THAT(dismissed_providers(), IsEmpty()); 651 EXPECT_THAT(dismissed_providers(), IsEmpty());
643 } 652 }
644 653
645 } // namespace ntp_snippets 654 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698