Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / content / renderer / raster_worker_pool_unittest.cc
blob926ba2b6d0631fab216d1f7e6c6badb11aa49fae
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"
10 namespace base {
11 namespace {
13 // Number of threads spawned in tests.
14 const int kNumThreads = 4;
16 class RasterWorkerPoolTestDelegate {
17 public:
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(); }
35 private:
36 scoped_refptr<content::RasterWorkerPool> raster_worker_pool_;
39 INSTANTIATE_TYPED_TEST_CASE_P(RasterWorkerPool,
40 TaskRunnerTest,
41 RasterWorkerPoolTestDelegate);
43 class RasterWorkerPoolSequencedTestDelegate {
44 public:
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(); }
62 private:
63 scoped_refptr<content::RasterWorkerPool> raster_worker_pool_;
66 INSTANTIATE_TYPED_TEST_CASE_P(RasterWorkerPool,
67 SequencedTaskRunnerTest,
68 RasterWorkerPoolSequencedTestDelegate);
70 } // namespace
71 } // namespace base