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

Side by Side Diff: base/task/cancelable_task_tracker_unittest.cc

Issue 2335153002: Use TestSimpleTaskRunner::NumPendingTasks instead of GetPendingTasks().size() (Closed)
Patch Set: rebase Created 4 years, 3 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 | chrome/browser/notifications/extension_welcome_notification_unittest.cc » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "base/task/cancelable_task_tracker.h" 5 #include "base/task/cancelable_task_tracker.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 #include <deque> 8 #include <deque>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // Post a task with the task tracker but cancel it before running the 105 // Post a task with the task tracker but cancel it before running the
106 // task runner. The task should not run. 106 // task runner. The task should not run.
107 TEST_F(CancelableTaskTrackerTest, CancelPostedTask) { 107 TEST_F(CancelableTaskTrackerTest, CancelPostedTask) {
108 scoped_refptr<TestSimpleTaskRunner> test_task_runner( 108 scoped_refptr<TestSimpleTaskRunner> test_task_runner(
109 new TestSimpleTaskRunner()); 109 new TestSimpleTaskRunner());
110 110
111 CancelableTaskTracker::TaskId task_id = task_tracker_.PostTask( 111 CancelableTaskTracker::TaskId task_id = task_tracker_.PostTask(
112 test_task_runner.get(), FROM_HERE, MakeExpectedNotRunClosure(FROM_HERE)); 112 test_task_runner.get(), FROM_HERE, MakeExpectedNotRunClosure(FROM_HERE));
113 EXPECT_NE(CancelableTaskTracker::kBadTaskId, task_id); 113 EXPECT_NE(CancelableTaskTracker::kBadTaskId, task_id);
114 114
115 EXPECT_EQ(1U, test_task_runner->GetPendingTasks().size()); 115 EXPECT_EQ(1U, test_task_runner->NumPendingTasks());
116 116
117 task_tracker_.TryCancel(task_id); 117 task_tracker_.TryCancel(task_id);
118 118
119 test_task_runner->RunUntilIdle(); 119 test_task_runner->RunUntilIdle();
120 } 120 }
121 121
122 // Post a task with reply with the task tracker and cancel it before 122 // Post a task with reply with the task tracker and cancel it before
123 // running the task runner. Neither the task nor the reply should 123 // running the task runner. Neither the task nor the reply should
124 // run. 124 // run.
125 TEST_F(CancelableTaskTrackerTest, CancelPostedTaskAndReply) { 125 TEST_F(CancelableTaskTrackerTest, CancelPostedTaskAndReply) {
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 407
408 bad_thread.task_runner()->PostTask( 408 bad_thread.task_runner()->PostTask(
409 FROM_HERE, 409 FROM_HERE,
410 Bind(&MaybeRunDeadlyTaskTrackerMemberFunction, Unretained(&task_tracker_), 410 Bind(&MaybeRunDeadlyTaskTrackerMemberFunction, Unretained(&task_tracker_),
411 Bind(&CancelableTaskTracker::TryCancelAll))); 411 Bind(&CancelableTaskTracker::TryCancelAll)));
412 412
413 test_task_runner->RunUntilIdle(); 413 test_task_runner->RunUntilIdle();
414 } 414 }
415 415
416 } // namespace base 416 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/notifications/extension_welcome_notification_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698