Chromium Code Reviews| Index: components/ntp_snippets/content_suggestions_service_unittest.cc |
| diff --git a/components/ntp_snippets/content_suggestions_service_unittest.cc b/components/ntp_snippets/content_suggestions_service_unittest.cc |
| index a7f75386acb4268a0af656e142c1ca04ab12ffdd..72e6f89ea947dcdb3430a9546e2dc1ec6a485075 100644 |
| --- a/components/ntp_snippets/content_suggestions_service_unittest.cc |
| +++ b/components/ntp_snippets/content_suggestions_service_unittest.cc |
| @@ -87,6 +87,11 @@ class MockProvider : public ContentSuggestionsProvider { |
| observer()->OnCategoryStatusChanged(this, category, new_status); |
| } |
| + void FireSuggestionInvalidated(Category category, |
| + const std::string& suggestion_id) { |
| + observer()->OnSuggestionInvalidated(this, category, suggestion_id); |
| + } |
| + |
| MOCK_METHOD1(ClearCachedSuggestionsForDebugging, void(Category category)); |
| MOCK_METHOD1(GetDismissedSuggestionsForDebugging, |
| std::vector<ContentSuggestion>(Category category)); |
| @@ -106,6 +111,8 @@ class MockServiceObserver : public ContentSuggestionsService::Observer { |
| MOCK_METHOD1(OnNewSuggestions, void(Category category)); |
| MOCK_METHOD2(OnCategoryStatusChanged, |
| void(Category changed_category, CategoryStatus new_status)); |
| + MOCK_METHOD2(OnSuggestionInvalidated, |
| + void(Category category, const std::string& suggestion_id)); |
| MOCK_METHOD0(ContentSuggestionsServiceShutdown, void()); |
| ~MockServiceObserver() override {} |
| }; |
| @@ -301,6 +308,25 @@ TEST_F(ContentSuggestionsServiceTest, ShouldRedirectDismissSuggestion) { |
| service()->DismissSuggestion(suggestion_id); |
| } |
| +TEST_F(ContentSuggestionsServiceTest, ShouldRedirectSuggestionInvalidated) { |
| + Category articles_category = FromKnownCategory(KnownCategories::ARTICLES); |
| + |
| + MockProvider* provider = MakeProvider(articles_category); |
| + MockServiceObserver observer; |
| + service()->AddObserver(&observer); |
| + |
| + provider->FireSuggestionsChanged(articles_category, {11, 12, 13}); |
| + ExpectThatSuggestionsAre(articles_category, {11, 12, 13}); |
| + std::string suggestion_id = CreateSuggestion(12).id(); |
| + |
| + EXPECT_CALL(observer, |
| + OnSuggestionInvalidated(articles_category, suggestion_id)) |
| + .Times(1); |
|
Marc Treib
2016/08/16 09:03:54
As I've recently learned, ".Times(1)" is a no-op,
Philipp Keck
2016/08/16 10:54:40
Done (for the entire file).
|
| + provider->FireSuggestionInvalidated(articles_category, suggestion_id); |
| + ExpectThatSuggestionsAre(articles_category, {11, 13}); |
|
Marc Treib
2016/08/16 09:03:54
Add a case with a suggestion that isn't known to t
Philipp Keck
2016/08/16 10:54:40
Done.
|
| + service()->RemoveObserver(&observer); |
| +} |
| + |
| TEST_F(ContentSuggestionsServiceTest, ShouldForwardSuggestions) { |
| Category articles_category = FromKnownCategory(KnownCategories::ARTICLES); |
| Category offline_pages_category = |