OLD | NEW |
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/raster/task_graph_runner.h" | 5 #include "cc/raster/task_graph_runner.h" |
6 | 6 |
| 7 #include <deque> |
7 #include <vector> | 8 #include <vector> |
8 | 9 |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
11 #include "base/threading/simple_thread.h" | 12 #include "base/threading/simple_thread.h" |
12 #include "cc/base/scoped_ptr_deque.h" | 13 #include "cc/base/container_util.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 | 15 |
15 namespace cc { | 16 namespace cc { |
16 namespace { | 17 namespace { |
17 | 18 |
18 const int kNamespaceCount = 3; | 19 const int kNamespaceCount = 3; |
19 | 20 |
20 class TaskGraphRunnerTestBase { | 21 class TaskGraphRunnerTestBase { |
21 public: | 22 public: |
22 struct TaskInfo { | 23 struct TaskInfo { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 make_scoped_ptr(new base::DelegateSimpleThread(this, "TestWorker")); | 175 make_scoped_ptr(new base::DelegateSimpleThread(this, "TestWorker")); |
175 worker->Start(); | 176 worker->Start(); |
176 workers_.push_back(worker.Pass()); | 177 workers_.push_back(worker.Pass()); |
177 } | 178 } |
178 | 179 |
179 for (int i = 0; i < kNamespaceCount; ++i) | 180 for (int i = 0; i < kNamespaceCount; ++i) |
180 namespace_token_[i] = task_graph_runner_->GetNamespaceToken(); | 181 namespace_token_[i] = task_graph_runner_->GetNamespaceToken(); |
181 } | 182 } |
182 void TearDown() override { | 183 void TearDown() override { |
183 task_graph_runner_->Shutdown(); | 184 task_graph_runner_->Shutdown(); |
184 while (workers_.size()) { | 185 while (!workers_.empty()) { |
185 scoped_ptr<base::DelegateSimpleThread> worker = workers_.take_front(); | 186 scoped_ptr<base::DelegateSimpleThread> worker = PopFront(&workers_); |
186 worker->Join(); | 187 worker->Join(); |
187 } | 188 } |
188 } | 189 } |
189 | 190 |
190 private: | 191 private: |
191 // Overridden from base::DelegateSimpleThread::Delegate: | 192 // Overridden from base::DelegateSimpleThread::Delegate: |
192 void Run() override { task_graph_runner_->Run(); } | 193 void Run() override { task_graph_runner_->Run(); } |
193 | 194 |
194 ScopedPtrDeque<base::DelegateSimpleThread> workers_; | 195 std::deque<scoped_ptr<base::DelegateSimpleThread>> workers_; |
195 }; | 196 }; |
196 | 197 |
197 TEST_P(TaskGraphRunnerTest, Basic) { | 198 TEST_P(TaskGraphRunnerTest, Basic) { |
198 for (int i = 0; i < kNamespaceCount; ++i) { | 199 for (int i = 0; i < kNamespaceCount; ++i) { |
199 EXPECT_EQ(0u, run_task_ids(i).size()); | 200 EXPECT_EQ(0u, run_task_ids(i).size()); |
200 EXPECT_EQ(0u, on_task_completed_ids(i).size()); | 201 EXPECT_EQ(0u, on_task_completed_ids(i).size()); |
201 | 202 |
202 ScheduleTasks(i, std::vector<TaskInfo>(1, TaskInfo(i, 0u, 0u, 0u, 0u))); | 203 ScheduleTasks(i, std::vector<TaskInfo>(1, TaskInfo(i, 0u, 0u, 0u, 0u))); |
203 } | 204 } |
204 | 205 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 EXPECT_EQ(0u, run_task_ids(i)[2]); | 323 EXPECT_EQ(0u, run_task_ids(i)[2]); |
323 EXPECT_EQ(2u, run_task_ids(i)[3]); | 324 EXPECT_EQ(2u, run_task_ids(i)[3]); |
324 ASSERT_EQ(2u, on_task_completed_ids(i).size()); | 325 ASSERT_EQ(2u, on_task_completed_ids(i).size()); |
325 EXPECT_EQ(1u, on_task_completed_ids(i)[0]); | 326 EXPECT_EQ(1u, on_task_completed_ids(i)[0]); |
326 EXPECT_EQ(0u, on_task_completed_ids(i)[1]); | 327 EXPECT_EQ(0u, on_task_completed_ids(i)[1]); |
327 } | 328 } |
328 } | 329 } |
329 | 330 |
330 } // namespace | 331 } // namespace |
331 } // namespace cc | 332 } // namespace cc |
OLD | NEW |