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

Side by Side Diff: cc/resources/task_graph_runner_unittest.cc

Issue 628443002: replace OVERRIDE and FINAL with override and final in cc/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 6 years, 2 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 | « cc/resources/task_graph_runner_perftest.cc ('k') | cc/resources/texture_uploader_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "cc/resources/task_graph_runner.h" 5 #include "cc/resources/task_graph_runner.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 tasks_[namespace_index].swap(new_tasks); 111 tasks_[namespace_index].swap(new_tasks);
112 } 112 }
113 113
114 protected: 114 protected:
115 class FakeTaskImpl : public Task { 115 class FakeTaskImpl : public Task {
116 public: 116 public:
117 FakeTaskImpl(TaskGraphRunnerTestBase* test, int namespace_index, int id) 117 FakeTaskImpl(TaskGraphRunnerTestBase* test, int namespace_index, int id)
118 : test_(test), namespace_index_(namespace_index), id_(id) {} 118 : test_(test), namespace_index_(namespace_index), id_(id) {}
119 119
120 // Overridden from Task: 120 // Overridden from Task:
121 virtual void RunOnWorkerThread() OVERRIDE { 121 virtual void RunOnWorkerThread() override {
122 test_->RunTaskOnWorkerThread(namespace_index_, id_); 122 test_->RunTaskOnWorkerThread(namespace_index_, id_);
123 } 123 }
124 124
125 virtual void CompleteOnOriginThread() { 125 virtual void CompleteOnOriginThread() {
126 test_->OnTaskCompleted(namespace_index_, id_); 126 test_->OnTaskCompleted(namespace_index_, id_);
127 } 127 }
128 128
129 protected: 129 protected:
130 virtual ~FakeTaskImpl() {} 130 virtual ~FakeTaskImpl() {}
131 131
132 private: 132 private:
133 TaskGraphRunnerTestBase* test_; 133 TaskGraphRunnerTestBase* test_;
134 int namespace_index_; 134 int namespace_index_;
135 int id_; 135 int id_;
136 136
137 DISALLOW_COPY_AND_ASSIGN(FakeTaskImpl); 137 DISALLOW_COPY_AND_ASSIGN(FakeTaskImpl);
138 }; 138 };
139 139
140 class FakeDependentTaskImpl : public FakeTaskImpl { 140 class FakeDependentTaskImpl : public FakeTaskImpl {
141 public: 141 public:
142 FakeDependentTaskImpl(TaskGraphRunnerTestBase* test, 142 FakeDependentTaskImpl(TaskGraphRunnerTestBase* test,
143 int namespace_index, 143 int namespace_index,
144 int id) 144 int id)
145 : FakeTaskImpl(test, namespace_index, id) {} 145 : FakeTaskImpl(test, namespace_index, id) {}
146 146
147 // Overridden from FakeTaskImpl: 147 // Overridden from FakeTaskImpl:
148 virtual void CompleteOnOriginThread() OVERRIDE {} 148 virtual void CompleteOnOriginThread() override {}
149 149
150 private: 150 private:
151 virtual ~FakeDependentTaskImpl() {} 151 virtual ~FakeDependentTaskImpl() {}
152 152
153 DISALLOW_COPY_AND_ASSIGN(FakeDependentTaskImpl); 153 DISALLOW_COPY_AND_ASSIGN(FakeDependentTaskImpl);
154 }; 154 };
155 155
156 scoped_ptr<TaskGraphRunner> task_graph_runner_; 156 scoped_ptr<TaskGraphRunner> task_graph_runner_;
157 NamespaceToken namespace_token_[kNamespaceCount]; 157 NamespaceToken namespace_token_[kNamespaceCount];
158 Task::Vector tasks_[kNamespaceCount]; 158 Task::Vector tasks_[kNamespaceCount];
159 Task::Vector dependents_[kNamespaceCount]; 159 Task::Vector dependents_[kNamespaceCount];
160 std::vector<unsigned> run_task_ids_[kNamespaceCount]; 160 std::vector<unsigned> run_task_ids_[kNamespaceCount];
161 base::Lock run_task_ids_lock_; 161 base::Lock run_task_ids_lock_;
162 std::vector<unsigned> on_task_completed_ids_[kNamespaceCount]; 162 std::vector<unsigned> on_task_completed_ids_[kNamespaceCount];
163 }; 163 };
164 164
165 class TaskGraphRunnerTest : public TaskGraphRunnerTestBase, 165 class TaskGraphRunnerTest : public TaskGraphRunnerTestBase,
166 public testing::TestWithParam<int>, 166 public testing::TestWithParam<int>,
167 public base::DelegateSimpleThread::Delegate { 167 public base::DelegateSimpleThread::Delegate {
168 public: 168 public:
169 // Overridden from testing::Test: 169 // Overridden from testing::Test:
170 virtual void SetUp() OVERRIDE { 170 virtual void SetUp() override {
171 const size_t num_threads = GetParam(); 171 const size_t num_threads = GetParam();
172 while (workers_.size() < num_threads) { 172 while (workers_.size() < num_threads) {
173 scoped_ptr<base::DelegateSimpleThread> worker = 173 scoped_ptr<base::DelegateSimpleThread> worker =
174 make_scoped_ptr(new base::DelegateSimpleThread(this, "TestWorker")); 174 make_scoped_ptr(new base::DelegateSimpleThread(this, "TestWorker"));
175 worker->Start(); 175 worker->Start();
176 workers_.push_back(worker.Pass()); 176 workers_.push_back(worker.Pass());
177 } 177 }
178 178
179 for (int i = 0; i < kNamespaceCount; ++i) 179 for (int i = 0; i < kNamespaceCount; ++i)
180 namespace_token_[i] = task_graph_runner_->GetNamespaceToken(); 180 namespace_token_[i] = task_graph_runner_->GetNamespaceToken();
181 } 181 }
182 virtual void TearDown() OVERRIDE { 182 virtual void TearDown() override {
183 task_graph_runner_->Shutdown(); 183 task_graph_runner_->Shutdown();
184 while (workers_.size()) { 184 while (workers_.size()) {
185 scoped_ptr<base::DelegateSimpleThread> worker = workers_.take_front(); 185 scoped_ptr<base::DelegateSimpleThread> worker = workers_.take_front();
186 worker->Join(); 186 worker->Join();
187 } 187 }
188 } 188 }
189 189
190 private: 190 private:
191 // Overridden from base::DelegateSimpleThread::Delegate: 191 // Overridden from base::DelegateSimpleThread::Delegate:
192 virtual void Run() OVERRIDE { task_graph_runner_->Run(); } 192 virtual void Run() override { task_graph_runner_->Run(); }
193 193
194 ScopedPtrDeque<base::DelegateSimpleThread> workers_; 194 ScopedPtrDeque<base::DelegateSimpleThread> workers_;
195 }; 195 };
196 196
197 TEST_P(TaskGraphRunnerTest, Basic) { 197 TEST_P(TaskGraphRunnerTest, Basic) {
198 for (int i = 0; i < kNamespaceCount; ++i) { 198 for (int i = 0; i < kNamespaceCount; ++i) {
199 EXPECT_EQ(0u, run_task_ids(i).size()); 199 EXPECT_EQ(0u, run_task_ids(i).size());
200 EXPECT_EQ(0u, on_task_completed_ids(i).size()); 200 EXPECT_EQ(0u, on_task_completed_ids(i).size());
201 201
202 ScheduleTasks(i, std::vector<TaskInfo>(1, TaskInfo(i, 0u, 0u, 0u, 0u))); 202 ScheduleTasks(i, std::vector<TaskInfo>(1, TaskInfo(i, 0u, 0u, 0u, 0u)));
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 INSTANTIATE_TEST_CASE_P(TaskGraphRunnerTests, 278 INSTANTIATE_TEST_CASE_P(TaskGraphRunnerTests,
279 TaskGraphRunnerTest, 279 TaskGraphRunnerTest,
280 ::testing::Range(1, 5)); 280 ::testing::Range(1, 5));
281 281
282 class TaskGraphRunnerSingleThreadTest 282 class TaskGraphRunnerSingleThreadTest
283 : public TaskGraphRunnerTestBase, 283 : public TaskGraphRunnerTestBase,
284 public testing::Test, 284 public testing::Test,
285 public base::DelegateSimpleThread::Delegate { 285 public base::DelegateSimpleThread::Delegate {
286 public: 286 public:
287 // Overridden from testing::Test: 287 // Overridden from testing::Test:
288 virtual void SetUp() OVERRIDE { 288 virtual void SetUp() override {
289 worker_.reset(new base::DelegateSimpleThread(this, "TestWorker")); 289 worker_.reset(new base::DelegateSimpleThread(this, "TestWorker"));
290 worker_->Start(); 290 worker_->Start();
291 291
292 for (int i = 0; i < kNamespaceCount; ++i) 292 for (int i = 0; i < kNamespaceCount; ++i)
293 namespace_token_[i] = task_graph_runner_->GetNamespaceToken(); 293 namespace_token_[i] = task_graph_runner_->GetNamespaceToken();
294 } 294 }
295 virtual void TearDown() OVERRIDE { 295 virtual void TearDown() override {
296 task_graph_runner_->Shutdown(); 296 task_graph_runner_->Shutdown();
297 worker_->Join(); 297 worker_->Join();
298 } 298 }
299 299
300 private: 300 private:
301 // Overridden from base::DelegateSimpleThread::Delegate: 301 // Overridden from base::DelegateSimpleThread::Delegate:
302 virtual void Run() OVERRIDE { task_graph_runner_->Run(); } 302 virtual void Run() override { task_graph_runner_->Run(); }
303 303
304 scoped_ptr<base::DelegateSimpleThread> worker_; 304 scoped_ptr<base::DelegateSimpleThread> worker_;
305 }; 305 };
306 306
307 TEST_F(TaskGraphRunnerSingleThreadTest, Priority) { 307 TEST_F(TaskGraphRunnerSingleThreadTest, Priority) {
308 for (int i = 0; i < kNamespaceCount; ++i) { 308 for (int i = 0; i < kNamespaceCount; ++i) {
309 TaskInfo tasks[] = {TaskInfo(i, 0u, 2u, 1u, 1u), // Priority 1 309 TaskInfo tasks[] = {TaskInfo(i, 0u, 2u, 1u, 1u), // Priority 1
310 TaskInfo(i, 1u, 3u, 1u, 0u) // Priority 0 310 TaskInfo(i, 1u, 3u, 1u, 0u) // Priority 0
311 }; 311 };
312 ScheduleTasks(i, std::vector<TaskInfo>(tasks, tasks + arraysize(tasks))); 312 ScheduleTasks(i, std::vector<TaskInfo>(tasks, tasks + arraysize(tasks)));
313 } 313 }
314 314
315 for (int i = 0; i < kNamespaceCount; ++i) { 315 for (int i = 0; i < kNamespaceCount; ++i) {
316 RunAllTasks(i); 316 RunAllTasks(i);
317 317
318 // Check if tasks ran in order of priority. 318 // Check if tasks ran in order of priority.
319 ASSERT_EQ(4u, run_task_ids(i).size()); 319 ASSERT_EQ(4u, run_task_ids(i).size());
320 EXPECT_EQ(1u, run_task_ids(i)[0]); 320 EXPECT_EQ(1u, run_task_ids(i)[0]);
321 EXPECT_EQ(3u, run_task_ids(i)[1]); 321 EXPECT_EQ(3u, run_task_ids(i)[1]);
322 EXPECT_EQ(0u, run_task_ids(i)[2]); 322 EXPECT_EQ(0u, run_task_ids(i)[2]);
323 EXPECT_EQ(2u, run_task_ids(i)[3]); 323 EXPECT_EQ(2u, run_task_ids(i)[3]);
324 ASSERT_EQ(2u, on_task_completed_ids(i).size()); 324 ASSERT_EQ(2u, on_task_completed_ids(i).size());
325 EXPECT_EQ(1u, on_task_completed_ids(i)[0]); 325 EXPECT_EQ(1u, on_task_completed_ids(i)[0]);
326 EXPECT_EQ(0u, on_task_completed_ids(i)[1]); 326 EXPECT_EQ(0u, on_task_completed_ids(i)[1]);
327 } 327 }
328 } 328 }
329 329
330 } // namespace 330 } // namespace
331 } // namespace cc 331 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/task_graph_runner_perftest.cc ('k') | cc/resources/texture_uploader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698