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

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

Issue 9689053: Fix uses of TimeDelta in base/test. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 9 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 | « no previous file | no next file » | 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 141 }
142 142
143 std::map<int, int> expected_task_run_counts; 143 std::map<int, int> expected_task_run_counts;
144 144
145 this->delegate_.StartTaskRunner(); 145 this->delegate_.StartTaskRunner();
146 scoped_refptr<TaskRunner> task_runner = this->delegate_.GetTaskRunner(); 146 scoped_refptr<TaskRunner> task_runner = this->delegate_.GetTaskRunner();
147 // Post each ith task i+1 times with delays from 0-i. 147 // Post each ith task i+1 times with delays from 0-i.
148 for (int i = 0; i < 20; ++i) { 148 for (int i = 0; i < 20; ++i) {
149 const Closure& ith_task = this->task_tracker_->WrapTask(Closure(), i); 149 const Closure& ith_task = this->task_tracker_->WrapTask(Closure(), i);
150 for (int j = 0; j < i + 1; ++j) { 150 for (int j = 0; j < i + 1; ++j) {
151 task_runner->PostDelayedTask(FROM_HERE, ith_task, j); 151 task_runner->PostDelayedTask(
152 FROM_HERE, ith_task, base::TimeDelta::FromMilliseconds(j));
152 ++expected_task_run_counts[i]; 153 ++expected_task_run_counts[i];
153 } 154 }
154 } 155 }
155 this->delegate_.StopTaskRunner(); 156 this->delegate_.StopTaskRunner();
156 157
157 EXPECT_EQ(expected_task_run_counts, 158 EXPECT_EQ(expected_task_run_counts,
158 this->task_tracker_->GetTaskRunCounts()); 159 this->task_tracker_->GetTaskRunCounts());
159 } 160 }
160 161
161 namespace internal { 162 namespace internal {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 EXPECT_EQ(expected_task_run_counts, 207 EXPECT_EQ(expected_task_run_counts,
207 this->task_tracker_->GetTaskRunCounts()); 208 this->task_tracker_->GetTaskRunCounts());
208 } 209 }
209 210
210 REGISTER_TYPED_TEST_CASE_P( 211 REGISTER_TYPED_TEST_CASE_P(
211 TaskRunnerTest, Basic, Delayed, RunsTasksOnCurrentThread); 212 TaskRunnerTest, Basic, Delayed, RunsTasksOnCurrentThread);
212 213
213 } // namespace base 214 } // namespace base
214 215
215 #endif //#define BASE_TEST_TASK_RUNNER_TEST_TEMPLATE_H_ 216 #endif //#define BASE_TEST_TASK_RUNNER_TEST_TEMPLATE_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698