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

Side by Side Diff: base/test/task_runner_test_template.h

Issue 1113953002: Revert of base: Remove use of MessageLoopProxy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months 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 | « base/test/sequenced_worker_pool_owner.cc ('k') | base/test/thread_test_helper.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 (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 class defines tests that implementations of TaskRunner should 5 // This class defines tests that implementations of TaskRunner should
6 // pass in order to be conformant. Here's how you use it to test your 6 // pass in order to be conformant. Here's how you use it to test your
7 // implementation. 7 // 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 #ifndef BASE_TEST_TASK_RUNNER_TEST_TEMPLATE_H_ 47 #ifndef BASE_TEST_TASK_RUNNER_TEST_TEMPLATE_H_
48 #define BASE_TEST_TASK_RUNNER_TEST_TEMPLATE_H_ 48 #define BASE_TEST_TASK_RUNNER_TEST_TEMPLATE_H_
49 49
50 #include <cstddef> 50 #include <cstddef>
51 #include <map> 51 #include <map>
52 52
53 #include "base/basictypes.h" 53 #include "base/basictypes.h"
54 #include "base/bind.h" 54 #include "base/bind.h"
55 #include "base/callback.h" 55 #include "base/callback.h"
56 #include "base/location.h"
57 #include "base/memory/ref_counted.h" 56 #include "base/memory/ref_counted.h"
58 #include "base/single_thread_task_runner.h"
59 #include "base/synchronization/condition_variable.h" 57 #include "base/synchronization/condition_variable.h"
60 #include "base/synchronization/lock.h" 58 #include "base/synchronization/lock.h"
61 #include "base/task_runner.h" 59 #include "base/task_runner.h"
62 #include "base/threading/thread.h" 60 #include "base/threading/thread.h"
63 #include "base/tracked_objects.h" 61 #include "base/tracked_objects.h"
64 #include "testing/gtest/include/gtest/gtest.h" 62 #include "testing/gtest/include/gtest/gtest.h"
65 63
66 namespace base { 64 namespace base {
67 65
68 namespace internal { 66 namespace internal {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 Bind(&internal::ExpectRunsTasksOnCurrentThread, 188 Bind(&internal::ExpectRunsTasksOnCurrentThread,
191 true, task_runner), 189 true, task_runner),
192 i); 190 i);
193 const Closure& ith_non_task_runner_task = 191 const Closure& ith_non_task_runner_task =
194 this->task_tracker_->WrapTask( 192 this->task_tracker_->WrapTask(
195 Bind(&internal::ExpectRunsTasksOnCurrentThread, 193 Bind(&internal::ExpectRunsTasksOnCurrentThread,
196 false, task_runner), 194 false, task_runner),
197 i); 195 i);
198 for (int j = 0; j < i + 1; ++j) { 196 for (int j = 0; j < i + 1; ++j) {
199 task_runner->PostTask(FROM_HERE, ith_task_runner_task); 197 task_runner->PostTask(FROM_HERE, ith_task_runner_task);
200 thread.task_runner()->PostTask(FROM_HERE, ith_non_task_runner_task); 198 thread.message_loop()->PostTask(FROM_HERE, ith_non_task_runner_task);
201 expected_task_run_counts[i] += 2; 199 expected_task_run_counts[i] += 2;
202 } 200 }
203 } 201 }
204 202
205 this->delegate_.StopTaskRunner(); 203 this->delegate_.StopTaskRunner();
206 thread.Stop(); 204 thread.Stop();
207 205
208 EXPECT_EQ(expected_task_run_counts, 206 EXPECT_EQ(expected_task_run_counts,
209 this->task_tracker_->GetTaskRunCounts()); 207 this->task_tracker_->GetTaskRunCounts());
210 } 208 }
211 209
212 REGISTER_TYPED_TEST_CASE_P( 210 REGISTER_TYPED_TEST_CASE_P(
213 TaskRunnerTest, Basic, Delayed, RunsTasksOnCurrentThread); 211 TaskRunnerTest, Basic, Delayed, RunsTasksOnCurrentThread);
214 212
215 } // namespace base 213 } // namespace base
216 214
217 #endif // BASE_TEST_TASK_RUNNER_TEST_TEMPLATE_H_ 215 #endif // BASE_TEST_TASK_RUNNER_TEST_TEMPLATE_H_
OLDNEW
« no previous file with comments | « base/test/sequenced_worker_pool_owner.cc ('k') | base/test/thread_test_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698