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

Side by Side Diff: components/scheduler/renderer/throttling_helper_unittest.cc

Issue 1730153005: [cherrypick] Fix computation of runtime for throttled tasks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2623
Patch Set: no changes Created 4 years, 9 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
« no previous file with comments | « components/scheduler/renderer/throttling_helper.cc ('k') | components/scheduler/scheduler.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/scheduler/renderer/throttling_helper.h" 5 #include "components/scheduler/renderer/throttling_helper.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 269
270 EXPECT_EQ(2u, task_count); // There are two since the cancelled task runs in 270 EXPECT_EQ(2u, task_count); // There are two since the cancelled task runs in
271 // the same DoWork batch. 271 // the same DoWork batch.
272 272
273 EXPECT_THAT( 273 EXPECT_THAT(
274 run_times, 274 run_times,
275 ElementsAre(base::TimeTicks() + base::TimeDelta::FromSeconds(6), 275 ElementsAre(base::TimeTicks() + base::TimeDelta::FromSeconds(6),
276 base::TimeTicks() + base::TimeDelta::FromSeconds(16))); 276 base::TimeTicks() + base::TimeDelta::FromSeconds(16)));
277 } 277 }
278 278
279 TEST_F(ThrottlingHelperTest, TaskDelayIsBasedOnRealTime) {
280 std::vector<base::TimeTicks> run_times;
281
282 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get());
283
284 // Post an initial task that should run at the first aligned time period.
285 timer_queue_->PostDelayedTask(FROM_HERE,
286 base::Bind(&TestTask, &run_times, clock_.get()),
287 base::TimeDelta::FromMilliseconds(900.0));
288
289 mock_task_runner_->RunUntilIdle();
290
291 // Advance realtime.
292 clock_->Advance(base::TimeDelta::FromMilliseconds(250));
293
294 // Post a task that due to real time + delay must run in the third aligned
295 // time period.
296 timer_queue_->PostDelayedTask(FROM_HERE,
297 base::Bind(&TestTask, &run_times, clock_.get()),
298 base::TimeDelta::FromMilliseconds(900.0));
299
300 mock_task_runner_->RunUntilIdle();
301
302 EXPECT_THAT(
303 run_times,
304 ElementsAre(
305 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1000.0),
306 base::TimeTicks() + base::TimeDelta::FromMilliseconds(3000.0)));
307 }
308
279 } // namespace scheduler 309 } // namespace scheduler
OLDNEW
« no previous file with comments | « components/scheduler/renderer/throttling_helper.cc ('k') | components/scheduler/scheduler.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698