Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Side by Side Diff: components/policy/core/common/cloud/external_policy_data_updater_unittest.cc

Issue 2331423002: Replace TestSimpleTaskRunner::GetPendingTasks with TakePendingTasks (Closed)
Patch Set: split test Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/policy/core/common/cloud/external_policy_data_updater.h" 5 #include "components/policy/core/common/cloud/external_policy_data_updater.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 io_task_runner_->RunUntilIdle(); 345 io_task_runner_->RunUntilIdle();
346 346
347 // Verify that the fetch is no longer running. 347 // Verify that the fetch is no longer running.
348 EXPECT_FALSE(fetcher_factory_.GetFetcherByID(fetcher_id)); 348 EXPECT_FALSE(fetcher_factory_.GetFetcherByID(fetcher_id));
349 349
350 // Verify that a retry has been scheduled. 350 // Verify that a retry has been scheduled.
351 EXPECT_EQ(1u, backend_task_runner_->NumPendingTasks()); 351 EXPECT_EQ(1u, backend_task_runner_->NumPendingTasks());
352 352
353 // Verify that the retry delay has been doubled, with random jitter from 80% 353 // Verify that the retry delay has been doubled, with random jitter from 80%
354 // to 100%. 354 // to 100%.
355 const base::TestPendingTask task = 355 base::TimeDelta delay = backend_task_runner_->NextPendingTaskDelay();
356 backend_task_runner_->GetPendingTasks().front(); 356 EXPECT_GT(delay,
357 EXPECT_GT(task.delay,
358 base::TimeDelta::FromMilliseconds( 357 base::TimeDelta::FromMilliseconds(
359 0.799 * expected_delay.InMilliseconds())); 358 0.799 * expected_delay.InMilliseconds()));
360 EXPECT_LE(task.delay, expected_delay); 359 EXPECT_LE(delay, expected_delay);
361 360
362 if (i < 10) { 361 if (i < 10) {
363 // The delay cap has not been reached yet. 362 // The delay cap has not been reached yet.
364 EXPECT_LT(expected_delay, delay_cap); 363 EXPECT_LT(expected_delay, delay_cap);
365 expected_delay *= 2; 364 expected_delay *= 2;
366 365
367 if (i == 9) { 366 if (i == 9) {
368 // The last doubling reached the cap. 367 // The last doubling reached the cap.
369 EXPECT_GT(expected_delay, delay_cap); 368 EXPECT_GT(expected_delay, delay_cap);
370 expected_delay = delay_cap; 369 expected_delay = delay_cap;
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 // Verify that the second fetch is no longer running. 955 // Verify that the second fetch is no longer running.
957 EXPECT_FALSE(fetcher_factory_.GetFetcherByID(1)); 956 EXPECT_FALSE(fetcher_factory_.GetFetcherByID(1));
958 957
959 // Verify that the third fetch has been started. 958 // Verify that the third fetch has been started.
960 fetcher = fetcher_factory_.GetFetcherByID(2); 959 fetcher = fetcher_factory_.GetFetcherByID(2);
961 ASSERT_TRUE(fetcher); 960 ASSERT_TRUE(fetcher);
962 EXPECT_EQ(GURL(kExternalPolicyDataURLs[2]), fetcher->GetOriginalURL()); 961 EXPECT_EQ(GURL(kExternalPolicyDataURLs[2]), fetcher->GetOriginalURL());
963 } 962 }
964 963
965 } // namespace policy 964 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698