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

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

Issue 734063004: Update from https://crrev.com/304418 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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/tile_manager.h » ('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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 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 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 void Run() override { task_graph_runner_->Run(); } 192 void Run() override { task_graph_runner_->Run(); }
(...skipping 85 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 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 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 void Run() override { task_graph_runner_->Run(); } 302 void Run() override { task_graph_runner_->Run(); }
303 303
304 scoped_ptr<base::DelegateSimpleThread> worker_; 304 scoped_ptr<base::DelegateSimpleThread> worker_;
305 }; 305 };
(...skipping 16 matching lines...) Expand all
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/tile_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698