| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CC_TEST_TASK_GRAPH_RUNNER_TEST_TEMPLATE_H_ | 5 #ifndef CC_TEST_TASK_GRAPH_RUNNER_TEST_TEMPLATE_H_ |
| 6 #define CC_TEST_TASK_GRAPH_RUNNER_TEST_TEMPLATE_H_ | 6 #define CC_TEST_TASK_GRAPH_RUNNER_TEST_TEMPLATE_H_ |
| 7 | 7 |
| 8 #include "cc/raster/task_graph_runner.h" | 8 #include "cc/raster/task_graph_runner.h" |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 void RunAllTasks(int namespace_index); | 48 void RunAllTasks(int namespace_index); |
| 49 void RunTaskOnWorkerThread(int namespace_index, unsigned id); | 49 void RunTaskOnWorkerThread(int namespace_index, unsigned id); |
| 50 void OnTaskCompleted(int namespace_index, unsigned id); | 50 void OnTaskCompleted(int namespace_index, unsigned id); |
| 51 const std::vector<unsigned>& run_task_ids(int namespace_index); | 51 const std::vector<unsigned>& run_task_ids(int namespace_index); |
| 52 const std::vector<unsigned>& on_task_completed_ids(int namespace_index); | 52 const std::vector<unsigned>& on_task_completed_ids(int namespace_index); |
| 53 void ScheduleTasks(int namespace_index, const std::vector<TaskInfo>& tasks); | 53 void ScheduleTasks(int namespace_index, const std::vector<TaskInfo>& tasks); |
| 54 | 54 |
| 55 static const int kNamespaceCount = 3; | 55 static const int kNamespaceCount = 3; |
| 56 | 56 |
| 57 protected: | 57 protected: |
| 58 class FakeTaskImpl : public Task { | 58 class FakeTaskImpl : public DependencyTask { |
| 59 public: | 59 public: |
| 60 FakeTaskImpl(TaskGraphRunnerTestBase* test, int namespace_index, int id) | 60 FakeTaskImpl(TaskGraphRunnerTestBase* test, int namespace_index, int id) |
| 61 : test_(test), namespace_index_(namespace_index), id_(id) {} | 61 : test_(test), namespace_index_(namespace_index), id_(id) {} |
| 62 | 62 |
| 63 // Overridden from Task: | 63 // Overridden from Task: |
| 64 void RunOnWorkerThread() override; | 64 void RunOnWorkerThread() override; |
| 65 | 65 void ScheduleOnOriginThread(DependencyTaskClient* client) override{}; |
| 66 virtual void CompleteOnOriginThread(); | 66 void CompleteOnOriginThread(DependencyTaskClient* client) override; |
| 67 | 67 |
| 68 protected: | 68 protected: |
| 69 ~FakeTaskImpl() override {} | 69 ~FakeTaskImpl() override {} |
| 70 | 70 |
| 71 private: | 71 private: |
| 72 TaskGraphRunnerTestBase* test_; | 72 TaskGraphRunnerTestBase* test_; |
| 73 int namespace_index_; | 73 int namespace_index_; |
| 74 int id_; | 74 int id_; |
| 75 | 75 |
| 76 DISALLOW_COPY_AND_ASSIGN(FakeTaskImpl); | 76 DISALLOW_COPY_AND_ASSIGN(FakeTaskImpl); |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 class FakeDependentTaskImpl : public FakeTaskImpl { | 79 class FakeDependentTaskImpl : public FakeTaskImpl { |
| 80 public: | 80 public: |
| 81 FakeDependentTaskImpl(TaskGraphRunnerTestBase* test, | 81 FakeDependentTaskImpl(TaskGraphRunnerTestBase* test, |
| 82 int namespace_index, | 82 int namespace_index, |
| 83 int id) | 83 int id) |
| 84 : FakeTaskImpl(test, namespace_index, id) {} | 84 : FakeTaskImpl(test, namespace_index, id) {} |
| 85 | 85 |
| 86 // Overridden from FakeTaskImpl: | 86 // Overridden from FakeTaskImpl: |
| 87 void CompleteOnOriginThread() override {} | 87 void CompleteOnOriginThread(DependencyTaskClient* client) override {} |
| 88 | 88 |
| 89 private: | 89 private: |
| 90 ~FakeDependentTaskImpl() override {} | 90 ~FakeDependentTaskImpl() override {} |
| 91 | 91 |
| 92 DISALLOW_COPY_AND_ASSIGN(FakeDependentTaskImpl); | 92 DISALLOW_COPY_AND_ASSIGN(FakeDependentTaskImpl); |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 TaskGraphRunner* task_graph_runner_; | 95 TaskGraphRunner* task_graph_runner_; |
| 96 NamespaceToken namespace_token_[kNamespaceCount]; | 96 NamespaceToken namespace_token_[kNamespaceCount]; |
| 97 Task::Vector tasks_[kNamespaceCount]; | 97 DependencyTask::Vector tasks_[kNamespaceCount]; |
| 98 Task::Vector dependents_[kNamespaceCount]; | 98 DependencyTask::Vector dependents_[kNamespaceCount]; |
| 99 std::vector<unsigned> run_task_ids_[kNamespaceCount]; | 99 std::vector<unsigned> run_task_ids_[kNamespaceCount]; |
| 100 base::Lock run_task_ids_lock_; | 100 base::Lock run_task_ids_lock_; |
| 101 std::vector<unsigned> on_task_completed_ids_[kNamespaceCount]; | 101 std::vector<unsigned> on_task_completed_ids_[kNamespaceCount]; |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 template <typename TaskRunnerTestDelegate> | 104 template <typename TaskRunnerTestDelegate> |
| 105 class TaskGraphRunnerTest : public TaskGraphRunnerTestBase, | 105 class TaskGraphRunnerTest : public TaskGraphRunnerTestBase, |
| 106 public testing::Test { | 106 public testing::Test { |
| 107 public: | 107 public: |
| 108 // Overridden from testing::Test: | 108 // Overridden from testing::Test: |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 EXPECT_EQ(1u, this->on_task_completed_ids(i)[0]); | 291 EXPECT_EQ(1u, this->on_task_completed_ids(i)[0]); |
| 292 EXPECT_EQ(0u, this->on_task_completed_ids(i)[1]); | 292 EXPECT_EQ(0u, this->on_task_completed_ids(i)[1]); |
| 293 } | 293 } |
| 294 } | 294 } |
| 295 | 295 |
| 296 REGISTER_TYPED_TEST_CASE_P(SingleThreadTaskGraphRunnerTest, Priority); | 296 REGISTER_TYPED_TEST_CASE_P(SingleThreadTaskGraphRunnerTest, Priority); |
| 297 | 297 |
| 298 } // namespace cc | 298 } // namespace cc |
| 299 | 299 |
| 300 #endif // CC_TEST_TASK_GRAPH_RUNNER_TEST_TEMPLATE_H_ | 300 #endif // CC_TEST_TASK_GRAPH_RUNNER_TEST_TEMPLATE_H_ |
| OLD | NEW |