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

Unified Diff: components/ntp_snippets/fake_content_suggestions_provider_observer.cc

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 side-by-side diff with in-line comments
Download patch
Index: components/ntp_snippets/fake_content_suggestions_provider_observer.cc
diff --git a/components/ntp_snippets/fake_content_suggestions_provider_observer.cc b/components/ntp_snippets/fake_content_suggestions_provider_observer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..977f45a11ee2d519c5f57ca4362320860503a201
--- /dev/null
+++ b/components/ntp_snippets/fake_content_suggestions_provider_observer.cc
@@ -0,0 +1,61 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/ntp_snippets/fake_content_suggestions_provider_observer.h"
+
+#include <utility>
+
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace ntp_snippets {
+
+using testing::Eq;
+using testing::Not;
+
+FakeContentSuggestionsProviderObserver::
+ FakeContentSuggestionsProviderObserver() = default;
+
+FakeContentSuggestionsProviderObserver::
+ ~FakeContentSuggestionsProviderObserver() = default;
+
+void FakeContentSuggestionsProviderObserver::OnNewSuggestions(
+ ContentSuggestionsProvider* provider,
+ Category category,
+ std::vector<ContentSuggestion> suggestions) {
+ suggestions_[category] = std::move(suggestions);
+}
+
+void FakeContentSuggestionsProviderObserver::OnCategoryStatusChanged(
+ ContentSuggestionsProvider* provider,
+ Category category,
+ CategoryStatus new_status) {
+ statuses_[category] = new_status;
+}
+
+void FakeContentSuggestionsProviderObserver::OnSuggestionInvalidated(
+ ContentSuggestionsProvider* provider,
+ const ContentSuggestion::ID& suggestion_id) {
+ FAIL() << "not implemented.";
+}
+
+const std::map<Category, CategoryStatus, Category::CompareByID>&
+FakeContentSuggestionsProviderObserver::statuses() const {
+ return statuses_;
+}
+
+CategoryStatus FakeContentSuggestionsProviderObserver::StatusForCategory(
+ Category category) const {
+ auto it = statuses_.find(category);
+ EXPECT_THAT(it, Not(Eq(statuses_.end())));
+ return it->second;
+}
+
+const std::vector<ContentSuggestion>&
+FakeContentSuggestionsProviderObserver::SuggestionsForCategory(
+ Category category) {
+ return suggestions_[category];
+}
+
+} // namespace ntp_snippets

Powered by Google App Engine
This is Rietveld 408576698