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

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

Issue 2618243004: Add a unit test for the BookmarkSuggestionsProvider. (Closed)
Patch Set: renamed MockProvider and updated tests comments about expected behavior 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 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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698