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

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

Issue 1718233002: Fix computation of runtime for throttled tasks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo Created 4 years, 10 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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 321
322 EXPECT_EQ(2u, task_count); // There are two since the cancelled task runs in 322 EXPECT_EQ(2u, task_count); // There are two since the cancelled task runs in
323 // the same DoWork batch. 323 // the same DoWork batch.
324 324
325 EXPECT_THAT( 325 EXPECT_THAT(
326 run_times, 326 run_times,
327 ElementsAre(base::TimeTicks() + base::TimeDelta::FromSeconds(6), 327 ElementsAre(base::TimeTicks() + base::TimeDelta::FromSeconds(6),
328 base::TimeTicks() + base::TimeDelta::FromSeconds(16))); 328 base::TimeTicks() + base::TimeDelta::FromSeconds(16)));
329 } 329 }
330 330
331 TEST_F(ThrottlingHelperTest, TaskDelayIsBasedOnRealTime) {
332 std::vector<base::TimeTicks> run_times;
333
334 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get());
335
336 // Post an initial task that should run at the first aligned time period.
337 timer_queue_->PostDelayedTask(FROM_HERE,
338 base::Bind(&TestTask, &run_times, clock_.get()),
339 base::TimeDelta::FromMilliseconds(900.0));
340
341 mock_task_runner_->RunUntilIdle();
342
343 // Advance realtime.
344 clock_->Advance(base::TimeDelta::FromMilliseconds(250));
345
346 // Post a task that due to real time + delay must run in the third aligned
347 // time period.
348 timer_queue_->PostDelayedTask(FROM_HERE,
349 base::Bind(&TestTask, &run_times, clock_.get()),
350 base::TimeDelta::FromMilliseconds(900.0));
351
352 mock_task_runner_->RunUntilIdle();
353
354 EXPECT_THAT(
355 run_times,
356 ElementsAre(
357 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1000.0),
358 base::TimeTicks() + base::TimeDelta::FromMilliseconds(3000.0)));
359 }
360
331 } // namespace scheduler 361 } // 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