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

Unified Diff: base/task/cancelable_task_tracker_unittest.cc

Issue 2672753002: Refactor History's CommitLaterTask with CancelableCallback (Closed)
Patch Set: Remove leftover friendship. Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: base/task/cancelable_task_tracker_unittest.cc
diff --git a/base/task/cancelable_task_tracker_unittest.cc b/base/task/cancelable_task_tracker_unittest.cc
index fd480f3687511a7fadbf13f5fc0f7014a9a5e7fe..c04165e296263877282ced55e4df7b7eadf915bd 100644
--- a/base/task/cancelable_task_tracker_unittest.cc
+++ b/base/task/cancelable_task_tracker_unittest.cc
@@ -316,6 +316,29 @@ TEST_F(CancelableTaskTrackerTest, HasTrackedTasksPostWithReply) {
EXPECT_FALSE(task_tracker_.HasTrackedTasks());
}
+// Post a task with a delay and cancel it. HasTrackedTasks() should return true
+// from when the task is posted until it is canceled.
+TEST_F(CancelableTaskTrackerTest, HasTrackedTasksPostDelayed) {
Marc Treib 2017/02/02 10:52:21 I think there's a few more tests here that should
mastiz 2017/02/02 12:35:54 I added these but then rethought the whole approac
+ scoped_refptr<TestSimpleTaskRunner> test_task_runner(
+ new TestSimpleTaskRunner());
+
+ EXPECT_FALSE(task_tracker_.HasTrackedTasks());
+
+ ignore_result(task_tracker_.PostDelayedTask(
+ test_task_runner.get(), FROM_HERE, MakeExpectedNotRunClosure(FROM_HERE),
+ base::TimeDelta::FromSeconds(1)));
+
+ task_tracker_.TryCancelAll();
+
+ test_task_runner->RunUntilIdle();
+
+ EXPECT_TRUE(task_tracker_.HasTrackedTasks());
+
+ RunCurrentLoopUntilIdle();
+
+ EXPECT_FALSE(task_tracker_.HasTrackedTasks());
+}
+
// Create a new tracked task ID. HasTrackedTasks() should return true
// until the IsCanceledCallback is destroyed.
TEST_F(CancelableTaskTrackerTest, HasTrackedTasksIsCancelled) {

Powered by Google App Engine
This is Rietveld 408576698