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

Side by Side Diff: content/renderer/categorized_worker_pool_unittest.cc

Issue 2021323002: content: Rename RasterWorkerPool -> CategorizedWorkerPool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@task_graph_runner_test_2
Patch Set: rebase Created 4 years, 6 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 | « content/renderer/categorized_worker_pool.cc ('k') | content/renderer/raster_worker_pool.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
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 "cc/test/task_graph_runner_test_template.h"
9 #include "content/renderer/categorized_worker_pool.h"
10
11 namespace base {
12 namespace {
13
14 // Number of threads spawned in tests.
15 const int kNumThreads = 4;
16
17 class CategorizedWorkerPoolTestDelegate {
18 public:
19 CategorizedWorkerPoolTestDelegate()
20 : categorized_worker_pool_(new content::CategorizedWorkerPool()) {}
21
22 void StartTaskRunner() { categorized_worker_pool_->Start(kNumThreads); }
23
24 scoped_refptr<content::CategorizedWorkerPool> GetTaskRunner() {
25 return categorized_worker_pool_;
26 }
27
28 void StopTaskRunner() { categorized_worker_pool_->FlushForTesting(); }
29
30 ~CategorizedWorkerPoolTestDelegate() { categorized_worker_pool_->Shutdown(); }
31
32 private:
33 scoped_refptr<content::CategorizedWorkerPool> categorized_worker_pool_;
34 };
35
36 INSTANTIATE_TYPED_TEST_CASE_P(CategorizedWorkerPool,
37 TaskRunnerTest,
38 CategorizedWorkerPoolTestDelegate);
39
40 class CategorizedWorkerPoolSequencedTestDelegate {
41 public:
42 CategorizedWorkerPoolSequencedTestDelegate()
43 : categorized_worker_pool_(new content::CategorizedWorkerPool()) {}
44
45 void StartTaskRunner() { categorized_worker_pool_->Start(kNumThreads); }
46
47 scoped_refptr<base::SequencedTaskRunner> GetTaskRunner() {
48 return categorized_worker_pool_->CreateSequencedTaskRunner();
49 }
50
51 void StopTaskRunner() { categorized_worker_pool_->FlushForTesting(); }
52
53 ~CategorizedWorkerPoolSequencedTestDelegate() {
54 categorized_worker_pool_->Shutdown();
55 }
56
57 private:
58 scoped_refptr<content::CategorizedWorkerPool> categorized_worker_pool_;
59 };
60
61 INSTANTIATE_TYPED_TEST_CASE_P(CategorizedWorkerPool,
62 SequencedTaskRunnerTest,
63 CategorizedWorkerPoolSequencedTestDelegate);
64
65 } // namespace
66 } // namespace base
67
68 namespace cc {
69 namespace {
70
71 template <int NumThreads>
72 class CategorizedWorkerPoolTaskGraphRunnerTestDelegate {
73 public:
74 CategorizedWorkerPoolTaskGraphRunnerTestDelegate()
75 : categorized_worker_pool_(new content::CategorizedWorkerPool()) {}
76
77 void StartTaskGraphRunner() { categorized_worker_pool_->Start(NumThreads); }
78
79 cc::TaskGraphRunner* GetTaskGraphRunner() {
80 return categorized_worker_pool_->GetTaskGraphRunner();
81 }
82
83 void StopTaskGraphRunner() { categorized_worker_pool_->FlushForTesting(); }
84
85 ~CategorizedWorkerPoolTaskGraphRunnerTestDelegate() {
86 categorized_worker_pool_->Shutdown();
87 }
88
89 private:
90 scoped_refptr<content::CategorizedWorkerPool> categorized_worker_pool_;
91 };
92
93 // Multithreaded tests.
94 INSTANTIATE_TYPED_TEST_CASE_P(
95 CategorizedWorkerPool_1_Threads,
96 TaskGraphRunnerTest,
97 CategorizedWorkerPoolTaskGraphRunnerTestDelegate<1>);
98 INSTANTIATE_TYPED_TEST_CASE_P(
99 CategorizedWorkerPool_2_Threads,
100 TaskGraphRunnerTest,
101 CategorizedWorkerPoolTaskGraphRunnerTestDelegate<2>);
102 INSTANTIATE_TYPED_TEST_CASE_P(
103 CategorizedWorkerPool_3_Threads,
104 TaskGraphRunnerTest,
105 CategorizedWorkerPoolTaskGraphRunnerTestDelegate<3>);
106 INSTANTIATE_TYPED_TEST_CASE_P(
107 CategorizedWorkerPool_4_Threads,
108 TaskGraphRunnerTest,
109 CategorizedWorkerPoolTaskGraphRunnerTestDelegate<4>);
110 INSTANTIATE_TYPED_TEST_CASE_P(
111 CategorizedWorkerPool_5_Threads,
112 TaskGraphRunnerTest,
113 CategorizedWorkerPoolTaskGraphRunnerTestDelegate<5>);
114
115 // Single threaded tests.
116 INSTANTIATE_TYPED_TEST_CASE_P(
117 CategorizedWorkerPool,
118 SingleThreadTaskGraphRunnerTest,
119 CategorizedWorkerPoolTaskGraphRunnerTestDelegate<1>);
120
121 } // namespace
122 } // namespace cc
OLDNEW
« no previous file with comments | « content/renderer/categorized_worker_pool.cc ('k') | content/renderer/raster_worker_pool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698