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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/scheduler/renderer/throttling_helper.cc ('k') | components/scheduler/scheduler.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/scheduler/renderer/throttling_helper_unittest.cc
diff --git a/components/scheduler/renderer/throttling_helper_unittest.cc b/components/scheduler/renderer/throttling_helper_unittest.cc
index f52a605aa1f5717a09eca22f0f33776b70117580..2936d4380bd45016df6ebf0a1f66acd4f50d58df 100644
--- a/components/scheduler/renderer/throttling_helper_unittest.cc
+++ b/components/scheduler/renderer/throttling_helper_unittest.cc
@@ -276,4 +276,34 @@ TEST_F(ThrottlingHelperTest,
base::TimeTicks() + base::TimeDelta::FromSeconds(16)));
}
+TEST_F(ThrottlingHelperTest, TaskDelayIsBasedOnRealTime) {
+ std::vector<base::TimeTicks> run_times;
+
+ throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get());
+
+ // Post an initial task that should run at the first aligned time period.
+ timer_queue_->PostDelayedTask(FROM_HERE,
+ base::Bind(&TestTask, &run_times, clock_.get()),
+ base::TimeDelta::FromMilliseconds(900.0));
+
+ mock_task_runner_->RunUntilIdle();
+
+ // Advance realtime.
+ clock_->Advance(base::TimeDelta::FromMilliseconds(250));
+
+ // Post a task that due to real time + delay must run in the third aligned
+ // time period.
+ timer_queue_->PostDelayedTask(FROM_HERE,
+ base::Bind(&TestTask, &run_times, clock_.get()),
+ base::TimeDelta::FromMilliseconds(900.0));
+
+ mock_task_runner_->RunUntilIdle();
+
+ EXPECT_THAT(
+ run_times,
+ ElementsAre(
+ base::TimeTicks() + base::TimeDelta::FromMilliseconds(1000.0),
+ base::TimeTicks() + base::TimeDelta::FromMilliseconds(3000.0)));
+}
+
} // namespace scheduler
« 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