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

Unified Diff: base/test/scoped_mock_time_message_loop_task_runner_unittest.cc

Issue 2434783002: Use OnceClosure in TestPendingTask (Closed)
Patch Set: +comment 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
« no previous file with comments | « base/test/scoped_mock_time_message_loop_task_runner.cc ('k') | base/test/test_mock_time_task_runner.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/scoped_mock_time_message_loop_task_runner_unittest.cc
diff --git a/base/test/scoped_mock_time_message_loop_task_runner_unittest.cc b/base/test/scoped_mock_time_message_loop_task_runner_unittest.cc
index 4d782e2cc26c0b6ea9bff7b5dea0209b065a2969..daca7827e270fa0a7a810ea838d93af68ba083d6 100644
--- a/base/test/scoped_mock_time_message_loop_task_runner_unittest.cc
+++ b/base/test/scoped_mock_time_message_loop_task_runner_unittest.cc
@@ -26,9 +26,13 @@ TaskRunner* GetCurrentTaskRunner() {
return MessageLoop::current()->task_runner().get();
}
+void AssignTrue(bool* out) {
+ *out = true;
+}
+
// Pops a task from the front of |pending_tasks| and returns it.
TestPendingTask PopFront(std::deque<TestPendingTask>* pending_tasks) {
- TestPendingTask task = pending_tasks->front();
+ TestPendingTask task = std::move(pending_tasks->front());
pending_tasks->pop_front();
return task;
}
@@ -69,10 +73,13 @@ TEST_F(ScopedMockTimeMessageLoopTaskRunnerTest,
auto scoped_task_runner_ =
base::MakeUnique<ScopedMockTimeMessageLoopTaskRunner>();
+ bool task_10_has_run = false;
+ bool task_11_has_run = false;
+
Closure task_1 = Bind(&DoNothing);
Closure task_2 = Bind(&DoNothing);
- Closure task_10 = Bind(&DoNothing);
- Closure task_11 = Bind(&DoNothing);
+ Closure task_10 = Bind(&AssignTrue, &task_10_has_run);
+ Closure task_11 = Bind(&AssignTrue, &task_11_has_run);
constexpr TimeDelta task_1_delay = TimeDelta::FromSeconds(1);
constexpr TimeDelta task_2_delay = TimeDelta::FromSeconds(2);
@@ -96,11 +103,15 @@ TEST_F(ScopedMockTimeMessageLoopTaskRunnerTest,
EXPECT_EQ(2U, pending_tasks.size());
TestPendingTask pending_task = PopFront(&pending_tasks);
- EXPECT_TRUE(task_10.Equals(pending_task.task));
+ EXPECT_FALSE(task_10_has_run);
+ std::move(pending_task.task).Run();
+ EXPECT_TRUE(task_10_has_run);
EXPECT_EQ(task_10_delay - step_time_by, pending_task.delay);
pending_task = PopFront(&pending_tasks);
- EXPECT_TRUE(task_11.Equals(pending_task.task));
+ EXPECT_FALSE(task_11_has_run);
+ std::move(pending_task.task).Run();
+ EXPECT_TRUE(task_11_has_run);
EXPECT_EQ(task_11_delay - step_time_by, pending_task.delay);
}
« no previous file with comments | « base/test/scoped_mock_time_message_loop_task_runner.cc ('k') | base/test/test_mock_time_task_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698