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

Side by Side Diff: components/ntp_snippets/mock_content_suggestions_provider.h

Issue 2618243004: Add a unit test for the BookmarkSuggestionsProvider. (Closed)
Patch Set: fixed BUILD dependencies Created 3 years, 11 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
(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 MockProvider : public ContentSuggestionsProvider {
jkrcal 2017/01/12 14:50:53 nit: MockContentSuggestionsProvider to keep naming
tschumann 2017/01/12 15:06:23 it's used rarely enough -- fixed.
21 public:
22 MockProvider(Observer* observer,
23 const std::vector<Category>& provided_categories);
24 ~MockProvider();
25
26 void SetProvidedCategories(const std::vector<Category>& provided_categories);
27
28 // Returns the status for |category|. The initial status in
29 // CatgoryStatus::AVAILABLE. Will be updated on FireCategoryStatusChanged
30 // events.
31 CategoryStatus GetCategoryStatus(Category category) override;
32
33 // Returns a hard-coded category info object.
34 CategoryInfo GetCategoryInfo(Category category) override;
35
36 // Forwards events to the underlying oberservers.
37 // TODO(tschumann): This functionality does not belong here. Whoever injected
38 // the observer into the constructor can as well notify the observer itself.
39 void FireSuggestionsChanged(Category category,
40 std::vector<ContentSuggestion> suggestions);
41 void FireCategoryStatusChanged(Category category, CategoryStatus new_status);
42 void FireCategoryStatusChangedWithCurrentStatus(Category category);
43 void FireSuggestionInvalidated(const ContentSuggestion::ID& suggestion_id);
44
45 MOCK_METHOD3(ClearHistory,
46 void(base::Time begin,
47 base::Time end,
48 const base::Callback<bool(const GURL& url)>& filter));
49 MOCK_METHOD3(Fetch,
50 void(const Category&,
51 const std::set<std::string>&,
52 const FetchDoneCallback&));
53 MOCK_METHOD1(ClearCachedSuggestions, void(Category category));
54 MOCK_METHOD2(GetDismissedSuggestionsForDebugging,
55 void(Category category,
56 const DismissedSuggestionsCallback& callback));
57 MOCK_METHOD1(ClearDismissedSuggestionsForDebugging, void(Category category));
58 MOCK_METHOD1(DismissSuggestion,
59 void(const ContentSuggestion::ID& suggestion_id));
60 MOCK_METHOD2(FetchSuggestionImage,
61 void(const ContentSuggestion::ID& suggestion_id,
62 const ImageFetchedCallback& callback));
63
64 private:
65 std::vector<Category> provided_categories_;
66 std::map<int, CategoryStatus> statuses_;
67 };
68
69 } // namespace ntp_snippets
70
71 #endif // COMPONENTS_NTP_SNIPPETS_MOCK_CONTENT_SUGGESTIONS_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698