OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/ntp_snippets/content_suggestions_service.h" | 5 #include "components/ntp_snippets/content_suggestions_service.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "components/ntp_snippets/category_info.h" |
16 #include "components/ntp_snippets/category_status.h" | 18 #include "components/ntp_snippets/category_status.h" |
17 #include "components/ntp_snippets/content_suggestion.h" | 19 #include "components/ntp_snippets/content_suggestion.h" |
18 #include "components/ntp_snippets/content_suggestions_provider.h" | 20 #include "components/ntp_snippets/content_suggestions_provider.h" |
19 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "ui/gfx/image/image.h" | 23 #include "ui/gfx/image/image.h" |
22 | 24 |
23 using testing::ByRef; | 25 using testing::ByRef; |
24 using testing::Const; | 26 using testing::Const; |
25 using testing::ElementsAre; | 27 using testing::ElementsAre; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 } | 66 } |
65 | 67 |
66 std::vector<Category> GetProvidedCategories() override { | 68 std::vector<Category> GetProvidedCategories() override { |
67 return provided_categories_; | 69 return provided_categories_; |
68 } | 70 } |
69 | 71 |
70 CategoryStatus GetCategoryStatus(Category category) { | 72 CategoryStatus GetCategoryStatus(Category category) { |
71 return statuses_[category.id()]; | 73 return statuses_[category.id()]; |
72 } | 74 } |
73 | 75 |
| 76 CategoryInfo GetCategoryInfo(Category category) { |
| 77 return CategoryInfo(base::ASCIIToUTF16("Section title")); |
| 78 } |
| 79 |
74 void FireSuggestionsChanged(Category category, std::vector<int> numbers) { | 80 void FireSuggestionsChanged(Category category, std::vector<int> numbers) { |
75 observer()->OnNewSuggestions(this, category, CreateSuggestions(numbers)); | 81 observer()->OnNewSuggestions(this, category, CreateSuggestions(numbers)); |
76 } | 82 } |
77 | 83 |
78 void FireCategoryStatusChanged(Category category, CategoryStatus new_status) { | 84 void FireCategoryStatusChanged(Category category, CategoryStatus new_status) { |
79 statuses_[category.id()] = new_status; | 85 statuses_[category.id()] = new_status; |
80 observer()->OnCategoryStatusChanged(this, category, new_status); | 86 observer()->OnCategoryStatusChanged(this, category, new_status); |
81 } | 87 } |
82 | 88 |
83 MOCK_METHOD0(ClearCachedSuggestionsForDebugging, void()); | 89 MOCK_METHOD0(ClearCachedSuggestionsForDebugging, void()); |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 Mock::VerifyAndClearExpectations(&observer); | 356 Mock::VerifyAndClearExpectations(&observer); |
351 | 357 |
352 // Shutdown the service | 358 // Shutdown the service |
353 EXPECT_CALL(observer, ContentSuggestionsServiceShutdown()); | 359 EXPECT_CALL(observer, ContentSuggestionsServiceShutdown()); |
354 service()->Shutdown(); | 360 service()->Shutdown(); |
355 service()->RemoveObserver(&observer); | 361 service()->RemoveObserver(&observer); |
356 // The service will receive two Shutdown() calls. | 362 // The service will receive two Shutdown() calls. |
357 } | 363 } |
358 | 364 |
359 } // namespace ntp_snippets | 365 } // namespace ntp_snippets |
OLD | NEW |