| Index: base/test/task_runner_test_template.h
|
| ===================================================================
|
| --- base/test/task_runner_test_template.h (revision 178148)
|
| +++ base/test/task_runner_test_template.h (working copy)
|
| @@ -58,6 +58,7 @@
|
| #include "base/bind.h"
|
| #include "base/callback.h"
|
| #include "base/memory/ref_counted.h"
|
| +#include "base/synchronization/condition_variable.h"
|
| #include "base/synchronization/lock.h"
|
| #include "base/task_runner.h"
|
| #include "base/threading/thread.h"
|
| @@ -81,6 +82,8 @@
|
|
|
| std::map<int, int> GetTaskRunCounts() const;
|
|
|
| + void WaitForTasksToComplete(int count);
|
| +
|
| private:
|
| friend class RefCountedThreadSafe<TaskTracker>;
|
|
|
| @@ -88,8 +91,10 @@
|
|
|
| void RunTask(const Closure& task, int i);
|
|
|
| - mutable Lock task_run_counts_lock_;
|
| + mutable Lock lock_;
|
| std::map<int, int> task_run_counts_;
|
| + int task_runs_;
|
| + ConditionVariable task_runs_cv_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(TaskTracker);
|
| };
|
| @@ -140,6 +145,7 @@
|
| }
|
|
|
| std::map<int, int> expected_task_run_counts;
|
| + int expected_total_tasks = 0;
|
|
|
| this->delegate_.StartTaskRunner();
|
| scoped_refptr<TaskRunner> task_runner = this->delegate_.GetTaskRunner();
|
| @@ -150,8 +156,10 @@
|
| task_runner->PostDelayedTask(
|
| FROM_HERE, ith_task, base::TimeDelta::FromMilliseconds(j));
|
| ++expected_task_run_counts[i];
|
| + ++expected_total_tasks;
|
| }
|
| }
|
| + this->task_tracker_->WaitForTasksToComplete(expected_total_tasks);
|
| this->delegate_.StopTaskRunner();
|
|
|
| EXPECT_EQ(expected_task_run_counts,
|
|
|