1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/test/sequenced_task_runner_test_template.h"
6 #include "base/test/task_runner_test_template.h"
7 #include "base/threading/simple_thread.h"
8 #include "content/renderer/raster_worker_pool.h"
13 // Number of threads spawned in tests.
14 const int kNumThreads
= 4;
16 class RasterWorkerPoolTestDelegate
{
18 RasterWorkerPoolTestDelegate()
19 : raster_worker_pool_(new content::RasterWorkerPool()) {}
21 void StartTaskRunner() {
22 raster_worker_pool_
->Start(kNumThreads
, SimpleThread::Options());
25 scoped_refptr
<content::RasterWorkerPool
> GetTaskRunner() {
26 return raster_worker_pool_
;
29 void StopTaskRunner() {
30 raster_worker_pool_
->GetTaskGraphRunner()->FlushForTesting();
33 ~RasterWorkerPoolTestDelegate() { raster_worker_pool_
->Shutdown(); }
36 scoped_refptr
<content::RasterWorkerPool
> raster_worker_pool_
;
39 INSTANTIATE_TYPED_TEST_CASE_P(RasterWorkerPool
,
41 RasterWorkerPoolTestDelegate
);
43 class RasterWorkerPoolSequencedTestDelegate
{
45 RasterWorkerPoolSequencedTestDelegate()
46 : raster_worker_pool_(new content::RasterWorkerPool()) {}
48 void StartTaskRunner() {
49 raster_worker_pool_
->Start(kNumThreads
, SimpleThread::Options());
52 scoped_refptr
<base::SequencedTaskRunner
> GetTaskRunner() {
53 return raster_worker_pool_
->CreateSequencedTaskRunner();
56 void StopTaskRunner() {
57 raster_worker_pool_
->GetTaskGraphRunner()->FlushForTesting();
60 ~RasterWorkerPoolSequencedTestDelegate() { raster_worker_pool_
->Shutdown(); }
63 scoped_refptr
<content::RasterWorkerPool
> raster_worker_pool_
;
66 INSTANTIATE_TYPED_TEST_CASE_P(RasterWorkerPool
,
67 SequencedTaskRunnerTest
,
68 RasterWorkerPoolSequencedTestDelegate
);