| 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" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 void FireCategoryStatusChangedWithCurrentStatus(Category category) { | 93 void FireCategoryStatusChangedWithCurrentStatus(Category category) { |
| 94 observer()->OnCategoryStatusChanged(this, category, | 94 observer()->OnCategoryStatusChanged(this, category, |
| 95 statuses_[category.id()]); | 95 statuses_[category.id()]); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void FireSuggestionInvalidated(Category category, | 98 void FireSuggestionInvalidated(Category category, |
| 99 const std::string& suggestion_id) { | 99 const std::string& suggestion_id) { |
| 100 observer()->OnSuggestionInvalidated(this, category, suggestion_id); | 100 observer()->OnSuggestionInvalidated(this, category, suggestion_id); |
| 101 } | 101 } |
| 102 | 102 |
| 103 MOCK_METHOD2(RemoveURLsFromHistory, |
| 104 void(bool all_history, const std::vector<GURL>& deleted_urls)); |
| 103 MOCK_METHOD3(ClearHistory, | 105 MOCK_METHOD3(ClearHistory, |
| 104 void(base::Time begin, | 106 void(base::Time begin, |
| 105 base::Time end, | 107 base::Time end, |
| 106 const base::Callback<bool(const GURL& url)>& filter)); | 108 const base::Callback<bool(const GURL& url)>& filter)); |
| 107 MOCK_METHOD1(ClearCachedSuggestions, void(Category category)); | 109 MOCK_METHOD1(ClearCachedSuggestions, void(Category category)); |
| 108 MOCK_METHOD2(GetDismissedSuggestionsForDebugging, | 110 MOCK_METHOD2(GetDismissedSuggestionsForDebugging, |
| 109 void(Category category, | 111 void(Category category, |
| 110 const DismissedSuggestionsCallback& callback)); | 112 const DismissedSuggestionsCallback& callback)); |
| 111 MOCK_METHOD1(ClearDismissedSuggestionsForDebugging, void(Category category)); | 113 MOCK_METHOD1(ClearDismissedSuggestionsForDebugging, void(Category category)); |
| 112 MOCK_METHOD1(DismissSuggestion, void(const std::string& suggestion_id)); | 114 MOCK_METHOD1(DismissSuggestion, void(const std::string& suggestion_id)); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 service()->RegisterProvider(std::move(provider)); | 200 service()->RegisterProvider(std::move(provider)); |
| 199 return result; | 201 return result; |
| 200 } | 202 } |
| 201 | 203 |
| 202 MOCK_METHOD1(OnImageFetched, void(const gfx::Image&)); | 204 MOCK_METHOD1(OnImageFetched, void(const gfx::Image&)); |
| 203 | 205 |
| 204 protected: | 206 protected: |
| 205 void CreateContentSuggestionsService( | 207 void CreateContentSuggestionsService( |
| 206 ContentSuggestionsService::State enabled) { | 208 ContentSuggestionsService::State enabled) { |
| 207 ASSERT_FALSE(service_); | 209 ASSERT_FALSE(service_); |
| 208 service_.reset(new ContentSuggestionsService(enabled)); | 210 service_.reset( |
| 211 new ContentSuggestionsService(enabled, /*history_service=*/nullptr)); |
| 209 } | 212 } |
| 210 | 213 |
| 211 ContentSuggestionsService* service() { return service_.get(); } | 214 ContentSuggestionsService* service() { return service_.get(); } |
| 212 | 215 |
| 213 private: | 216 private: |
| 214 std::unique_ptr<ContentSuggestionsService> service_; | 217 std::unique_ptr<ContentSuggestionsService> service_; |
| 215 | 218 |
| 216 DISALLOW_COPY_AND_ASSIGN(ContentSuggestionsServiceTest); | 219 DISALLOW_COPY_AND_ASSIGN(ContentSuggestionsServiceTest); |
| 217 }; | 220 }; |
| 218 | 221 |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 Category category = FromKnownCategory(KnownCategories::DOWNLOADS); | 576 Category category = FromKnownCategory(KnownCategories::DOWNLOADS); |
| 574 MockProvider* provider = RegisterProvider(category); | 577 MockProvider* provider = RegisterProvider(category); |
| 575 base::Time begin = base::Time::FromTimeT(123), | 578 base::Time begin = base::Time::FromTimeT(123), |
| 576 end = base::Time::FromTimeT(456); | 579 end = base::Time::FromTimeT(456); |
| 577 EXPECT_CALL(*provider, ClearHistory(begin, end, _)); | 580 EXPECT_CALL(*provider, ClearHistory(begin, end, _)); |
| 578 base::Callback<bool(const GURL& url)> filter; | 581 base::Callback<bool(const GURL& url)> filter; |
| 579 service()->ClearHistory(begin, end, filter); | 582 service()->ClearHistory(begin, end, filter); |
| 580 } | 583 } |
| 581 | 584 |
| 582 } // namespace ntp_snippets | 585 } // namespace ntp_snippets |
| OLD | NEW |