Chromium Code Reviews| 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/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> |
| 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" | |
| 22 #include "base/time/time.h" | 21 #include "base/time/time.h" |
| 23 #include "components/ntp_snippets/features.h" | 22 #include "components/ntp_snippets/features.h" |
| 24 #include "components/ntp_snippets/ntp_snippets_constants.h" | 23 #include "components/ntp_snippets/ntp_snippets_constants.h" |
| 25 #include "components/ntp_snippets/pref_names.h" | 24 #include "components/ntp_snippets/pref_names.h" |
| 26 #include "components/ntp_snippets/remote/persistent_scheduler.h" | 25 #include "components/ntp_snippets/remote/persistent_scheduler.h" |
| 27 #include "components/ntp_snippets/remote/remote_suggestions_provider.h" | 26 #include "components/ntp_snippets/remote/remote_suggestions_provider.h" |
| 28 #include "components/ntp_snippets/remote/test_utils.h" | 27 #include "components/ntp_snippets/remote/test_utils.h" |
| 29 #include "components/ntp_snippets/status.h" | 28 #include "components/ntp_snippets/status.h" |
| 30 #include "components/ntp_snippets/user_classifier.h" | 29 #include "components/ntp_snippets/user_classifier.h" |
| 31 #include "components/prefs/pref_registry_simple.h" | 30 #include "components/prefs/pref_registry_simple.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 MOCK_METHOD1(DismissSuggestion, void(const ContentSuggestion::ID&)); | 107 MOCK_METHOD1(DismissSuggestion, void(const ContentSuggestion::ID&)); |
| 109 MOCK_METHOD2(FetchSuggestionImage, | 108 MOCK_METHOD2(FetchSuggestionImage, |
| 110 void(const ContentSuggestion::ID&, const ImageFetchedCallback&)); | 109 void(const ContentSuggestion::ID&, const ImageFetchedCallback&)); |
| 111 MOCK_METHOD2(GetDismissedSuggestionsForDebugging, | 110 MOCK_METHOD2(GetDismissedSuggestionsForDebugging, |
| 112 void(Category, const DismissedSuggestionsCallback&)); | 111 void(Category, const DismissedSuggestionsCallback&)); |
| 113 MOCK_METHOD0(OnSignInStateChanged, void()); | 112 MOCK_METHOD0(OnSignInStateChanged, void()); |
| 114 }; | 113 }; |
| 115 | 114 |
| 116 } // namespace | 115 } // namespace |
| 117 | 116 |
| 118 class SchedulingRemoteSuggestionsProviderTest : public ::testing::Test { | 117 class RemoteSuggestionsSchedulerImplTest : public ::testing::Test { |
| 119 public: | 118 public: |
| 120 SchedulingRemoteSuggestionsProviderTest() | 119 RemoteSuggestionsSchedulerImplTest() |
| 121 : // For the test we enabled all trigger types. | 120 : // For the test we enabled all trigger types. |
| 122 default_variation_params_{{"scheduler_trigger_types", | 121 default_variation_params_{{"scheduler_trigger_types", |
| 123 "persistent_scheduler_wake_up,ntp_opened," | 122 "persistent_scheduler_wake_up,ntp_opened," |
| 124 "browser_foregrounded,browser_cold_start"}}, | 123 "browser_foregrounded,browser_cold_start"}}, |
| 125 params_manager_(ntp_snippets::kStudyName, | 124 params_manager_(ntp_snippets::kStudyName, |
| 126 default_variation_params_, | 125 default_variation_params_, |
| 127 {kArticleSuggestionsFeature.name}), | 126 {kArticleSuggestionsFeature.name}), |
| 128 underlying_provider_(nullptr), | 127 provider_(nullptr), |
| 129 scheduling_provider_(nullptr), | 128 scheduler_(nullptr), |
|
Marc Treib
2017/03/27 11:31:01
nit: unique_ptrs initialize themselves to nullptr
jkrcal
2017/03/27 14:09:31
Done.
| |
| 130 user_classifier_(/*pref_service=*/nullptr, | 129 user_classifier_(/*pref_service=*/nullptr, |
| 131 base::MakeUnique<base::DefaultClock>()) { | 130 base::MakeUnique<base::DefaultClock>()) { |
| 132 SchedulingRemoteSuggestionsProvider::RegisterProfilePrefs( | 131 RemoteSuggestionsSchedulerImpl::RegisterProfilePrefs( |
| 133 utils_.pref_service()->registry()); | 132 utils_.pref_service()->registry()); |
| 134 RequestThrottler::RegisterProfilePrefs(utils_.pref_service()->registry()); | 133 RequestThrottler::RegisterProfilePrefs(utils_.pref_service()->registry()); |
| 135 // TODO(jkrcal) Create a static function in EulaAcceptedNotifier that | 134 // TODO(jkrcal) Create a static function in EulaAcceptedNotifier that |
| 136 // registers this pref and replace the call in browser_process_impl.cc & in | 135 // registers this pref and replace the call in browser_process_impl.cc & in |
| 137 // eula_accepted_notifier_unittest.cc with the new static function. | 136 // eula_accepted_notifier_unittest.cc with the new static function. |
| 138 local_state_.registry()->RegisterBooleanPref(::prefs::kEulaAccepted, false); | 137 local_state_.registry()->RegisterBooleanPref(::prefs::kEulaAccepted, false); |
| 139 ResetProvider(); | 138 ResetProvider(); |
| 140 } | 139 } |
| 141 | 140 |
| 142 void ResetProvider() { | 141 void ResetProvider() { |
| 143 auto underlying_provider = | 142 provider_ = base::MakeUnique<StrictMock<MockRemoteSuggestionsProvider>>( |
| 144 base::MakeUnique<StrictMock<MockRemoteSuggestionsProvider>>( | 143 /*observer=*/nullptr); |
| 145 /*observer=*/nullptr); | |
| 146 underlying_provider_ = underlying_provider.get(); | |
| 147 | 144 |
| 148 auto test_clock = base::MakeUnique<base::SimpleTestClock>(); | 145 auto test_clock = base::MakeUnique<base::SimpleTestClock>(); |
| 149 test_clock_ = test_clock.get(); | 146 test_clock_ = test_clock.get(); |
| 150 test_clock_->SetNow(base::Time::Now()); | 147 test_clock_->SetNow(base::Time::Now()); |
| 151 | 148 |
| 152 scheduling_provider_ = | 149 scheduler_ = base::MakeUnique<RemoteSuggestionsSchedulerImpl>( |
| 153 base::MakeUnique<SchedulingRemoteSuggestionsProvider>( | 150 &persistent_scheduler_, &user_classifier_, utils_.pref_service(), |
| 154 /*observer=*/nullptr, std::move(underlying_provider), | 151 &local_state_, std::move(test_clock)); |
| 155 &persistent_scheduler_, &user_classifier_, utils_.pref_service(), | 152 scheduler_->set_provider(provider_.get()); |
| 156 &local_state_, std::move(test_clock)); | |
| 157 } | 153 } |
| 158 | 154 |
| 159 void SetVariationParameter(const std::string& param_name, | 155 void SetVariationParameter(const std::string& param_name, |
| 160 const std::string& param_value) { | 156 const std::string& param_value) { |
| 161 std::map<std::string, std::string> params = default_variation_params_; | 157 std::map<std::string, std::string> params = default_variation_params_; |
| 162 params[param_name] = param_value; | 158 params[param_name] = param_value; |
| 163 | 159 |
| 164 params_manager_.ClearAllVariationParams(); | 160 params_manager_.ClearAllVariationParams(); |
| 165 params_manager_.SetVariationParamsWithFeatureAssociations( | 161 params_manager_.SetVariationParamsWithFeatureAssociations( |
| 166 ntp_snippets::kStudyName, params, | 162 ntp_snippets::kStudyName, params, |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 184 fetch_done, | 180 fetch_done, |
| 185 Status status_code, | 181 Status status_code, |
| 186 std::vector<ContentSuggestion> suggestions) { | 182 std::vector<ContentSuggestion> suggestions) { |
| 187 fetch_done->Call(status_code, suggestions); | 183 fetch_done->Call(status_code, suggestions); |
| 188 } | 184 } |
| 189 | 185 |
| 190 protected: | 186 protected: |
| 191 std::map<std::string, std::string> default_variation_params_; | 187 std::map<std::string, std::string> default_variation_params_; |
| 192 variations::testing::VariationParamsManager params_manager_; | 188 variations::testing::VariationParamsManager params_manager_; |
| 193 StrictMock<MockPersistentScheduler> persistent_scheduler_; | 189 StrictMock<MockPersistentScheduler> persistent_scheduler_; |
| 194 StrictMock<MockRemoteSuggestionsProvider>* underlying_provider_; | 190 std::unique_ptr<MockRemoteSuggestionsProvider> provider_; |
| 195 std::unique_ptr<SchedulingRemoteSuggestionsProvider> scheduling_provider_; | 191 std::unique_ptr<RemoteSuggestionsSchedulerImpl> scheduler_; |
| 196 base::SimpleTestClock* test_clock_; | 192 base::SimpleTestClock* test_clock_; |
| 197 | 193 |
| 198 void ActivateUnderlyingProvider() { | 194 void ActivateProvider() { |
| 199 SetEulaAcceptedPref(); | 195 SetEulaAcceptedPref(); |
| 200 scheduling_provider_->OnProviderActivated(); | 196 scheduler_->OnProviderActivated(); |
| 201 } | 197 } |
| 202 | 198 |
| 203 void InactivateUnderlyingProvider() { | 199 void DeactivateProvider() { scheduler_->OnProviderDeactivated(); } |
| 204 scheduling_provider_->OnProviderDeactivated(); | |
| 205 } | |
| 206 | 200 |
| 207 private: | 201 private: |
| 208 test::RemoteSuggestionsTestUtils utils_; | 202 test::RemoteSuggestionsTestUtils utils_; |
| 209 UserClassifier user_classifier_; | 203 UserClassifier user_classifier_; |
| 210 TestingPrefServiceSimple local_state_; | 204 TestingPrefServiceSimple local_state_; |
| 211 | 205 |
| 212 DISALLOW_COPY_AND_ASSIGN(SchedulingRemoteSuggestionsProviderTest); | 206 DISALLOW_COPY_AND_ASSIGN(RemoteSuggestionsSchedulerImplTest); |
| 213 }; | 207 }; |
| 214 | 208 |
| 215 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 209 TEST_F(RemoteSuggestionsSchedulerImplTest, ShouldIgnoreSignalsWhenNotEnabled) { |
| 216 ShouldIgnoreSignalsWhenNotEnabled) { | 210 scheduler_->OnPersistentSchedulerWakeUp(); |
| 217 scheduling_provider_->OnPersistentSchedulerWakeUp(); | 211 scheduler_->OnNTPOpened(); |
| 218 scheduling_provider_->OnNTPOpened(); | 212 scheduler_->OnBrowserForegrounded(); |
| 219 scheduling_provider_->OnBrowserForegrounded(); | 213 scheduler_->OnBrowserColdStart(); |
| 220 scheduling_provider_->OnBrowserColdStart(); | |
| 221 } | 214 } |
| 222 | 215 |
| 223 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 216 TEST_F(RemoteSuggestionsSchedulerImplTest, |
| 224 ShouldIgnoreEulaStateOnPlatformsWhereNotAvaiable) { | 217 ShouldIgnoreEulaStateOnPlatformsWhereNotAvaiable) { |
| 225 // Only run this tests on platforms that don't support Eula. | 218 // Only run this tests on platforms that don't support Eula. |
| 226 if (IsEulaNotifierAvailable()) { | 219 if (IsEulaNotifierAvailable()) { |
| 227 return; | 220 return; |
| 228 } | 221 } |
| 229 | 222 |
| 230 // Activating the provider should schedule the persistent background fetches. | 223 // Activating the provider should schedule the persistent background fetches. |
| 231 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 224 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 232 scheduling_provider_->OnProviderActivated(); | 225 scheduler_->OnProviderActivated(); |
| 233 | 226 |
| 234 // Verify fetches get triggered. | 227 // Verify fetches get triggered. |
| 235 EXPECT_CALL(*underlying_provider_, RefetchInTheBackground(_)); | 228 EXPECT_CALL(*provider_, RefetchInTheBackground(_)); |
| 236 scheduling_provider_->OnPersistentSchedulerWakeUp(); | 229 scheduler_->OnPersistentSchedulerWakeUp(); |
| 237 } | 230 } |
| 238 | 231 |
| 239 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 232 TEST_F(RemoteSuggestionsSchedulerImplTest, |
| 240 ShouldIgnoreSignalsWhenEulaNotAccepted) { | 233 ShouldIgnoreSignalsWhenEulaNotAccepted) { |
| 241 // Only run this tests on platforms supporting Eula. | 234 // Only run this tests on platforms supporting Eula. |
| 242 if (!IsEulaNotifierAvailable()) { | 235 if (!IsEulaNotifierAvailable()) { |
| 243 return; | 236 return; |
| 244 } | 237 } |
| 245 // Activating the provider should schedule the persistent background fetches. | 238 // Activating the provider should schedule the persistent background fetches. |
| 246 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 239 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 247 scheduling_provider_->OnProviderActivated(); | 240 scheduler_->OnProviderActivated(); |
| 248 | 241 |
| 249 // All signals are ignored because of Eula not being accepted. | 242 // All signals are ignored because of Eula not being accepted. |
| 250 scheduling_provider_->OnPersistentSchedulerWakeUp(); | 243 scheduler_->OnPersistentSchedulerWakeUp(); |
| 251 scheduling_provider_->OnNTPOpened(); | 244 scheduler_->OnNTPOpened(); |
| 252 scheduling_provider_->OnBrowserForegrounded(); | 245 scheduler_->OnBrowserForegrounded(); |
| 253 scheduling_provider_->OnBrowserColdStart(); | 246 scheduler_->OnBrowserColdStart(); |
| 254 } | 247 } |
| 255 | 248 |
| 256 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 249 TEST_F(RemoteSuggestionsSchedulerImplTest, ShouldFetchWhenEulaGetsAccepted) { |
| 257 ShouldFetchWhenEulaGetsAccepted) { | |
| 258 // Only run this tests on platforms supporting Eula. | 250 // Only run this tests on platforms supporting Eula. |
| 259 if (!IsEulaNotifierAvailable()) { | 251 if (!IsEulaNotifierAvailable()) { |
| 260 return; | 252 return; |
| 261 } | 253 } |
| 262 // Activating the provider should schedule the persistent background fetches. | 254 // Activating the provider should schedule the persistent background fetches. |
| 263 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 255 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 264 scheduling_provider_->OnProviderActivated(); | 256 scheduler_->OnProviderActivated(); |
| 265 | 257 |
| 266 // Make one (ignored) call to make sure we are interested in eula state. | 258 // Make one (ignored) call to make sure we are interested in eula state. |
| 267 scheduling_provider_->OnPersistentSchedulerWakeUp(); | 259 scheduler_->OnPersistentSchedulerWakeUp(); |
| 268 | 260 |
| 269 // Accepting Eula afterwards results in a background fetch. | 261 // Accepting Eula afterwards results in a background fetch. |
| 270 EXPECT_CALL(*underlying_provider_, RefetchInTheBackground(_)); | 262 EXPECT_CALL(*provider_, RefetchInTheBackground(_)); |
| 271 SetEulaAcceptedPref(); | 263 SetEulaAcceptedPref(); |
| 272 } | 264 } |
| 273 | 265 |
| 274 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 266 TEST_F(RemoteSuggestionsSchedulerImplTest, |
| 275 ShouldIgnoreSignalsWhenDisabledByParam) { | 267 ShouldIgnoreSignalsWhenDisabledByParam) { |
| 276 // First set an empty list of allowed trigger types. | 268 // First set an empty list of allowed trigger types. |
| 277 SetVariationParameter("scheduler_trigger_types", "-"); | 269 SetVariationParameter("scheduler_trigger_types", "-"); |
| 278 ResetProvider(); | 270 ResetProvider(); |
| 279 | 271 |
| 280 // Then enable the scheduler. | 272 // Then enable the scheduler. |
| 281 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 273 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 282 ActivateUnderlyingProvider(); | 274 ActivateProvider(); |
| 283 | 275 |
| 284 scheduling_provider_->OnPersistentSchedulerWakeUp(); | 276 scheduler_->OnPersistentSchedulerWakeUp(); |
| 285 scheduling_provider_->OnNTPOpened(); | 277 scheduler_->OnNTPOpened(); |
| 286 scheduling_provider_->OnBrowserForegrounded(); | 278 scheduler_->OnBrowserForegrounded(); |
| 287 scheduling_provider_->OnBrowserColdStart(); | 279 scheduler_->OnBrowserColdStart(); |
| 288 } | 280 } |
| 289 | 281 |
| 290 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 282 TEST_F(RemoteSuggestionsSchedulerImplTest, |
| 291 ShouldHandleEmptyParamForTriggerTypes) { | 283 ShouldHandleEmptyParamForTriggerTypes) { |
| 292 // First set an empty param for allowed trigger types -> should result in the | 284 // First set an empty param for allowed trigger types -> should result in the |
| 293 // default list. | 285 // default list. |
| 294 SetVariationParameter("scheduler_trigger_types", ""); | 286 SetVariationParameter("scheduler_trigger_types", ""); |
| 295 ResetProvider(); | 287 ResetProvider(); |
| 296 | 288 |
| 297 // Then enable the scheduler. | 289 // Then enable the scheduler. |
| 298 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 290 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 299 ActivateUnderlyingProvider(); | 291 ActivateProvider(); |
| 300 | 292 |
| 301 // For instance, persistent scheduler wake up should be enabled by default. | 293 // For instance, persistent scheduler wake up should be enabled by default. |
| 302 EXPECT_CALL(*underlying_provider_, RefetchInTheBackground(_)); | 294 EXPECT_CALL(*provider_, RefetchInTheBackground(_)); |
| 303 scheduling_provider_->OnPersistentSchedulerWakeUp(); | 295 scheduler_->OnPersistentSchedulerWakeUp(); |
| 304 } | 296 } |
| 305 | 297 |
| 306 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 298 TEST_F(RemoteSuggestionsSchedulerImplTest, |
| 307 ShouldHandleIncorrentParamForTriggerTypes) { | 299 ShouldHandleIncorrentParamForTriggerTypes) { |
| 308 // First set an invalid list of allowed trigger types. | 300 // First set an invalid list of allowed trigger types. |
| 309 SetVariationParameter("scheduler_trigger_types", "ntp_opened,foo;"); | 301 SetVariationParameter("scheduler_trigger_types", "ntp_opened,foo;"); |
| 310 ResetProvider(); | 302 ResetProvider(); |
| 311 | 303 |
| 312 // Then enable the scheduler. | 304 // Then enable the scheduler. |
| 313 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 305 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 314 ActivateUnderlyingProvider(); | 306 ActivateProvider(); |
| 315 | 307 |
| 316 // For instance, persistent scheduler wake up should be enabled by default. | 308 // For instance, persistent scheduler wake up should be enabled by default. |
| 317 EXPECT_CALL(*underlying_provider_, RefetchInTheBackground(_)); | 309 EXPECT_CALL(*provider_, RefetchInTheBackground(_)); |
| 318 scheduling_provider_->OnPersistentSchedulerWakeUp(); | 310 scheduler_->OnPersistentSchedulerWakeUp(); |
| 319 } | 311 } |
| 320 | 312 |
| 321 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 313 TEST_F(RemoteSuggestionsSchedulerImplTest, |
| 322 ShouldFetchOnPersistentSchedulerWakeUp) { | 314 ShouldFetchOnPersistentSchedulerWakeUp) { |
| 323 // First set only this type to be allowed. | 315 // First set only this type to be allowed. |
| 324 SetVariationParameter("scheduler_trigger_types", | 316 SetVariationParameter("scheduler_trigger_types", |
| 325 "persistent_scheduler_wake_up"); | 317 "persistent_scheduler_wake_up"); |
| 326 ResetProvider(); | 318 ResetProvider(); |
| 327 | 319 |
| 328 // Then enable the scheduler. | 320 // Then enable the scheduler. |
| 329 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 321 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 330 ActivateUnderlyingProvider(); | 322 ActivateProvider(); |
| 331 | 323 |
| 332 EXPECT_CALL(*underlying_provider_, RefetchInTheBackground(_)); | 324 EXPECT_CALL(*provider_, RefetchInTheBackground(_)); |
| 333 scheduling_provider_->OnPersistentSchedulerWakeUp(); | 325 scheduler_->OnPersistentSchedulerWakeUp(); |
| 334 } | 326 } |
| 335 | 327 |
| 336 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 328 TEST_F(RemoteSuggestionsSchedulerImplTest, |
| 337 ShouldFetchOnPersistentSchedulerWakeUpRepeated) { | 329 ShouldFetchOnPersistentSchedulerWakeUpRepeated) { |
| 338 RemoteSuggestionsProvider::FetchStatusCallback signal_fetch_done; | 330 RemoteSuggestionsProvider::FetchStatusCallback signal_fetch_done; |
| 339 { | 331 { |
| 340 InSequence s; | 332 InSequence s; |
| 341 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 333 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 342 EXPECT_CALL(*underlying_provider_, RefetchInTheBackground(_)) | 334 EXPECT_CALL(*provider_, RefetchInTheBackground(_)) |
| 343 .WillOnce(SaveArg<0>(&signal_fetch_done)); | 335 .WillOnce(SaveArg<0>(&signal_fetch_done)); |
| 344 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 336 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 345 EXPECT_CALL(*underlying_provider_, RefetchInTheBackground(_)); | 337 EXPECT_CALL(*provider_, RefetchInTheBackground(_)); |
| 346 } | 338 } |
| 347 // First enable the scheduler -- calling Schedule() for the first time. | 339 // First enable the scheduler -- calling Schedule() for the first time. |
| 348 ActivateUnderlyingProvider(); | 340 ActivateProvider(); |
| 349 // Make the first persistent fetch successful -- calling Schedule() again. | 341 // Make the first persistent fetch successful -- calling Schedule() again. |
| 350 scheduling_provider_->OnPersistentSchedulerWakeUp(); | 342 scheduler_->OnPersistentSchedulerWakeUp(); |
| 351 signal_fetch_done.Run(Status::Success()); | 343 signal_fetch_done.Run(Status::Success()); |
| 352 // Make the second fetch. | 344 // Make the second fetch. |
| 353 scheduling_provider_->OnPersistentSchedulerWakeUp(); | 345 scheduler_->OnPersistentSchedulerWakeUp(); |
| 354 } | 346 } |
| 355 | 347 |
| 356 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 348 TEST_F(RemoteSuggestionsSchedulerImplTest, |
| 357 ShouldNotTriggerBackgroundFetchIfAlreadyInProgess) { | 349 ShouldNotTriggerBackgroundFetchIfAlreadyInProgess) { |
| 358 { | 350 { |
| 359 InSequence s; | 351 InSequence s; |
| 360 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 352 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 361 EXPECT_CALL(*underlying_provider_, RefetchInTheBackground(_)); | 353 EXPECT_CALL(*provider_, RefetchInTheBackground(_)); |
| 362 // RefetchInTheBackground is not called after the second trigger. | 354 // RefetchInTheBackground is not called after the second trigger. |
| 363 } | 355 } |
| 364 // First enable the scheduler -- calling Schedule() for the first time. | 356 // First enable the scheduler -- calling Schedule() for the first time. |
| 365 ActivateUnderlyingProvider(); | 357 ActivateProvider(); |
| 366 // Make the first persistent fetch never finish. | 358 // Make the first persistent fetch never finish. |
| 367 scheduling_provider_->OnPersistentSchedulerWakeUp(); | 359 scheduler_->OnPersistentSchedulerWakeUp(); |
| 368 // Make the second fetch. | 360 // Make the second fetch. |
| 369 scheduling_provider_->OnPersistentSchedulerWakeUp(); | 361 scheduler_->OnPersistentSchedulerWakeUp(); |
| 370 } | 362 } |
| 371 | 363 |
| 372 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 364 TEST_F(RemoteSuggestionsSchedulerImplTest, |
| 373 ShouldFetchOnNTPOpenedForTheFirstTime) { | 365 ShouldFetchOnNTPOpenedForTheFirstTime) { |
| 374 // First set only this type to be allowed. | 366 // First set only this type to be allowed. |
| 375 SetVariationParameter("scheduler_trigger_types", "ntp_opened"); | 367 SetVariationParameter("scheduler_trigger_types", "ntp_opened"); |
| 376 ResetProvider(); | 368 ResetProvider(); |
| 377 | 369 |
| 378 // Then enable the scheduler. | 370 // Then enable the scheduler. |
| 379 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 371 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 380 ActivateUnderlyingProvider(); | 372 ActivateProvider(); |
| 381 | 373 |
| 382 EXPECT_CALL(*underlying_provider_, RefetchInTheBackground(_)); | 374 EXPECT_CALL(*provider_, RefetchInTheBackground(_)); |
| 383 scheduling_provider_->OnNTPOpened(); | 375 scheduler_->OnNTPOpened(); |
| 384 } | 376 } |
| 385 | 377 |
| 386 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 378 TEST_F(RemoteSuggestionsSchedulerImplTest, |
| 387 ShouldFetchOnBrowserForegroundedForTheFirstTime) { | 379 ShouldFetchOnBrowserForegroundedForTheFirstTime) { |
| 388 // First set only this type to be allowed. | 380 // First set only this type to be allowed. |
| 389 SetVariationParameter("scheduler_trigger_types", "browser_foregrounded"); | 381 SetVariationParameter("scheduler_trigger_types", "browser_foregrounded"); |
| 390 ResetProvider(); | 382 ResetProvider(); |
| 391 | 383 |
| 392 // Then enable the scheduler. | 384 // Then enable the scheduler. |
| 393 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 385 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 394 ActivateUnderlyingProvider(); | 386 ActivateProvider(); |
| 395 | 387 |
| 396 EXPECT_CALL(*underlying_provider_, RefetchInTheBackground(_)); | 388 EXPECT_CALL(*provider_, RefetchInTheBackground(_)); |
| 397 scheduling_provider_->OnBrowserForegrounded(); | 389 scheduler_->OnBrowserForegrounded(); |
| 398 } | 390 } |
| 399 | 391 |
| 400 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 392 TEST_F(RemoteSuggestionsSchedulerImplTest, |
| 401 ShouldFetchOnBrowserColdStartForTheFirstTime) { | 393 ShouldFetchOnBrowserColdStartForTheFirstTime) { |
| 402 // First set only this type to be allowed. | 394 // First set only this type to be allowed. |
| 403 SetVariationParameter("scheduler_trigger_types", "browser_cold_start"); | 395 SetVariationParameter("scheduler_trigger_types", "browser_cold_start"); |
| 404 ResetProvider(); | 396 ResetProvider(); |
| 405 | 397 |
| 406 // Then enable the scheduler. | 398 // Then enable the scheduler. |
| 407 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 399 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 408 ActivateUnderlyingProvider(); | 400 ActivateProvider(); |
| 409 | 401 |
| 410 EXPECT_CALL(*underlying_provider_, RefetchInTheBackground(_)); | 402 EXPECT_CALL(*provider_, RefetchInTheBackground(_)); |
| 411 scheduling_provider_->OnBrowserColdStart(); | 403 scheduler_->OnBrowserColdStart(); |
| 412 } | 404 } |
| 413 | 405 |
| 414 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 406 TEST_F(RemoteSuggestionsSchedulerImplTest, |
| 415 ShouldNotFetchOnNTPOpenedAfterSuccessfulSoftFetch) { | 407 ShouldNotFetchOnNTPOpenedAfterSuccessfulSoftFetch) { |
| 416 // First enable the scheduler; the second Schedule is called after the | 408 // First enable the scheduler; the second Schedule is called after the |
| 417 // successful fetch. | 409 // successful fetch. |
| 418 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)).Times(2); | 410 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)).Times(2); |
| 419 ActivateUnderlyingProvider(); | 411 ActivateProvider(); |
| 420 | 412 |
| 421 // Make the first soft fetch successful. | 413 // Make the first soft fetch successful. |
| 422 RemoteSuggestionsProvider::FetchStatusCallback signal_fetch_done; | 414 RemoteSuggestionsProvider::FetchStatusCallback signal_fetch_done; |
| 423 EXPECT_CALL(*underlying_provider_, RefetchInTheBackground(_)) | 415 EXPECT_CALL(*provider_, RefetchInTheBackground(_)) |
| 424 .WillOnce(SaveArg<0>(&signal_fetch_done)); | 416 .WillOnce(SaveArg<0>(&signal_fetch_done)); |
| 425 scheduling_provider_->OnNTPOpened(); | 417 scheduler_->OnNTPOpened(); |
| 426 signal_fetch_done.Run(Status::Success()); | 418 signal_fetch_done.Run(Status::Success()); |
| 427 // The second call is ignored if it happens right after the first one. | 419 // The second call is ignored if it happens right after the first one. |
| 428 scheduling_provider_->OnNTPOpened(); | 420 scheduler_->OnNTPOpened(); |
| 429 } | 421 } |
| 430 | 422 |
| 431 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 423 TEST_F(RemoteSuggestionsSchedulerImplTest, |
| 432 ShouldNotFetchOnNTPOpenedAfterSuccessfulPersistentFetch) { | 424 ShouldNotFetchOnNTPOpenedAfterSuccessfulPersistentFetch) { |
| 433 // First enable the scheduler; the second Schedule is called after the | 425 // First enable the scheduler; the second Schedule is called after the |
| 434 // successful fetch. | 426 // successful fetch. |
| 435 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)).Times(2); | 427 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)).Times(2); |
| 436 ActivateUnderlyingProvider(); | 428 ActivateProvider(); |
| 437 | 429 |
| 438 // Make the first persistent fetch successful. | 430 // Make the first persistent fetch successful. |
| 439 RemoteSuggestionsProvider::FetchStatusCallback signal_fetch_done; | 431 RemoteSuggestionsProvider::FetchStatusCallback signal_fetch_done; |
| 440 EXPECT_CALL(*underlying_provider_, RefetchInTheBackground(_)) | 432 EXPECT_CALL(*provider_, RefetchInTheBackground(_)) |
| 441 .WillOnce(SaveArg<0>(&signal_fetch_done)); | 433 .WillOnce(SaveArg<0>(&signal_fetch_done)); |
| 442 scheduling_provider_->OnPersistentSchedulerWakeUp(); | 434 scheduler_->OnPersistentSchedulerWakeUp(); |
| 443 signal_fetch_done.Run(Status::Success()); | 435 signal_fetch_done.Run(Status::Success()); |
| 444 // The second call is ignored if it happens right after the first one. | 436 // The second call is ignored if it happens right after the first one. |
| 445 scheduling_provider_->OnNTPOpened(); | 437 scheduler_->OnNTPOpened(); |
| 446 } | 438 } |
| 447 | 439 |
| 448 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 440 TEST_F(RemoteSuggestionsSchedulerImplTest, |
| 449 ShouldNotFetchOnNTPOpenedAfterFailedSoftFetch) { | 441 ShouldNotFetchOnNTPOpenedAfterFailedSoftFetch) { |
| 450 // First enable the scheduler. | 442 // First enable the scheduler. |
| 451 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 443 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 452 ActivateUnderlyingProvider(); | 444 ActivateProvider(); |
| 453 | 445 |
| 454 // Make the first soft fetch failed. | 446 // Make the first soft fetch failed. |
| 455 RemoteSuggestionsProvider::FetchStatusCallback signal_fetch_done; | 447 RemoteSuggestionsProvider::FetchStatusCallback signal_fetch_done; |
| 456 EXPECT_CALL(*underlying_provider_, RefetchInTheBackground(_)) | 448 EXPECT_CALL(*provider_, RefetchInTheBackground(_)) |
| 457 .WillOnce(SaveArg<0>(&signal_fetch_done)); | 449 .WillOnce(SaveArg<0>(&signal_fetch_done)); |
| 458 scheduling_provider_->OnNTPOpened(); | 450 scheduler_->OnNTPOpened(); |
| 459 signal_fetch_done.Run(Status(StatusCode::PERMANENT_ERROR, "")); | 451 signal_fetch_done.Run(Status(StatusCode::PERMANENT_ERROR, "")); |
| 460 | 452 |
| 461 // The second call is ignored if it happens right after the first one. | 453 // The second call is ignored if it happens right after the first one. |
| 462 scheduling_provider_->OnNTPOpened(); | 454 scheduler_->OnNTPOpened(); |
| 463 } | 455 } |
| 464 | 456 |
| 465 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 457 TEST_F(RemoteSuggestionsSchedulerImplTest, |
| 466 ShouldNotFetchOnNTPOpenedAfterFailedPersistentFetch) { | 458 ShouldNotFetchOnNTPOpenedAfterFailedPersistentFetch) { |
| 467 // First enable the scheduler. | 459 // First enable the scheduler. |
| 468 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 460 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 469 ActivateUnderlyingProvider(); | 461 ActivateProvider(); |
| 470 | 462 |
| 471 // Make the first persistent fetch failed. | 463 // Make the first persistent fetch failed. |
| 472 RemoteSuggestionsProvider::FetchStatusCallback signal_fetch_done; | 464 RemoteSuggestionsProvider::FetchStatusCallback signal_fetch_done; |
| 473 EXPECT_CALL(*underlying_provider_, RefetchInTheBackground(_)) | 465 EXPECT_CALL(*provider_, RefetchInTheBackground(_)) |
| 474 .WillOnce(SaveArg<0>(&signal_fetch_done)); | 466 .WillOnce(SaveArg<0>(&signal_fetch_done)); |
| 475 scheduling_provider_->OnPersistentSchedulerWakeUp(); | 467 scheduler_->OnPersistentSchedulerWakeUp(); |
| 476 signal_fetch_done.Run(Status(StatusCode::PERMANENT_ERROR, "")); | 468 signal_fetch_done.Run(Status(StatusCode::PERMANENT_ERROR, "")); |
| 477 | 469 |
| 478 // The second call is ignored if it happens right after the first one. | 470 // The second call is ignored if it happens right after the first one. |
| 479 scheduling_provider_->OnNTPOpened(); | 471 scheduler_->OnNTPOpened(); |
| 480 } | 472 } |
| 481 | 473 |
| 482 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 474 TEST_F(RemoteSuggestionsSchedulerImplTest, |
| 483 ShouldFetchAgainOnBrowserForgroundLaterAgain) { | 475 ShouldFetchAgainOnBrowserForgroundLaterAgain) { |
| 484 RemoteSuggestionsProvider::FetchStatusCallback signal_fetch_done; | 476 RemoteSuggestionsProvider::FetchStatusCallback signal_fetch_done; |
| 485 { | 477 { |
| 486 InSequence s; | 478 InSequence s; |
| 487 // Initial scheduling after being enabled. | 479 // Initial scheduling after being enabled. |
| 488 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 480 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 489 // The first call to NTPOpened results in a fetch. | 481 // The first call to NTPOpened results in a fetch. |
| 490 EXPECT_CALL(*underlying_provider_, RefetchInTheBackground(_)) | 482 EXPECT_CALL(*provider_, RefetchInTheBackground(_)) |
| 491 .WillOnce(SaveArg<0>(&signal_fetch_done)); | 483 .WillOnce(SaveArg<0>(&signal_fetch_done)); |
| 492 // Rescheduling after a succesful fetch. | 484 // Rescheduling after a succesful fetch. |
| 493 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 485 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 494 // The second call to NTPOpened 2hrs later again results in a fetch. | 486 // The second call to NTPOpened 2hrs later again results in a fetch. |
| 495 EXPECT_CALL(*underlying_provider_, RefetchInTheBackground(_)); | 487 EXPECT_CALL(*provider_, RefetchInTheBackground(_)); |
| 496 } | 488 } |
| 497 | 489 |
| 498 // First enable the scheduler. | 490 // First enable the scheduler. |
| 499 ActivateUnderlyingProvider(); | 491 ActivateProvider(); |
| 500 // Make the first soft fetch successful. | 492 // Make the first soft fetch successful. |
| 501 scheduling_provider_->OnBrowserForegrounded(); | 493 scheduler_->OnBrowserForegrounded(); |
| 502 signal_fetch_done.Run(Status::Success()); | 494 signal_fetch_done.Run(Status::Success()); |
| 503 // Open NTP again after 2hrs. | 495 // Open NTP again after 2hrs. |
| 504 test_clock_->Advance(base::TimeDelta::FromHours(2)); | 496 test_clock_->Advance(base::TimeDelta::FromHours(2)); |
| 505 scheduling_provider_->OnBrowserForegrounded(); | 497 scheduler_->OnBrowserForegrounded(); |
| 506 } | 498 } |
| 507 | 499 |
| 508 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 500 TEST_F(RemoteSuggestionsSchedulerImplTest, |
| 509 ShouldRescheduleOnRescheduleFetching) { | 501 ShouldRescheduleOnRescheduleFetching) { |
| 510 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 502 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 511 scheduling_provider_->RescheduleFetching(); | 503 scheduler_->RescheduleFetching(); |
| 512 } | 504 } |
| 513 | 505 |
| 514 TEST_F(SchedulingRemoteSuggestionsProviderTest, ShouldScheduleOnActivation) { | 506 TEST_F(RemoteSuggestionsSchedulerImplTest, ShouldScheduleOnActivation) { |
| 515 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 507 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 516 ActivateUnderlyingProvider(); | 508 ActivateProvider(); |
| 517 } | 509 } |
| 518 | 510 |
| 519 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 511 TEST_F(RemoteSuggestionsSchedulerImplTest, |
| 520 ShouldUnscheduleOnLaterInactivation) { | 512 ShouldUnscheduleOnLaterInactivation) { |
| 521 { | 513 { |
| 522 InSequence s; | 514 InSequence s; |
| 523 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 515 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 524 EXPECT_CALL(persistent_scheduler_, Unschedule()); | 516 EXPECT_CALL(persistent_scheduler_, Unschedule()); |
| 525 } | 517 } |
| 526 ActivateUnderlyingProvider(); | 518 ActivateProvider(); |
| 527 InactivateUnderlyingProvider(); | 519 DeactivateProvider(); |
| 528 } | 520 } |
| 529 | 521 |
| 530 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 522 TEST_F(RemoteSuggestionsSchedulerImplTest, ShouldScheduleOnLaterActivation) { |
| 531 ShouldScheduleOnLaterActivation) { | |
| 532 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 523 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 533 // There is no schedule yet, so inactivation does not trigger unschedule. | 524 // There is no schedule yet, so inactivation does not trigger unschedule. |
| 534 InactivateUnderlyingProvider(); | 525 DeactivateProvider(); |
| 535 ActivateUnderlyingProvider(); | 526 ActivateProvider(); |
| 536 } | 527 } |
| 537 | 528 |
| 538 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 529 TEST_F(RemoteSuggestionsSchedulerImplTest, |
| 539 ShouldRescheduleAfterSuccessfulFetch) { | 530 ShouldRescheduleAfterSuccessfulFetch) { |
| 540 // First reschedule on becoming active. | 531 // First reschedule on becoming active. |
| 541 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)).Times(2); | 532 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)).Times(2); |
| 542 ActivateUnderlyingProvider(); | 533 ActivateProvider(); |
| 543 | 534 |
| 544 RemoteSuggestionsProvider::FetchStatusCallback signal_fetch_done; | 535 RemoteSuggestionsProvider::FetchStatusCallback signal_fetch_done; |
| 545 EXPECT_CALL(*underlying_provider_, RefetchInTheBackground(_)) | 536 EXPECT_CALL(*provider_, RefetchInTheBackground(_)) |
| 546 .WillOnce(SaveArg<0>(&signal_fetch_done)); | 537 .WillOnce(SaveArg<0>(&signal_fetch_done)); |
| 547 | 538 |
| 548 // Trigger a fetch. | 539 // Trigger a fetch. |
| 549 scheduling_provider_->OnPersistentSchedulerWakeUp(); | 540 scheduler_->OnPersistentSchedulerWakeUp(); |
| 550 // Second reschedule after a successful fetch. | 541 // Second reschedule after a successful fetch. |
| 551 signal_fetch_done.Run(Status::Success()); | 542 signal_fetch_done.Run(Status::Success()); |
| 552 } | 543 } |
| 553 | 544 |
| 554 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 545 TEST_F(RemoteSuggestionsSchedulerImplTest, |
| 555 ShouldNotRescheduleAfterFailedFetch) { | 546 ShouldNotRescheduleAfterFailedFetch) { |
| 556 // Only reschedule on becoming active. | 547 // Only reschedule on becoming active. |
| 557 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 548 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 558 ActivateUnderlyingProvider(); | 549 ActivateProvider(); |
| 559 | 550 |
| 560 RemoteSuggestionsProvider::FetchStatusCallback signal_fetch_done; | 551 RemoteSuggestionsProvider::FetchStatusCallback signal_fetch_done; |
| 561 EXPECT_CALL(*underlying_provider_, RefetchInTheBackground(_)) | 552 EXPECT_CALL(*provider_, RefetchInTheBackground(_)) |
| 562 .WillOnce(SaveArg<0>(&signal_fetch_done)); | 553 .WillOnce(SaveArg<0>(&signal_fetch_done)); |
| 563 | 554 |
| 564 // Trigger a fetch. | 555 // Trigger a fetch. |
| 565 scheduling_provider_->OnPersistentSchedulerWakeUp(); | 556 scheduler_->OnPersistentSchedulerWakeUp(); |
| 566 // No furter reschedule after a failure. | 557 // No furter reschedule after a failure. |
| 567 signal_fetch_done.Run(Status(StatusCode::PERMANENT_ERROR, "")); | 558 signal_fetch_done.Run(Status(StatusCode::PERMANENT_ERROR, "")); |
| 568 } | 559 } |
| 569 | 560 |
| 570 TEST_F(SchedulingRemoteSuggestionsProviderTest, ShouldScheduleOnlyOnce) { | 561 TEST_F(RemoteSuggestionsSchedulerImplTest, ShouldScheduleOnlyOnce) { |
| 571 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 562 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 572 ActivateUnderlyingProvider(); | 563 ActivateProvider(); |
| 573 // No further call to Schedule on a second status callback. | 564 // No further call to Schedule on a second status callback. |
| 574 ActivateUnderlyingProvider(); | 565 ActivateProvider(); |
| 575 } | 566 } |
| 576 | 567 |
| 577 TEST_F(SchedulingRemoteSuggestionsProviderTest, ShouldUnscheduleOnlyOnce) { | 568 TEST_F(RemoteSuggestionsSchedulerImplTest, ShouldUnscheduleOnlyOnce) { |
| 578 { | 569 { |
| 579 InSequence s; | 570 InSequence s; |
| 580 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 571 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 581 EXPECT_CALL(persistent_scheduler_, Unschedule()); | 572 EXPECT_CALL(persistent_scheduler_, Unschedule()); |
| 582 } | 573 } |
| 583 // First schedule so that later we really unschedule. | 574 // First schedule so that later we really unschedule. |
| 584 ActivateUnderlyingProvider(); | 575 ActivateProvider(); |
| 585 InactivateUnderlyingProvider(); | 576 DeactivateProvider(); |
| 586 // No further call to Unschedule on second status callback. | 577 // No further call to Unschedule on second status callback. |
| 587 InactivateUnderlyingProvider(); | 578 DeactivateProvider(); |
| 588 } | 579 } |
| 589 | 580 |
| 590 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 581 TEST_F(RemoteSuggestionsSchedulerImplTest, ReschedulesWhenWifiParamChanges) { |
| 591 ReschedulesWhenWifiParamChanges) { | |
| 592 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)).Times(2); | 582 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)).Times(2); |
| 593 ActivateUnderlyingProvider(); | 583 ActivateProvider(); |
| 594 | 584 |
| 595 // UserClassifier defaults to UserClass::ACTIVE_NTP_USER if PrefService is | 585 // UserClassifier defaults to UserClass::ACTIVE_NTP_USER if PrefService is |
| 596 // null. Change the wifi interval for this class. | 586 // null. Change the wifi interval for this class. |
| 597 SetVariationParameter("fetching_interval_hours-wifi-active_ntp_user", "1.5"); | 587 SetVariationParameter("fetching_interval_hours-wifi-active_ntp_user", "1.5"); |
| 598 | 588 |
| 599 // Schedule() should get called for the second time after params have changed. | 589 // Schedule() should get called for the second time after params have changed. |
| 600 ActivateUnderlyingProvider(); | 590 ActivateProvider(); |
| 601 } | 591 } |
| 602 | 592 |
| 603 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 593 TEST_F(RemoteSuggestionsSchedulerImplTest, |
| 604 ReschedulesWhenFallbackParamChanges) { | 594 ReschedulesWhenFallbackParamChanges) { |
| 605 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)).Times(2); | 595 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)).Times(2); |
| 606 ActivateUnderlyingProvider(); | 596 ActivateProvider(); |
| 607 | 597 |
| 608 // UserClassifier defaults to UserClass::ACTIVE_NTP_USER if PrefService is | 598 // UserClassifier defaults to UserClass::ACTIVE_NTP_USER if PrefService is |
| 609 // null. Change the fallback interval for this class. | 599 // null. Change the fallback interval for this class. |
| 610 SetVariationParameter("fetching_interval_hours-fallback-active_ntp_user", | 600 SetVariationParameter("fetching_interval_hours-fallback-active_ntp_user", |
| 611 "1.5"); | 601 "1.5"); |
| 612 | 602 |
| 613 // Schedule() should get called for the second time after params have changed. | 603 // Schedule() should get called for the second time after params have changed. |
| 614 ActivateUnderlyingProvider(); | 604 ActivateProvider(); |
| 615 } | 605 } |
| 616 | 606 |
| 617 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 607 TEST_F(RemoteSuggestionsSchedulerImplTest, |
| 618 ReschedulesWhenOnUsageEventParamChanges) { | 608 ReschedulesWhenOnUsageEventParamChanges) { |
| 619 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)).Times(2); | 609 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)).Times(2); |
| 620 ActivateUnderlyingProvider(); | 610 ActivateProvider(); |
| 621 | 611 |
| 622 // UserClassifier defaults to UserClass::ACTIVE_NTP_USER if PrefService is | 612 // UserClassifier defaults to UserClass::ACTIVE_NTP_USER if PrefService is |
| 623 // null. Change the on usage interval for this class. | 613 // null. Change the on usage interval for this class. |
| 624 SetVariationParameter("soft_fetching_interval_hours-active-active_ntp_user", | 614 SetVariationParameter("soft_fetching_interval_hours-active-active_ntp_user", |
| 625 "1.5"); | 615 "1.5"); |
| 626 | 616 |
| 627 // Schedule() should get called for the second time after params have changed. | 617 // Schedule() should get called for the second time after params have changed. |
| 628 ActivateUnderlyingProvider(); | 618 ActivateProvider(); |
| 629 } | 619 } |
| 630 | 620 |
| 631 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 621 TEST_F(RemoteSuggestionsSchedulerImplTest, |
| 632 ReschedulesWhenOnNtpOpenedParamChanges) { | 622 ReschedulesWhenOnNtpOpenedParamChanges) { |
| 633 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)).Times(2); | 623 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)).Times(2); |
| 634 ActivateUnderlyingProvider(); | 624 ActivateProvider(); |
| 635 | 625 |
| 636 // UserClassifier defaults to UserClass::ACTIVE_NTP_USER if PrefService is | 626 // UserClassifier defaults to UserClass::ACTIVE_NTP_USER if PrefService is |
| 637 // null. Change the fallback interval for this class. | 627 // null. Change the fallback interval for this class. |
| 638 SetVariationParameter("soft_on_ntp_opened_interval_hours-active_ntp_user", | 628 SetVariationParameter("soft_on_ntp_opened_interval_hours-active_ntp_user", |
| 639 "1.5"); | 629 "1.5"); |
| 640 | 630 |
| 641 // Schedule() should get called for the second time after params have changed. | 631 // Schedule() should get called for the second time after params have changed. |
| 642 ActivateUnderlyingProvider(); | 632 ActivateProvider(); |
| 643 } | 633 } |
| 644 | 634 |
| 645 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 635 TEST_F(RemoteSuggestionsSchedulerImplTest, FetchIntervalForNtpOpenedTrigger) { |
| 646 FetchIntervalForNtpOpenedTrigger) { | |
| 647 RemoteSuggestionsProvider::FetchStatusCallback signal_fetch_done; | 636 RemoteSuggestionsProvider::FetchStatusCallback signal_fetch_done; |
| 648 { | 637 { |
| 649 InSequence s; | 638 InSequence s; |
| 650 // Initial scheduling after being enabled. | 639 // Initial scheduling after being enabled. |
| 651 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 640 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 652 // The first call to NTPOpened results in a fetch. | 641 // The first call to NTPOpened results in a fetch. |
| 653 EXPECT_CALL(*underlying_provider_, RefetchInTheBackground(_)) | 642 EXPECT_CALL(*provider_, RefetchInTheBackground(_)) |
| 654 .WillOnce(SaveArg<0>(&signal_fetch_done)); | 643 .WillOnce(SaveArg<0>(&signal_fetch_done)); |
| 655 // Rescheduling after a succesful fetch. | 644 // Rescheduling after a succesful fetch. |
| 656 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 645 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 657 // The third call to NTPOpened 35min later again results in a fetch. | 646 // The third call to NTPOpened 35min later again results in a fetch. |
| 658 EXPECT_CALL(*underlying_provider_, RefetchInTheBackground(_)); | 647 EXPECT_CALL(*provider_, RefetchInTheBackground(_)); |
| 659 } | 648 } |
| 660 | 649 |
| 661 ActivateUnderlyingProvider(); | 650 ActivateProvider(); |
| 662 | 651 |
| 663 scheduling_provider_->OnNTPOpened(); | 652 scheduler_->OnNTPOpened(); |
| 664 signal_fetch_done.Run(Status::Success()); | 653 signal_fetch_done.Run(Status::Success()); |
| 665 | 654 |
| 666 // UserClassifier defaults to UserClass::ACTIVE_NTP_USER which uses a 2h time | 655 // UserClassifier defaults to UserClass::ACTIVE_NTP_USER which uses a 2h time |
| 667 // interval by default for soft backgroudn fetches on ntp open events. | 656 // interval by default for soft backgroudn fetches on ntp open events. |
| 668 | 657 |
| 669 // Open NTP again after 20min. This time no fetch is executed. | 658 // Open NTP again after 20min. This time no fetch is executed. |
| 670 test_clock_->Advance(base::TimeDelta::FromMinutes(20)); | 659 test_clock_->Advance(base::TimeDelta::FromMinutes(20)); |
| 671 scheduling_provider_->OnNTPOpened(); | 660 scheduler_->OnNTPOpened(); |
| 672 | 661 |
| 673 // Open NTP again after 101min (121min since first opened). Since the default | 662 // Open NTP again after 101min (121min since first opened). Since the default |
| 674 // time interval has passed refetch again. | 663 // time interval has passed refetch again. |
| 675 test_clock_->Advance(base::TimeDelta::FromMinutes(101)); | 664 test_clock_->Advance(base::TimeDelta::FromMinutes(101)); |
| 676 scheduling_provider_->OnNTPOpened(); | 665 scheduler_->OnNTPOpened(); |
| 677 } | 666 } |
| 678 | 667 |
| 679 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 668 TEST_F(RemoteSuggestionsSchedulerImplTest, |
| 680 OverrideFetchIntervalForNtpOpenedTrigger) { | 669 OverrideFetchIntervalForNtpOpenedTrigger) { |
| 681 // UserClassifier defaults to UserClass::ACTIVE_NTP_USER if PrefService is | 670 // UserClassifier defaults to UserClass::ACTIVE_NTP_USER if PrefService is |
| 682 // null. Change the on usage interval for this class from 2h to 30min. | 671 // null. Change the on usage interval for this class from 2h to 30min. |
| 683 SetVariationParameter("soft_on_ntp_opened_interval_hours-active_ntp_user", | 672 SetVariationParameter("soft_on_ntp_opened_interval_hours-active_ntp_user", |
| 684 "0.5"); | 673 "0.5"); |
| 685 | 674 |
| 686 RemoteSuggestionsProvider::FetchStatusCallback signal_fetch_done; | 675 RemoteSuggestionsProvider::FetchStatusCallback signal_fetch_done; |
| 687 { | 676 { |
| 688 InSequence s; | 677 InSequence s; |
| 689 // Initial scheduling after being enabled. | 678 // Initial scheduling after being enabled. |
| 690 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 679 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 691 // The first call to NTPOpened results in a fetch. | 680 // The first call to NTPOpened results in a fetch. |
| 692 EXPECT_CALL(*underlying_provider_, RefetchInTheBackground(_)) | 681 EXPECT_CALL(*provider_, RefetchInTheBackground(_)) |
| 693 .WillOnce(SaveArg<0>(&signal_fetch_done)); | 682 .WillOnce(SaveArg<0>(&signal_fetch_done)); |
| 694 // Rescheduling after a succesful fetch. | 683 // Rescheduling after a succesful fetch. |
| 695 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 684 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 696 // The third call to NTPOpened 35min later again results in a fetch. | 685 // The third call to NTPOpened 35min later again results in a fetch. |
| 697 EXPECT_CALL(*underlying_provider_, RefetchInTheBackground(_)); | 686 EXPECT_CALL(*provider_, RefetchInTheBackground(_)); |
| 698 } | 687 } |
| 699 | 688 |
| 700 ActivateUnderlyingProvider(); | 689 ActivateProvider(); |
| 701 | 690 |
| 702 scheduling_provider_->OnNTPOpened(); | 691 scheduler_->OnNTPOpened(); |
| 703 signal_fetch_done.Run(Status::Success()); | 692 signal_fetch_done.Run(Status::Success()); |
| 704 | 693 |
| 705 // Open NTP again after 20min. No fetch request is issues since the 30 min | 694 // Open NTP again after 20min. No fetch request is issues since the 30 min |
| 706 // time interval has not passed yet. | 695 // time interval has not passed yet. |
| 707 test_clock_->Advance(base::TimeDelta::FromMinutes(20)); | 696 test_clock_->Advance(base::TimeDelta::FromMinutes(20)); |
| 708 scheduling_provider_->OnNTPOpened(); | 697 scheduler_->OnNTPOpened(); |
| 709 | 698 |
| 710 // Open NTP again after 15min (35min since first opened) | 699 // Open NTP again after 15min (35min since first opened) |
| 711 test_clock_->Advance(base::TimeDelta::FromMinutes(15)); | 700 test_clock_->Advance(base::TimeDelta::FromMinutes(15)); |
| 712 scheduling_provider_->OnNTPOpened(); | 701 scheduler_->OnNTPOpened(); |
| 713 } | 702 } |
| 714 | 703 |
| 715 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 704 TEST_F(RemoteSuggestionsSchedulerImplTest, |
| 716 ShouldBlockFetchingForSomeTimeAfterHistoryCleared) { | 705 ShouldBlockFetchingForSomeTimeAfterHistoryCleared) { |
| 717 // First enable the scheduler -- this will trigger the persistent scheduling. | 706 // First enable the scheduler -- this will trigger the persistent scheduling. |
| 718 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 707 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 719 ActivateUnderlyingProvider(); | 708 ActivateProvider(); |
| 720 // Clear the history. | 709 // Clear the history. |
| 721 scheduling_provider_->OnHistoryCleared(); | 710 scheduler_->OnHistoryCleared(); |
| 722 | 711 |
| 723 // A trigger after 15 minutes is ignored. | 712 // A trigger after 15 minutes is ignored. |
| 724 test_clock_->Advance(base::TimeDelta::FromMinutes(15)); | 713 test_clock_->Advance(base::TimeDelta::FromMinutes(15)); |
| 725 scheduling_provider_->OnBrowserForegrounded(); | 714 scheduler_->OnBrowserForegrounded(); |
| 726 | 715 |
| 727 // A trigger after another 16 minutes is performed (more than 30m after | 716 // A trigger after another 16 minutes is performed (more than 30m after |
| 728 // clearing the history). | 717 // clearing the history). |
| 729 EXPECT_CALL(*underlying_provider_, RefetchInTheBackground(_)); | 718 EXPECT_CALL(*provider_, RefetchInTheBackground(_)); |
| 730 test_clock_->Advance(base::TimeDelta::FromMinutes(16)); | 719 test_clock_->Advance(base::TimeDelta::FromMinutes(16)); |
| 731 scheduling_provider_->OnBrowserForegrounded(); | 720 scheduler_->OnBrowserForegrounded(); |
| 732 } | 721 } |
| 733 | 722 |
| 734 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 723 TEST_F(RemoteSuggestionsSchedulerImplTest, |
| 735 ShouldImmediatelyFetchAfterSuggestionsCleared) { | 724 ShouldImmediatelyFetchAfterSuggestionsCleared) { |
| 736 RemoteSuggestionsProvider::FetchStatusCallback signal_fetch_done; | 725 RemoteSuggestionsProvider::FetchStatusCallback signal_fetch_done; |
| 737 | 726 |
| 738 // First enable the scheduler -- this will trigger the persistent scheduling. | 727 // First enable the scheduler -- this will trigger the persistent scheduling. |
| 739 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 728 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 740 ActivateUnderlyingProvider(); | 729 ActivateProvider(); |
| 741 | 730 |
| 742 // The first trigger results in a fetch. | 731 // The first trigger results in a fetch. |
| 743 EXPECT_CALL(*underlying_provider_, RefetchInTheBackground(_)) | 732 EXPECT_CALL(*provider_, RefetchInTheBackground(_)) |
| 744 .WillOnce(SaveArg<0>(&signal_fetch_done)); | 733 .WillOnce(SaveArg<0>(&signal_fetch_done)); |
| 745 scheduling_provider_->OnBrowserForegrounded(); | 734 scheduler_->OnBrowserForegrounded(); |
| 746 // Make the fetch successful -- this results in rescheduling. | 735 // Make the fetch successful -- this results in rescheduling. |
| 747 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); | 736 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)); |
| 748 signal_fetch_done.Run(Status::Success()); | 737 signal_fetch_done.Run(Status::Success()); |
| 749 | 738 |
| 750 // Clear the suggestions - results in an immediate fetch. | 739 // Clear the suggestions - results in an immediate fetch. |
| 751 EXPECT_CALL(*underlying_provider_, ReloadSuggestions()); | 740 EXPECT_CALL(*provider_, ReloadSuggestions()); |
| 752 scheduling_provider_->OnSuggestionsCleared(); | 741 scheduler_->OnSuggestionsCleared(); |
| 753 } | 742 } |
| 754 | 743 |
| 755 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 744 TEST_F(RemoteSuggestionsSchedulerImplTest, ShouldThrottleInteractiveRequests) { |
| 756 ShouldThrottleInteractiveRequests) { | |
| 757 // Change the quota for interactive requests ("active NTP user" is the default | 745 // Change the quota for interactive requests ("active NTP user" is the default |
| 758 // class in tests). | 746 // class in tests). |
| 759 SetVariationParameter("interactive_quota_SuggestionFetcherActiveNTPUser", | 747 SetVariationParameter("interactive_quota_SuggestionFetcherActiveNTPUser", |
| 760 "10"); | 748 "10"); |
| 761 ResetProvider(); | 749 ResetProvider(); |
| 762 | 750 |
| 763 Category category = Category::FromKnownCategory(KnownCategories::ARTICLES); | 751 for (int x = 0; x < 10; ++x) { |
| 764 std::set<std::string> known_suggestions; | 752 EXPECT_THAT(scheduler_->AcquireQuotaForInteractiveFetch(), Eq(true)); |
| 765 | |
| 766 // Both Fetch(..) and ReloadSuggestions() consume the same quota. As long as | |
| 767 // the quota suffices, the call gets through. | |
| 768 EXPECT_CALL(*underlying_provider_, ReloadSuggestions()).Times(5); | |
| 769 for (int x = 0; x < 5; ++x) { | |
| 770 scheduling_provider_->ReloadSuggestions(); | |
| 771 } | 753 } |
| 772 | 754 |
| 773 // Expect underlying provider being called and store the callback to inform | 755 // Now the quota is over. |
| 774 // scheduling provider. | 756 EXPECT_THAT(scheduler_->AcquireQuotaForInteractiveFetch(), Eq(false)); |
| 775 FetchDoneCallback signal_fetch_done_from_underlying_provider; | |
| 776 EXPECT_CALL(*underlying_provider_, Fetch(_, _, _)) | |
| 777 .Times(5) | |
| 778 .WillRepeatedly(SaveArg<2>(&signal_fetch_done_from_underlying_provider)); | |
| 779 // Expect scheduling provider to pass the information through. | |
| 780 MockFunction<void(Status status_code, | |
| 781 const std::vector<ContentSuggestion>& suggestions)> | |
| 782 fetch_done_from_scheduling_provider; | |
| 783 EXPECT_CALL(fetch_done_from_scheduling_provider, | |
| 784 Call(Field(&Status::code, StatusCode::SUCCESS), _)) | |
| 785 .Times(5); | |
| 786 // Scheduling is not activated, each successful fetch results in Unschedule(). | |
| 787 EXPECT_CALL(persistent_scheduler_, Unschedule()).Times(5); | |
| 788 for (int x = 0; x < 5; ++x) { | |
| 789 scheduling_provider_->Fetch( | |
| 790 category, known_suggestions, | |
| 791 base::Bind(&SchedulingRemoteSuggestionsProviderTest::FetchDoneWrapper, | |
| 792 base::Unretained(this), | |
| 793 &fetch_done_from_scheduling_provider)); | |
| 794 // Inform scheduling provider the fetc is successful (with no suggestions). | |
| 795 signal_fetch_done_from_underlying_provider.Run( | |
| 796 Status::Success(), std::vector<ContentSuggestion>{}); | |
| 797 } | |
| 798 | |
| 799 // When the quota expires, it is blocked by the scheduling provider, directly | |
| 800 // calling the callback. | |
| 801 EXPECT_CALL(fetch_done_from_scheduling_provider, | |
| 802 Call(Field(&Status::code, StatusCode::TEMPORARY_ERROR), _)); | |
| 803 scheduling_provider_->ReloadSuggestions(); | |
| 804 scheduling_provider_->Fetch( | |
| 805 category, known_suggestions, | |
| 806 base::Bind(&SchedulingRemoteSuggestionsProviderTest::FetchDoneWrapper, | |
| 807 base::Unretained(this), &fetch_done_from_scheduling_provider)); | |
| 808 } | 757 } |
| 809 | 758 |
| 810 TEST_F(SchedulingRemoteSuggestionsProviderTest, | 759 TEST_F(RemoteSuggestionsSchedulerImplTest, |
| 811 ShouldThrottleNonInteractiveRequests) { | 760 ShouldThrottleNonInteractiveRequests) { |
| 812 // Change the quota for interactive requests ("active NTP user" is the default | 761 // Change the quota for interactive requests ("active NTP user" is the default |
| 813 // class in tests). | 762 // class in tests). |
| 814 SetVariationParameter("quota_SuggestionFetcherActiveNTPUser", "5"); | 763 SetVariationParameter("quota_SuggestionFetcherActiveNTPUser", "5"); |
| 815 ResetProvider(); | 764 ResetProvider(); |
| 816 | 765 |
| 817 // One scheduling on start, 5 times after successful fetches. | 766 // One scheduling on start, 5 times after successful fetches. |
| 818 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)).Times(6); | 767 EXPECT_CALL(persistent_scheduler_, Schedule(_, _)).Times(6); |
| 819 | 768 |
| 820 // First enable the scheduler -- this will trigger the persistent scheduling. | 769 // First enable the scheduler -- this will trigger the persistent scheduling. |
| 821 ActivateUnderlyingProvider(); | 770 ActivateProvider(); |
| 822 | 771 |
| 823 // As long as the quota suffices, the call gets through. | 772 // As long as the quota suffices, the call gets through. |
| 824 RemoteSuggestionsProvider::FetchStatusCallback signal_fetch_done; | 773 RemoteSuggestionsProvider::FetchStatusCallback signal_fetch_done; |
| 825 EXPECT_CALL(*underlying_provider_, RefetchInTheBackground(_)) | 774 EXPECT_CALL(*provider_, RefetchInTheBackground(_)) |
| 826 .Times(5) | 775 .Times(5) |
| 827 .WillRepeatedly(SaveArg<0>(&signal_fetch_done)); | 776 .WillRepeatedly(SaveArg<0>(&signal_fetch_done)); |
| 828 for (int x = 0; x < 5; ++x) { | 777 for (int x = 0; x < 5; ++x) { |
| 829 scheduling_provider_->OnPersistentSchedulerWakeUp(); | 778 scheduler_->OnPersistentSchedulerWakeUp(); |
| 830 signal_fetch_done.Run(Status::Success()); | 779 signal_fetch_done.Run(Status::Success()); |
| 831 } | 780 } |
| 832 | 781 |
| 833 // For the 6th time, it is blocked by the scheduling provider. | 782 // For the 6th time, it is blocked by the scheduling provider. |
| 834 scheduling_provider_->OnPersistentSchedulerWakeUp(); | 783 scheduler_->OnPersistentSchedulerWakeUp(); |
| 835 } | 784 } |
| 836 | 785 |
| 837 } // namespace ntp_snippets | 786 } // namespace ntp_snippets |
| OLD | NEW |