OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "base/test/scoped_task_environment.h" | 5 #include "base/test/scoped_task_environment.h" |
6 | 6 |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/task_scheduler/scheduler_worker_pool_params.h" | 8 #include "base/task_scheduler/scheduler_worker_pool_params.h" |
9 #include "base/task_scheduler/task_scheduler.h" | 9 #include "base/task_scheduler/task_scheduler.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 14 matching lines...) Expand all Loading... | |
25 TaskScheduler::CreateAndSetDefaultTaskScheduler( | 25 TaskScheduler::CreateAndSetDefaultTaskScheduler( |
26 "ScopedTaskEnvironment", {worker_pool_params, worker_pool_params, | 26 "ScopedTaskEnvironment", {worker_pool_params, worker_pool_params, |
27 worker_pool_params, worker_pool_params}); | 27 worker_pool_params, worker_pool_params}); |
28 task_scheduler_ = TaskScheduler::GetInstance(); | 28 task_scheduler_ = TaskScheduler::GetInstance(); |
29 } | 29 } |
30 | 30 |
31 ScopedTaskEnvironment::~ScopedTaskEnvironment() { | 31 ScopedTaskEnvironment::~ScopedTaskEnvironment() { |
32 RunLoop().RunUntilIdle(); | 32 RunLoop().RunUntilIdle(); |
33 | 33 |
34 DCHECK_EQ(TaskScheduler::GetInstance(), task_scheduler_); | 34 DCHECK_EQ(TaskScheduler::GetInstance(), task_scheduler_); |
35 TaskScheduler::GetInstance()->FlushForTesting(); | |
gab
2017/04/12 19:18:34
Add a comment explaining why it's required.
fdoray
2017/04/12 19:38:05
Done.
| |
35 TaskScheduler::GetInstance()->Shutdown(); | 36 TaskScheduler::GetInstance()->Shutdown(); |
36 TaskScheduler::GetInstance()->JoinForTesting(); | 37 TaskScheduler::GetInstance()->JoinForTesting(); |
37 TaskScheduler::SetInstance(nullptr); | 38 TaskScheduler::SetInstance(nullptr); |
38 } | 39 } |
39 | 40 |
40 } // namespace test | 41 } // namespace test |
41 } // namespace base | 42 } // namespace base |
OLD | NEW |