| OLD | NEW |
| 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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 | 423 |
| 424 bad_thread.message_loop_proxy()->PostTask( | 424 bad_thread.message_loop_proxy()->PostTask( |
| 425 FROM_HERE, | 425 FROM_HERE, |
| 426 Bind(&MaybeRunDeadlyTaskTrackerMemberFunction, | 426 Bind(&MaybeRunDeadlyTaskTrackerMemberFunction, |
| 427 Unretained(&task_tracker_), | 427 Unretained(&task_tracker_), |
| 428 Bind(&CancelableTaskTracker::TryCancelAll))); | 428 Bind(&CancelableTaskTracker::TryCancelAll))); |
| 429 | 429 |
| 430 test_task_runner->RunUntilIdle(); | 430 test_task_runner->RunUntilIdle(); |
| 431 } | 431 } |
| 432 | 432 |
| 433 TEST_F(CancelableTaskTrackerTest, PostDelayedTask) { |
| 434 scoped_refptr<TestSimpleTaskRunner> test_task_runner( |
| 435 new TestSimpleTaskRunner()); |
| 436 |
| 437 EXPECT_FALSE(task_tracker_.HasTrackedTasks()); |
| 438 |
| 439 EXPECT_NE(CancelableTaskTracker::kBadTaskId, task_tracker_.PostDelayedTask( |
| 440 test_task_runner.get(), |
| 441 FROM_HERE, |
| 442 MakeExpectedRunClosure(FROM_HERE), |
| 443 TimeDelta())); |
| 444 |
| 445 EXPECT_NE(CancelableTaskTracker::kBadTaskId, task_tracker_.PostDelayedTask( |
| 446 test_task_runner.get(), |
| 447 FROM_HERE, |
| 448 MakeExpectedRunClosure(FROM_HERE), |
| 449 TimeDelta(TimeDelta::FromMilliseconds(1)))); |
| 450 |
| 451 test_task_runner->RunUntilIdle(); |
| 452 |
| 453 EXPECT_TRUE(task_tracker_.HasTrackedTasks()); |
| 454 |
| 455 RunCurrentLoopUntilIdle(); |
| 456 |
| 457 EXPECT_FALSE(task_tracker_.HasTrackedTasks()); |
| 458 } |
| 459 |
| 433 } // namespace base | 460 } // namespace base |
| OLD | NEW |