mock_content_suggestions_provider_observer.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2016 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. #ifndef COMPONENTS_NTP_SNIPPETS_MOCK_CONTENT_SUGGESTIONS_PROVIDER_OBSERVER_H_
  5. #define COMPONENTS_NTP_SNIPPETS_MOCK_CONTENT_SUGGESTIONS_PROVIDER_OBSERVER_H_
  6. #include <list>
  7. #include <vector>
  8. #include "components/ntp_snippets/content_suggestions_provider.h"
  9. #include "testing/gmock/include/gmock/gmock.h"
  10. namespace ntp_snippets {
  11. class MockContentSuggestionsProviderObserver
  12. : public ContentSuggestionsProvider::Observer {
  13. public:
  14. MockContentSuggestionsProviderObserver();
  15. ~MockContentSuggestionsProviderObserver();
  16. // Call of this function is redirected to the mock function OnNewSuggestions
  17. // which takes const list of suggestions. We do this trick so that the
  18. // MOCK_METHOD behaves the same way in tests as the actual method and we can
  19. // keep this gMock issue limited to the mock class. MOCK_METHOD cannot be
  20. // applied here directly, since gMock does not support movable-only types
  21. // such as ContentSuggestion.
  22. void OnNewSuggestions(ContentSuggestionsProvider* provider,
  23. Category category,
  24. std::vector<ContentSuggestion> suggestions) override;
  25. MOCK_METHOD3(OnNewSuggestions,
  26. void(ContentSuggestionsProvider* provider,
  27. Category category,
  28. const std::list<ContentSuggestion>& suggestions));
  29. MOCK_METHOD3(OnCategoryStatusChanged,
  30. void(ContentSuggestionsProvider* provider,
  31. Category category,
  32. CategoryStatus new_status));
  33. MOCK_METHOD2(OnSuggestionInvalidated,
  34. void(ContentSuggestionsProvider* provider,
  35. const ContentSuggestion::ID& suggestion_id));
  36. };
  37. } // namespace ntp_snippets
  38. #endif // COMPONENTS_NTP_SNIPPETS_MOCK_CONTENT_SUGGESTIONS_PROVIDER_OBSERVER_H_