| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 #include "base/bind.h" | 61 #include "base/bind.h" |
| 62 #include "base/callback.h" | 62 #include "base/callback.h" |
| 63 #include "base/location.h" | 63 #include "base/location.h" |
| 64 #include "base/memory/ref_counted.h" | 64 #include "base/memory/ref_counted.h" |
| 65 #include "base/single_thread_task_runner.h" | 65 #include "base/single_thread_task_runner.h" |
| 66 #include "base/synchronization/condition_variable.h" | 66 #include "base/synchronization/condition_variable.h" |
| 67 #include "base/synchronization/lock.h" | 67 #include "base/synchronization/lock.h" |
| 68 #include "base/task_runner.h" | 68 #include "base/task_runner.h" |
| 69 #include "base/threading/thread.h" | 69 #include "base/threading/thread.h" |
| 70 #include "base/tracked_objects.h" | 70 #include "base/tracked_objects.h" |
| 71 #include "testing/gtest/include/gtest/gtest.h" | 71 #include "testing/gtest/googletest/include/gtest/gtest.h" |
| 72 | 72 |
| 73 namespace base { | 73 namespace base { |
| 74 | 74 |
| 75 namespace internal { | 75 namespace internal { |
| 76 | 76 |
| 77 // Utility class that keeps track of how many times particular tasks | 77 // Utility class that keeps track of how many times particular tasks |
| 78 // are run. | 78 // are run. |
| 79 class TaskTracker : public RefCountedThreadSafe<TaskTracker> { | 79 class TaskTracker : public RefCountedThreadSafe<TaskTracker> { |
| 80 public: | 80 public: |
| 81 TaskTracker(); | 81 TaskTracker(); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 this->task_tracker_->GetTaskRunCounts()); | 225 this->task_tracker_->GetTaskRunCounts()); |
| 226 } | 226 } |
| 227 | 227 |
| 228 // TaskRunnerAffinityTest tests that the TaskRunner implementation | 228 // TaskRunnerAffinityTest tests that the TaskRunner implementation |
| 229 // can determine if tasks will never be run on a specific thread. | 229 // can determine if tasks will never be run on a specific thread. |
| 230 REGISTER_TYPED_TEST_CASE_P(TaskRunnerAffinityTest, RunsTasksOnCurrentThread); | 230 REGISTER_TYPED_TEST_CASE_P(TaskRunnerAffinityTest, RunsTasksOnCurrentThread); |
| 231 | 231 |
| 232 } // namespace base | 232 } // namespace base |
| 233 | 233 |
| 234 #endif // BASE_TEST_TASK_RUNNER_TEST_TEMPLATE_H_ | 234 #endif // BASE_TEST_TASK_RUNNER_TEST_TEMPLATE_H_ |
| OLD | NEW |