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

Side by Side Diff: base/threading/sequenced_worker_pool_unittest.cc

Issue 2762753002: Initialize TaskScheduler with InitParams in sequenced_worker_pool_unittest.cc. (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/threading/sequenced_worker_pool.h" 5 #include "base/threading/sequenced_worker_pool.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 237
238 class SequencedWorkerPoolTest 238 class SequencedWorkerPoolTest
239 : public testing::TestWithParam<SequencedWorkerPoolRedirection> { 239 : public testing::TestWithParam<SequencedWorkerPoolRedirection> {
240 public: 240 public:
241 SequencedWorkerPoolTest() 241 SequencedWorkerPoolTest()
242 : pool_owner_(new SequencedWorkerPoolOwner(kNumWorkerThreads, "test")), 242 : pool_owner_(new SequencedWorkerPoolOwner(kNumWorkerThreads, "test")),
243 tracker_(new TestTracker) {} 243 tracker_(new TestTracker) {}
244 244
245 void SetUp() override { 245 void SetUp() override {
246 if (RedirectedToTaskScheduler()) { 246 if (RedirectedToTaskScheduler()) {
247 std::vector<SchedulerWorkerPoolParams> worker_pool_params; 247 const SchedulerWorkerPoolParams worker_pool_params(
248 worker_pool_params.emplace_back(
249 "SchedulerWorkerPoolName", ThreadPriority::NORMAL,
250 SchedulerWorkerPoolParams::StandbyThreadPolicy::LAZY, 248 SchedulerWorkerPoolParams::StandbyThreadPolicy::LAZY,
251 kNumWorkerThreads, TimeDelta::Max()); 249 static_cast<int>(kNumWorkerThreads), TimeDelta::Max());
252 TaskScheduler::CreateAndSetDefaultTaskScheduler( 250 TaskScheduler::CreateAndSetDefaultTaskScheduler(
253 std::move(worker_pool_params), 251 "SequencedWorkerPoolTest", {worker_pool_params, worker_pool_params,
254 base::Bind([](const TaskTraits&) -> size_t { return 0U; })); 252 worker_pool_params, worker_pool_params});
255 253
256 // Unit tests run in an environment where SequencedWorkerPool is enabled 254 // Unit tests run in an environment where SequencedWorkerPool is enabled
257 // without redirection to TaskScheduler. For the current unit test, 255 // without redirection to TaskScheduler. For the current unit test,
258 // disable it and re-enable it with redirection to TaskScheduler. 256 // disable it and re-enable it with redirection to TaskScheduler.
259 SequencedWorkerPool::DisableForProcessForTesting(); 257 SequencedWorkerPool::DisableForProcessForTesting();
260 SequencedWorkerPool::EnableWithRedirectionToTaskSchedulerForProcess(); 258 SequencedWorkerPool::EnableWithRedirectionToTaskSchedulerForProcess();
261 } 259 }
262 } 260 }
263 261
264 void TearDown() override { 262 void TearDown() override {
(...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 SequencedWorkerPoolSequencedTaskRunner, SequencedTaskRunnerTest, 1236 SequencedWorkerPoolSequencedTaskRunner, SequencedTaskRunnerTest,
1239 SequencedWorkerPoolSequencedTaskRunnerTestDelegate); 1237 SequencedWorkerPoolSequencedTaskRunnerTestDelegate);
1240 INSTANTIATE_TYPED_TEST_CASE_P( 1238 INSTANTIATE_TYPED_TEST_CASE_P(
1241 SequencedWorkerPoolSequencedTaskRunner, 1239 SequencedWorkerPoolSequencedTaskRunner,
1242 SequencedTaskRunnerDelayedTest, 1240 SequencedTaskRunnerDelayedTest,
1243 SequencedWorkerPoolSequencedTaskRunnerTestDelegate); 1241 SequencedWorkerPoolSequencedTaskRunnerTestDelegate);
1244 1242
1245 } // namespace 1243 } // namespace
1246 1244
1247 } // namespace base 1245 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698