| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 } // namespace | 100 } // namespace |
| 101 | 101 |
| 102 class RemoteSuggestionsSchedulerImplTest : public ::testing::Test { | 102 class RemoteSuggestionsSchedulerImplTest : public ::testing::Test { |
| 103 public: | 103 public: |
| 104 RemoteSuggestionsSchedulerImplTest() | 104 RemoteSuggestionsSchedulerImplTest() |
| 105 : // For the test we enabled all trigger types. | 105 : // For the test we enabled all trigger types. |
| 106 default_variation_params_{{"scheduler_trigger_types", | 106 default_variation_params_{{"scheduler_trigger_types", |
| 107 "persistent_scheduler_wake_up,ntp_opened," | 107 "persistent_scheduler_wake_up,ntp_opened," |
| 108 "browser_foregrounded,browser_cold_start"}}, | 108 "browser_foregrounded,browser_cold_start"}}, |
| 109 params_manager_(ntp_snippets::kStudyName, | 109 params_manager_(ntp_snippets::kArticleSuggestionsFeature.name, |
| 110 default_variation_params_, | 110 default_variation_params_, |
| 111 {kArticleSuggestionsFeature.name}), | 111 {kArticleSuggestionsFeature.name}), |
| 112 user_classifier_(/*pref_service=*/nullptr, | 112 user_classifier_(/*pref_service=*/nullptr, |
| 113 base::MakeUnique<base::DefaultClock>()) { | 113 base::MakeUnique<base::DefaultClock>()) { |
| 114 RemoteSuggestionsSchedulerImpl::RegisterProfilePrefs( | 114 RemoteSuggestionsSchedulerImpl::RegisterProfilePrefs( |
| 115 utils_.pref_service()->registry()); | 115 utils_.pref_service()->registry()); |
| 116 RequestThrottler::RegisterProfilePrefs(utils_.pref_service()->registry()); | 116 RequestThrottler::RegisterProfilePrefs(utils_.pref_service()->registry()); |
| 117 // TODO(jkrcal) Create a static function in EulaAcceptedNotifier that | 117 // TODO(jkrcal) Create a static function in EulaAcceptedNotifier that |
| 118 // registers this pref and replace the call in browser_process_impl.cc & in | 118 // registers this pref and replace the call in browser_process_impl.cc & in |
| 119 // eula_accepted_notifier_unittest.cc with the new static function. | 119 // eula_accepted_notifier_unittest.cc with the new static function. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 135 scheduler_->SetProvider(provider_.get()); | 135 scheduler_->SetProvider(provider_.get()); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void SetVariationParameter(const std::string& param_name, | 138 void SetVariationParameter(const std::string& param_name, |
| 139 const std::string& param_value) { | 139 const std::string& param_value) { |
| 140 std::map<std::string, std::string> params = default_variation_params_; | 140 std::map<std::string, std::string> params = default_variation_params_; |
| 141 params[param_name] = param_value; | 141 params[param_name] = param_value; |
| 142 | 142 |
| 143 params_manager_.ClearAllVariationParams(); | 143 params_manager_.ClearAllVariationParams(); |
| 144 params_manager_.SetVariationParamsWithFeatureAssociations( | 144 params_manager_.SetVariationParamsWithFeatureAssociations( |
| 145 ntp_snippets::kStudyName, params, | 145 ntp_snippets::kArticleSuggestionsFeature.name, params, |
| 146 {ntp_snippets::kArticleSuggestionsFeature.name}); | 146 {ntp_snippets::kArticleSuggestionsFeature.name}); |
| 147 } | 147 } |
| 148 | 148 |
| 149 bool IsEulaNotifierAvailable() { | 149 bool IsEulaNotifierAvailable() { |
| 150 // Create() returns a unique_ptr, so this is no leak. | 150 // Create() returns a unique_ptr, so this is no leak. |
| 151 return web_resource::EulaAcceptedNotifier::Create(&local_state_) != nullptr; | 151 return web_resource::EulaAcceptedNotifier::Create(&local_state_) != nullptr; |
| 152 } | 152 } |
| 153 | 153 |
| 154 void SetEulaAcceptedPref() { | 154 void SetEulaAcceptedPref() { |
| 155 local_state_.SetBoolean(::prefs::kEulaAccepted, true); | 155 local_state_.SetBoolean(::prefs::kEulaAccepted, true); |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 for (int x = 0; x < 5; ++x) { | 767 for (int x = 0; x < 5; ++x) { |
| 768 scheduler()->OnPersistentSchedulerWakeUp(); | 768 scheduler()->OnPersistentSchedulerWakeUp(); |
| 769 signal_fetch_done.Run(Status::Success()); | 769 signal_fetch_done.Run(Status::Success()); |
| 770 } | 770 } |
| 771 | 771 |
| 772 // For the 6th time, it is blocked by the scheduling provider. | 772 // For the 6th time, it is blocked by the scheduling provider. |
| 773 scheduler()->OnPersistentSchedulerWakeUp(); | 773 scheduler()->OnPersistentSchedulerWakeUp(); |
| 774 } | 774 } |
| 775 | 775 |
| 776 } // namespace ntp_snippets | 776 } // namespace ntp_snippets |
| OLD | NEW |