| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This file defines tests that implementations of TaskRunner should | 5 // This file defines tests that implementations of TaskRunner should |
| 6 // pass in order to be conformant, as well as test cases for optional behavior. | 6 // pass in order to be conformant, as well as test cases for optional behavior. |
| 7 // Here's how you use it to test your implementation. | 7 // Here's how you use it to test your implementation. |
| 8 // | 8 // |
| 9 // Say your class is called MyTaskRunner. Then you need to define a | 9 // Say your class is called MyTaskRunner. Then you need to define a |
| 10 // class called MyTaskRunnerTestDelegate in my_task_runner_unittest.cc | 10 // class called MyTaskRunnerTestDelegate in my_task_runner_unittest.cc |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 } | 168 } |
| 169 | 169 |
| 170 // The TaskRunnerTest test case verifies behaviour that is expected from a | 170 // The TaskRunnerTest test case verifies behaviour that is expected from a |
| 171 // task runner in order to be conformant. | 171 // task runner in order to be conformant. |
| 172 REGISTER_TYPED_TEST_CASE_P(TaskRunnerTest, Basic, Delayed); | 172 REGISTER_TYPED_TEST_CASE_P(TaskRunnerTest, Basic, Delayed); |
| 173 | 173 |
| 174 namespace test { | 174 namespace test { |
| 175 | 175 |
| 176 // Calls RunsTasksOnCurrentThread() on |task_runner| and expects it to | 176 // Calls RunsTasksOnCurrentThread() on |task_runner| and expects it to |
| 177 // equal |expected_value|. | 177 // equal |expected_value|. |
| 178 void ExpectRunsTasksOnCurrentThread( | 178 void ExpectRunsTasksOnCurrentThread(bool expected_value, |
| 179 bool expected_value, | 179 TaskRunner* task_runner); |
| 180 const scoped_refptr<TaskRunner>& task_runner); | |
| 181 | 180 |
| 182 } // namespace test | 181 } // namespace test |
| 183 | 182 |
| 184 template <typename TaskRunnerTestDelegate> | 183 template <typename TaskRunnerTestDelegate> |
| 185 class TaskRunnerAffinityTest : public TaskRunnerTest<TaskRunnerTestDelegate> {}; | 184 class TaskRunnerAffinityTest : public TaskRunnerTest<TaskRunnerTestDelegate> {}; |
| 186 | 185 |
| 187 TYPED_TEST_CASE_P(TaskRunnerAffinityTest); | 186 TYPED_TEST_CASE_P(TaskRunnerAffinityTest); |
| 188 | 187 |
| 189 // Post a bunch of tasks to the task runner as well as to a separate | 188 // Post a bunch of tasks to the task runner as well as to a separate |
| 190 // thread, each checking the value of RunsTasksOnCurrentThread(), | 189 // thread, each checking the value of RunsTasksOnCurrentThread(), |
| (...skipping 28 matching lines...) Expand all Loading... |
| 219 this->task_tracker_->GetTaskRunCounts()); | 218 this->task_tracker_->GetTaskRunCounts()); |
| 220 } | 219 } |
| 221 | 220 |
| 222 // TaskRunnerAffinityTest tests that the TaskRunner implementation | 221 // TaskRunnerAffinityTest tests that the TaskRunner implementation |
| 223 // can determine if tasks will never be run on a specific thread. | 222 // can determine if tasks will never be run on a specific thread. |
| 224 REGISTER_TYPED_TEST_CASE_P(TaskRunnerAffinityTest, RunsTasksOnCurrentThread); | 223 REGISTER_TYPED_TEST_CASE_P(TaskRunnerAffinityTest, RunsTasksOnCurrentThread); |
| 225 | 224 |
| 226 } // namespace base | 225 } // namespace base |
| 227 | 226 |
| 228 #endif // BASE_TEST_TASK_RUNNER_TEST_TEMPLATE_H_ | 227 #endif // BASE_TEST_TASK_RUNNER_TEST_TEMPLATE_H_ |
| OLD | NEW |