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 dc197d1ae197e4746907934c093891adc1dc1103..931c8f66b5df1e192dbb601852a8651aeeee1696 100644 |
--- a/components/ntp_snippets/content_suggestions_service_unittest.cc |
+++ b/components/ntp_snippets/content_suggestions_service_unittest.cc |
@@ -14,7 +14,6 @@ |
#include "base/message_loop/message_loop.h" |
#include "base/run_loop.h" |
#include "base/strings/string_number_conversions.h" |
-#include "base/strings/utf_string_conversions.h" |
#include "components/ntp_snippets/category_info.h" |
#include "components/ntp_snippets/category_rankers/constant_category_ranker.h" |
#include "components/ntp_snippets/category_rankers/fake_category_ranker.h" |
@@ -22,6 +21,7 @@ |
#include "components/ntp_snippets/category_status.h" |
#include "components/ntp_snippets/content_suggestion.h" |
#include "components/ntp_snippets/content_suggestions_provider.h" |
+#include "components/ntp_snippets/mock_content_suggestions_provider.h" |
#include "components/ntp_snippets/user_classifier.h" |
#include "components/prefs/testing_pref_service.h" |
#include "testing/gmock/include/gmock/gmock.h" |
@@ -43,78 +43,6 @@ namespace ntp_snippets { |
namespace { |
-// TODO(treib): This is a weird combination of a mock and a fake. Fix this. |
-class MockProvider : public ContentSuggestionsProvider { |
- public: |
- MockProvider(Observer* observer, |
- const std::vector<Category>& provided_categories) |
- : ContentSuggestionsProvider(observer) { |
- SetProvidedCategories(provided_categories); |
- } |
- |
- void SetProvidedCategories(const std::vector<Category>& provided_categories) { |
- statuses_.clear(); |
- provided_categories_ = provided_categories; |
- for (Category category : provided_categories) { |
- statuses_[category.id()] = CategoryStatus::AVAILABLE; |
- } |
- } |
- |
- CategoryStatus GetCategoryStatus(Category category) override { |
- return statuses_[category.id()]; |
- } |
- |
- CategoryInfo GetCategoryInfo(Category category) override { |
- return CategoryInfo(base::ASCIIToUTF16("Section title"), |
- ContentSuggestionsCardLayout::FULL_CARD, true, false, |
- true, false, |
- base::ASCIIToUTF16("No suggestions message")); |
- } |
- |
- void FireSuggestionsChanged( |
- Category category, |
- std::vector<ContentSuggestion> suggestions) { |
- observer()->OnNewSuggestions(this, category, std::move(suggestions)); |
- } |
- |
- void FireCategoryStatusChanged(Category category, CategoryStatus new_status) { |
- statuses_[category.id()] = new_status; |
- observer()->OnCategoryStatusChanged(this, category, new_status); |
- } |
- |
- void FireCategoryStatusChangedWithCurrentStatus(Category category) { |
- observer()->OnCategoryStatusChanged(this, category, |
- statuses_[category.id()]); |
- } |
- |
- void FireSuggestionInvalidated(const ContentSuggestion::ID& suggestion_id) { |
- observer()->OnSuggestionInvalidated(this, suggestion_id); |
- } |
- |
- MOCK_METHOD3(ClearHistory, |
- void(base::Time begin, |
- base::Time end, |
- const base::Callback<bool(const GURL& url)>& filter)); |
- MOCK_METHOD3(Fetch, |
- void(const Category&, |
- const std::set<std::string>&, |
- const FetchDoneCallback&)); |
- MOCK_METHOD1(ClearCachedSuggestions, void(Category category)); |
- MOCK_METHOD2(GetDismissedSuggestionsForDebugging, |
- void(Category category, |
- const DismissedSuggestionsCallback& callback)); |
- MOCK_METHOD1(ClearDismissedSuggestionsForDebugging, void(Category category)); |
- MOCK_METHOD1(DismissSuggestion, |
- void(const ContentSuggestion::ID& suggestion_id)); |
- MOCK_METHOD2(FetchSuggestionImage, |
- void(const ContentSuggestion::ID& suggestion_id, |
- const ImageFetchedCallback& callback)); |
- |
- private: |
- std::vector<Category> provided_categories_; |
- std::map<int, CategoryStatus> statuses_; |
-}; |
- |
class MockServiceObserver : public ContentSuggestionsService::Observer { |
public: |
MockServiceObserver() = default; |