| 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/remote/remote_suggestions_scheduler_impl.h" | 5 #include "components/ntp_snippets/remote/remote_suggestions_scheduler_impl.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 bool(base::TimeDelta period_wifi, | 65 bool(base::TimeDelta period_wifi, |
| 66 base::TimeDelta period_fallback)); | 66 base::TimeDelta period_fallback)); |
| 67 MOCK_METHOD0(Unschedule, bool()); | 67 MOCK_METHOD0(Unschedule, bool()); |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 // TODO(jkrcal): Move into its own library to reuse in other unit-tests? | 70 // TODO(jkrcal): Move into its own library to reuse in other unit-tests? |
| 71 class MockRemoteSuggestionsProvider : public RemoteSuggestionsProvider { | 71 class MockRemoteSuggestionsProvider : public RemoteSuggestionsProvider { |
| 72 public: | 72 public: |
| 73 MockRemoteSuggestionsProvider(Observer* observer) | 73 MockRemoteSuggestionsProvider(Observer* observer) |
| 74 : RemoteSuggestionsProvider(observer) {} | 74 : RemoteSuggestionsProvider(observer) {} |
| 75 // Move-only params are not supported by GMock. We want to mock out | |
| 76 // RefetchInTheBackground() which takes a unique_ptr<>. Instead, we add a new | |
| 77 // mock function which takes a copy of the callback and override the | |
| 78 // RemoteSuggestionsProvider's method to forward the call into the new mock | |
| 79 // function. | |
| 80 void RefetchInTheBackground( | |
| 81 std::unique_ptr<RemoteSuggestionsProvider::FetchStatusCallback> callback) | |
| 82 override { | |
| 83 RefetchInTheBackground(*callback); | |
| 84 } | |
| 85 MOCK_METHOD1(RefetchInTheBackground, | 75 MOCK_METHOD1(RefetchInTheBackground, |
| 86 void(RemoteSuggestionsProvider::FetchStatusCallback)); | 76 void(const RemoteSuggestionsProvider::FetchStatusCallback&)); |
| 87 | |
| 88 MOCK_CONST_METHOD0(suggestions_fetcher_for_debugging, | 77 MOCK_CONST_METHOD0(suggestions_fetcher_for_debugging, |
| 89 const RemoteSuggestionsFetcher*()); | 78 const RemoteSuggestionsFetcher*()); |
| 90 | |
| 91 MOCK_METHOD1(GetCategoryStatus, CategoryStatus(Category)); | 79 MOCK_METHOD1(GetCategoryStatus, CategoryStatus(Category)); |
| 92 MOCK_METHOD1(GetCategoryInfo, CategoryInfo(Category)); | 80 MOCK_METHOD1(GetCategoryInfo, CategoryInfo(Category)); |
| 93 MOCK_METHOD3(ClearHistory, | 81 MOCK_METHOD3(ClearHistory, |
| 94 void(base::Time begin, | 82 void(base::Time begin, |
| 95 base::Time end, | 83 base::Time end, |
| 96 const base::Callback<bool(const GURL& url)>& filter)); | 84 const base::Callback<bool(const GURL& url)>& filter)); |
| 97 MOCK_METHOD3(Fetch, | 85 MOCK_METHOD3(Fetch, |
| 98 void(const Category&, | 86 void(const Category&, |
| 99 const std::set<std::string>&, | 87 const std::set<std::string>&, |
| 100 const FetchDoneCallback&)); | 88 const FetchDoneCallback&)); |
| (...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 for (int x = 0; x < 5; ++x) { | 767 for (int x = 0; x < 5; ++x) { |
| 780 scheduler()->OnPersistentSchedulerWakeUp(); | 768 scheduler()->OnPersistentSchedulerWakeUp(); |
| 781 signal_fetch_done.Run(Status::Success()); | 769 signal_fetch_done.Run(Status::Success()); |
| 782 } | 770 } |
| 783 | 771 |
| 784 // For the 6th time, it is blocked by the scheduling provider. | 772 // For the 6th time, it is blocked by the scheduling provider. |
| 785 scheduler()->OnPersistentSchedulerWakeUp(); | 773 scheduler()->OnPersistentSchedulerWakeUp(); |
| 786 } | 774 } |
| 787 | 775 |
| 788 } // namespace ntp_snippets | 776 } // namespace ntp_snippets |
| OLD | NEW |