OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_NTP_SNIPPETS_MOCK_CONTENT_SUGGESTIONS_PROVIDER_H_ |
| 6 #define COMPONENTS_NTP_SNIPPETS_MOCK_CONTENT_SUGGESTIONS_PROVIDER_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <set> |
| 10 #include <string> |
| 11 #include <vector> |
| 12 |
| 13 #include "base/macros.h" |
| 14 #include "components/ntp_snippets/content_suggestions_provider.h" |
| 15 #include "testing/gmock/include/gmock/gmock.h" |
| 16 |
| 17 namespace ntp_snippets { |
| 18 |
| 19 // TODO(treib): This is a weird combination of a mock and a fake. Fix this. |
| 20 class MockContentSuggestionsProvider : public ContentSuggestionsProvider { |
| 21 public: |
| 22 MockContentSuggestionsProvider( |
| 23 Observer* observer, |
| 24 const std::vector<Category>& provided_categories); |
| 25 ~MockContentSuggestionsProvider(); |
| 26 |
| 27 void SetProvidedCategories(const std::vector<Category>& provided_categories); |
| 28 |
| 29 // Returns the status for |category|. The initial status in |
| 30 // CatgoryStatus::AVAILABLE. Will be updated on FireCategoryStatusChanged |
| 31 // events. |
| 32 CategoryStatus GetCategoryStatus(Category category) override; |
| 33 |
| 34 // Returns a hard-coded category info object. |
| 35 CategoryInfo GetCategoryInfo(Category category) override; |
| 36 |
| 37 // Forwards events to the underlying oberservers. |
| 38 // TODO(tschumann): This functionality does not belong here. Whoever injected |
| 39 // the observer into the constructor can as well notify the observer itself. |
| 40 void FireSuggestionsChanged(Category category, |
| 41 std::vector<ContentSuggestion> suggestions); |
| 42 void FireCategoryStatusChanged(Category category, CategoryStatus new_status); |
| 43 void FireCategoryStatusChangedWithCurrentStatus(Category category); |
| 44 void FireSuggestionInvalidated(const ContentSuggestion::ID& suggestion_id); |
| 45 |
| 46 MOCK_METHOD3(ClearHistory, |
| 47 void(base::Time begin, |
| 48 base::Time end, |
| 49 const base::Callback<bool(const GURL& url)>& filter)); |
| 50 MOCK_METHOD3(Fetch, |
| 51 void(const Category&, |
| 52 const std::set<std::string>&, |
| 53 const FetchDoneCallback&)); |
| 54 MOCK_METHOD1(ClearCachedSuggestions, void(Category category)); |
| 55 MOCK_METHOD2(GetDismissedSuggestionsForDebugging, |
| 56 void(Category category, |
| 57 const DismissedSuggestionsCallback& callback)); |
| 58 MOCK_METHOD1(ClearDismissedSuggestionsForDebugging, void(Category category)); |
| 59 MOCK_METHOD1(DismissSuggestion, |
| 60 void(const ContentSuggestion::ID& suggestion_id)); |
| 61 MOCK_METHOD2(FetchSuggestionImage, |
| 62 void(const ContentSuggestion::ID& suggestion_id, |
| 63 const ImageFetchedCallback& callback)); |
| 64 |
| 65 private: |
| 66 std::vector<Category> provided_categories_; |
| 67 std::map<int, CategoryStatus> statuses_; |
| 68 }; |
| 69 |
| 70 } // namespace ntp_snippets |
| 71 |
| 72 #endif // COMPONENTS_NTP_SNIPPETS_MOCK_CONTENT_SUGGESTIONS_PROVIDER_H_ |
OLD | NEW |