| 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 <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 class MockServiceObserver : public ContentSuggestionsService::Observer { | 112 class MockServiceObserver : public ContentSuggestionsService::Observer { |
| 113 public: | 113 public: |
| 114 MockServiceObserver() = default; | 114 MockServiceObserver() = default; |
| 115 ~MockServiceObserver() override = default; | 115 ~MockServiceObserver() override = default; |
| 116 | 116 |
| 117 MOCK_METHOD1(OnNewSuggestions, void(Category category)); | 117 MOCK_METHOD1(OnNewSuggestions, void(Category category)); |
| 118 MOCK_METHOD2(OnCategoryStatusChanged, | 118 MOCK_METHOD2(OnCategoryStatusChanged, |
| 119 void(Category changed_category, CategoryStatus new_status)); | 119 void(Category changed_category, CategoryStatus new_status)); |
| 120 MOCK_METHOD1(OnSuggestionInvalidated, | 120 MOCK_METHOD1(OnSuggestionInvalidated, |
| 121 void(const ContentSuggestion::ID& suggestion_id)); | 121 void(const ContentSuggestion::ID& suggestion_id)); |
| 122 MOCK_METHOD0(OnFullRefreshRequired, void()); |
| 122 MOCK_METHOD0(ContentSuggestionsServiceShutdown, void()); | 123 MOCK_METHOD0(ContentSuggestionsServiceShutdown, void()); |
| 123 | 124 |
| 124 private: | 125 private: |
| 125 DISALLOW_COPY_AND_ASSIGN(MockServiceObserver); | 126 DISALLOW_COPY_AND_ASSIGN(MockServiceObserver); |
| 126 }; | 127 }; |
| 127 | 128 |
| 128 } // namespace | 129 } // namespace |
| 129 | 130 |
| 130 class ContentSuggestionsServiceTest : public testing::Test { | 131 class ContentSuggestionsServiceTest : public testing::Test { |
| 131 public: | 132 public: |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 protected: | 208 protected: |
| 208 void RegisterPrefs() { | 209 void RegisterPrefs() { |
| 209 ContentSuggestionsService::RegisterProfilePrefs(pref_service_->registry()); | 210 ContentSuggestionsService::RegisterProfilePrefs(pref_service_->registry()); |
| 210 UserClassifier::RegisterProfilePrefs(pref_service_->registry()); | 211 UserClassifier::RegisterProfilePrefs(pref_service_->registry()); |
| 211 } | 212 } |
| 212 | 213 |
| 213 void CreateContentSuggestionsService( | 214 void CreateContentSuggestionsService( |
| 214 ContentSuggestionsService::State enabled) { | 215 ContentSuggestionsService::State enabled) { |
| 215 ASSERT_FALSE(service_); | 216 ASSERT_FALSE(service_); |
| 216 service_.reset(new ContentSuggestionsService( | 217 service_.reset(new ContentSuggestionsService( |
| 217 enabled, /*history_service=*/nullptr, pref_service_.get())); | 218 enabled, /*signin_manager=*/nullptr, /*history_service=*/nullptr, |
| 219 pref_service_.get())); |
| 218 } | 220 } |
| 219 | 221 |
| 220 void ResetService() { | 222 void ResetService() { |
| 221 service_->Shutdown(); | 223 service_->Shutdown(); |
| 222 service_.reset(); | 224 service_.reset(); |
| 223 CreateContentSuggestionsService(ContentSuggestionsService::State::ENABLED); | 225 CreateContentSuggestionsService(ContentSuggestionsService::State::ENABLED); |
| 224 } | 226 } |
| 225 | 227 |
| 226 ContentSuggestionsService* service() { return service_.get(); } | 228 ContentSuggestionsService* service() { return service_.get(); } |
| 227 | 229 |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 provider = RegisterProvider(category); | 701 provider = RegisterProvider(category); |
| 700 provider->FireCategoryStatusChangedWithCurrentStatus(category); | 702 provider->FireCategoryStatusChangedWithCurrentStatus(category); |
| 701 EXPECT_TRUE(service()->IsCategoryDismissed(category)); | 703 EXPECT_TRUE(service()->IsCategoryDismissed(category)); |
| 702 | 704 |
| 703 service()->RestoreDismissedCategories(); | 705 service()->RestoreDismissedCategories(); |
| 704 EXPECT_FALSE(service()->IsCategoryDismissed(category)); | 706 EXPECT_FALSE(service()->IsCategoryDismissed(category)); |
| 705 EXPECT_THAT(providers().find(category)->second, Eq(provider)); | 707 EXPECT_THAT(providers().find(category)->second, Eq(provider)); |
| 706 } | 708 } |
| 707 | 709 |
| 708 } // namespace ntp_snippets | 710 } // namespace ntp_snippets |
| OLD | NEW |