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

Unified Diff: cc/test/ordered_simple_task_runner.cc

Issue 387493002: Fixing and enhancing OrderedSimpleTaskRunner to allow 100% deterministic tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sprintf is hard. Created 6 years, 5 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
Index: cc/test/ordered_simple_task_runner.cc
diff --git a/cc/test/ordered_simple_task_runner.cc b/cc/test/ordered_simple_task_runner.cc
index 188ffe72b5f8adea6208635d68263b3139811000..21ec2ac24a7d4605c6aae6aa1dd25479d5449b8e 100644
--- a/cc/test/ordered_simple_task_runner.cc
+++ b/cc/test/ordered_simple_task_runner.cc
@@ -7,8 +7,6 @@
#include <algorithm>
#include <deque>
-#include "base/logging.h"
-
namespace {
bool TestPendingTaskComparator(const base::TestPendingTask& lhs,
@@ -20,8 +18,6 @@ bool TestPendingTaskComparator(const base::TestPendingTask& lhs,
namespace cc {
-OrderedSimpleTaskRunner::OrderedSimpleTaskRunner() {}
-
OrderedSimpleTaskRunner::~OrderedSimpleTaskRunner() {}
void OrderedSimpleTaskRunner::RunPendingTasks() {
@@ -32,8 +28,18 @@ void OrderedSimpleTaskRunner::RunPendingTasks() {
std::stable_sort(tasks_to_run.begin(),
tasks_to_run.end(),
TestPendingTaskComparator);
+
for (std::deque<base::TestPendingTask>::iterator it = tasks_to_run.begin();
it != tasks_to_run.end(); ++it) {
+ base::TimeTicks task_time = it->GetTimeToRun();
+ if (Now() < task_time) {
+ if (advance_now_) {
+ SetNow(task_time);
+ } else {
+ pending_tasks_.push_back(*it);
+ continue;
+ }
+ }
it->task.Run();
}
}

Powered by Google App Engine
This is Rietveld 408576698