| Index: base/test/sequenced_task_runner_test_template.h
|
| ===================================================================
|
| --- base/test/sequenced_task_runner_test_template.h (revision 178148)
|
| +++ base/test/sequenced_task_runner_test_template.h (working copy)
|
| @@ -18,6 +18,7 @@
|
| #include "base/callback.h"
|
| #include "base/memory/ref_counted.h"
|
| #include "base/sequenced_task_runner.h"
|
| +#include "base/synchronization/condition_variable.h"
|
| #include "base/synchronization/lock.h"
|
| #include "base/time.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| @@ -61,6 +62,8 @@
|
|
|
| const std::vector<TaskEvent>& GetTaskEvents() const;
|
|
|
| + void WaitForTasksToComplete(int count);
|
| +
|
| private:
|
| friend class RefCountedThreadSafe<SequencedTaskTracker>;
|
|
|
| @@ -79,7 +82,7 @@
|
| // Records a end event for task |i|.
|
| void TaskEnded(int i);
|
|
|
| - // Protects events_ and next_post_i_.
|
| + // Protects events_, next_post_i_, task_end_count_ and task_end_cv_.
|
| Lock lock_;
|
|
|
| // The events as they occurred for each task (protected by lock_).
|
| @@ -89,6 +92,10 @@
|
| // lock_).
|
| int next_post_i_;
|
|
|
| + // The number of task ends we've received.
|
| + int task_end_count_;
|
| + ConditionVariable task_end_cv_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(SequencedTaskTracker);
|
| };
|
|
|
| @@ -191,6 +198,7 @@
|
| TimeDelta::FromMilliseconds(kDelayIncrementMs * i));
|
| }
|
|
|
| + this->task_tracker_->WaitForTasksToComplete(kTaskCount);
|
| this->delegate_.StopTaskRunner();
|
|
|
| EXPECT_TRUE(CheckNonNestableInvariants(this->task_tracker_->GetTaskEvents(),
|
| @@ -244,6 +252,7 @@
|
| Time time_before_run = Time::Now();
|
| this->task_tracker_->PostWrappedDelayedNonNestableTask(
|
| task_runner, Closure(), kDelay);
|
| + this->task_tracker_->WaitForTasksToComplete(1);
|
| this->delegate_.StopTaskRunner();
|
| Time time_after_run = Time::Now();
|
|
|
| @@ -278,6 +287,7 @@
|
| task_runner, Closure(), kDelay);
|
| this->task_tracker_->PostWrappedDelayedNonNestableTask(
|
| task_runner, Closure(), kDelay);
|
| + this->task_tracker_->WaitForTasksToComplete(kTaskCount);
|
| this->delegate_.StopTaskRunner();
|
|
|
| EXPECT_TRUE(CheckNonNestableInvariants(this->task_tracker_->GetTaskEvents(),
|
| @@ -306,6 +316,7 @@
|
| TimeDelta::FromMilliseconds(50)));
|
| this->task_tracker_->PostWrappedDelayedNonNestableTask(
|
| task_runner, Closure(), TimeDelta::FromMilliseconds(10));
|
| + this->task_tracker_->WaitForTasksToComplete(kTaskCount);
|
| this->delegate_.StopTaskRunner();
|
|
|
| EXPECT_TRUE(CheckNonNestableInvariants(this->task_tracker_->GetTaskEvents(),
|
| @@ -335,6 +346,7 @@
|
| }
|
| this->task_tracker_->PostWrappedDelayedNonNestableTask(
|
| task_runner, Closure(), TimeDelta::FromMilliseconds(10));
|
| + this->task_tracker_->WaitForTasksToComplete(kTaskCount);
|
| this->delegate_.StopTaskRunner();
|
|
|
| EXPECT_TRUE(CheckNonNestableInvariants(this->task_tracker_->GetTaskEvents(),
|
|
|