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 #include "components/ntp_snippets/fake_content_suggestions_provider_observer.h" |
| 6 |
| 7 #include <utility> |
| 8 |
| 9 #include "testing/gmock/include/gmock/gmock.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 |
| 12 namespace ntp_snippets { |
| 13 |
| 14 using testing::Eq; |
| 15 using testing::Not; |
| 16 |
| 17 FakeContentSuggestionsProviderObserver:: |
| 18 FakeContentSuggestionsProviderObserver() = default; |
| 19 |
| 20 FakeContentSuggestionsProviderObserver:: |
| 21 ~FakeContentSuggestionsProviderObserver() = default; |
| 22 |
| 23 void FakeContentSuggestionsProviderObserver::OnNewSuggestions( |
| 24 ContentSuggestionsProvider* provider, |
| 25 Category category, |
| 26 std::vector<ContentSuggestion> suggestions) { |
| 27 suggestions_[category] = std::move(suggestions); |
| 28 } |
| 29 |
| 30 void FakeContentSuggestionsProviderObserver::OnCategoryStatusChanged( |
| 31 ContentSuggestionsProvider* provider, |
| 32 Category category, |
| 33 CategoryStatus new_status) { |
| 34 statuses_[category] = new_status; |
| 35 } |
| 36 |
| 37 void FakeContentSuggestionsProviderObserver::OnSuggestionInvalidated( |
| 38 ContentSuggestionsProvider* provider, |
| 39 const ContentSuggestion::ID& suggestion_id) { |
| 40 FAIL() << "not implemented."; |
| 41 } |
| 42 |
| 43 const std::map<Category, CategoryStatus, Category::CompareByID>& |
| 44 FakeContentSuggestionsProviderObserver::statuses() const { |
| 45 return statuses_; |
| 46 } |
| 47 |
| 48 CategoryStatus FakeContentSuggestionsProviderObserver::StatusForCategory( |
| 49 Category category) const { |
| 50 auto it = statuses_.find(category); |
| 51 EXPECT_THAT(it, Not(Eq(statuses_.end()))); |
| 52 return it->second; |
| 53 } |
| 54 |
| 55 const std::vector<ContentSuggestion>& |
| 56 FakeContentSuggestionsProviderObserver::SuggestionsForCategory( |
| 57 Category category) { |
| 58 return suggestions_[category]; |
| 59 } |
| 60 |
| 61 } // namespace ntp_snippets |
OLD | NEW |