| 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/scheduling_remote_suggestions_provider.
h" | 5 #include "components/ntp_snippets/remote/scheduling_remote_suggestions_provider.
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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 17 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
| 18 #include "base/test/simple_test_clock.h" | 18 #include "base/test/simple_test_clock.h" |
| 19 #include "base/threading/thread_task_runner_handle.h" | 19 #include "base/threading/thread_task_runner_handle.h" |
| 20 #include "base/time/clock.h" | 20 #include "base/time/clock.h" |
| 21 #include "base/time/default_clock.h" |
| 21 #include "base/time/time.h" | 22 #include "base/time/time.h" |
| 22 #include "components/ntp_snippets/features.h" | 23 #include "components/ntp_snippets/features.h" |
| 23 #include "components/ntp_snippets/ntp_snippets_constants.h" | 24 #include "components/ntp_snippets/ntp_snippets_constants.h" |
| 24 #include "components/ntp_snippets/pref_names.h" | 25 #include "components/ntp_snippets/pref_names.h" |
| 25 #include "components/ntp_snippets/remote/persistent_scheduler.h" | 26 #include "components/ntp_snippets/remote/persistent_scheduler.h" |
| 26 #include "components/ntp_snippets/remote/remote_suggestions_provider.h" | 27 #include "components/ntp_snippets/remote/remote_suggestions_provider.h" |
| 27 #include "components/ntp_snippets/remote/test_utils.h" | 28 #include "components/ntp_snippets/remote/test_utils.h" |
| 28 #include "components/ntp_snippets/status.h" | 29 #include "components/ntp_snippets/status.h" |
| 29 #include "components/ntp_snippets/user_classifier.h" | 30 #include "components/ntp_snippets/user_classifier.h" |
| 30 #include "components/prefs/testing_pref_service.h" | 31 #include "components/prefs/testing_pref_service.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 SchedulingRemoteSuggestionsProviderTest() | 119 SchedulingRemoteSuggestionsProviderTest() |
| 119 : // For the test we enabled all trigger types. | 120 : // For the test we enabled all trigger types. |
| 120 default_variation_params_{{"scheduler_trigger_types", | 121 default_variation_params_{{"scheduler_trigger_types", |
| 121 "persistent_scheduler_wake_up,ntp_opened," | 122 "persistent_scheduler_wake_up,ntp_opened," |
| 122 "browser_foregrounded,browser_cold_start"}}, | 123 "browser_foregrounded,browser_cold_start"}}, |
| 123 params_manager_(ntp_snippets::kStudyName, | 124 params_manager_(ntp_snippets::kStudyName, |
| 124 default_variation_params_, | 125 default_variation_params_, |
| 125 {kArticleSuggestionsFeature.name}), | 126 {kArticleSuggestionsFeature.name}), |
| 126 underlying_provider_(nullptr), | 127 underlying_provider_(nullptr), |
| 127 scheduling_provider_(nullptr), | 128 scheduling_provider_(nullptr), |
| 128 user_classifier_(/*pref_service=*/nullptr) { | 129 user_classifier_(/*pref_service=*/nullptr, |
| 130 base::MakeUnique<base::DefaultClock>()) { |
| 129 SchedulingRemoteSuggestionsProvider::RegisterProfilePrefs( | 131 SchedulingRemoteSuggestionsProvider::RegisterProfilePrefs( |
| 130 utils_.pref_service()->registry()); | 132 utils_.pref_service()->registry()); |
| 131 RequestThrottler::RegisterProfilePrefs(utils_.pref_service()->registry()); | 133 RequestThrottler::RegisterProfilePrefs(utils_.pref_service()->registry()); |
| 132 ResetProvider(); | 134 ResetProvider(); |
| 133 } | 135 } |
| 134 | 136 |
| 135 void ResetProvider() { | 137 void ResetProvider() { |
| 136 auto underlying_provider = | 138 auto underlying_provider = |
| 137 base::MakeUnique<StrictMock<MockRemoteSuggestionsProvider>>( | 139 base::MakeUnique<StrictMock<MockRemoteSuggestionsProvider>>( |
| 138 /*observer=*/nullptr); | 140 /*observer=*/nullptr); |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 for (int x = 0; x < 5; ++x) { | 761 for (int x = 0; x < 5; ++x) { |
| 760 scheduling_provider_->OnPersistentSchedulerWakeUp(); | 762 scheduling_provider_->OnPersistentSchedulerWakeUp(); |
| 761 signal_fetch_done.Run(Status::Success()); | 763 signal_fetch_done.Run(Status::Success()); |
| 762 } | 764 } |
| 763 | 765 |
| 764 // For the 6th time, it is blocked by the scheduling provider. | 766 // For the 6th time, it is blocked by the scheduling provider. |
| 765 scheduling_provider_->OnPersistentSchedulerWakeUp(); | 767 scheduling_provider_->OnPersistentSchedulerWakeUp(); |
| 766 } | 768 } |
| 767 | 769 |
| 768 } // namespace ntp_snippets | 770 } // namespace ntp_snippets |
| OLD | NEW |