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

Unified Diff: base/test/scoped_mock_time_message_loop_task_runner_unittest.cc

Issue 2627863002: Split Closure part of TestPendingTask out of the struct (Closed)
Patch Set: rebase 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.h » ('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..b4e0098cd87bc096ab30346aa782aac3be6e8704 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
@@ -15,7 +15,7 @@
#include "base/memory/ref_counted.h"
#include "base/message_loop/message_loop.h"
#include "base/test/test_mock_time_task_runner.h"
-#include "base/test/test_pending_task.h"
+#include "base/test/test_pending_task_info.h"
#include "base/time/time.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -26,11 +26,8 @@ TaskRunner* GetCurrentTaskRunner() {
return MessageLoop::current()->task_runner().get();
}
-// Pops a task from the front of |pending_tasks| and returns it.
-TestPendingTask PopFront(std::deque<TestPendingTask>* pending_tasks) {
- TestPendingTask task = pending_tasks->front();
- pending_tasks->pop_front();
- return task;
+void RecordTrue(bool* b) {
+ *b = true;
}
class ScopedMockTimeMessageLoopTaskRunnerTest : public testing::Test {
@@ -69,10 +66,13 @@ TEST_F(ScopedMockTimeMessageLoopTaskRunnerTest,
auto scoped_task_runner_ =
base::MakeUnique<ScopedMockTimeMessageLoopTaskRunner>();
+ bool has_task_10_run = false;
+ bool has_task_11_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(&RecordTrue, &has_task_10_run);
+ Closure task_11 = Bind(&RecordTrue, &has_task_11_run);
constexpr TimeDelta task_1_delay = TimeDelta::FromSeconds(1);
constexpr TimeDelta task_2_delay = TimeDelta::FromSeconds(2);
@@ -90,18 +90,26 @@ TEST_F(ScopedMockTimeMessageLoopTaskRunnerTest,
scoped_task_runner_.reset();
- std::deque<TestPendingTask> pending_tasks =
+ TestPendingTaskQueue pending_tasks =
original_task_runner()->TakePendingTasks();
-
EXPECT_EQ(2U, pending_tasks.size());
- TestPendingTask pending_task = PopFront(&pending_tasks);
- EXPECT_TRUE(task_10.Equals(pending_task.task));
- 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_EQ(task_11_delay - step_time_by, pending_task.delay);
+ TestPendingTaskInfo task_info = pending_tasks.front().first;
+ OnceClosure task = std::move(pending_tasks.front().second);
+ pending_tasks.pop_front();
+
+ EXPECT_FALSE(has_task_10_run);
+ std::move(task).Run();
+ EXPECT_TRUE(has_task_10_run);
+ EXPECT_EQ(task_10_delay - step_time_by, task_info.delay);
+
+ task_info = pending_tasks.front().first;
+ task = std::move(pending_tasks.front().second);
+ pending_tasks.pop_front();
+ EXPECT_FALSE(has_task_11_run);
+ std::move(task).Run();
+ EXPECT_TRUE(has_task_11_run);
+ EXPECT_EQ(task_11_delay - step_time_by, task_info.delay);
}
} // namespace
« no previous file with comments | « base/test/scoped_mock_time_message_loop_task_runner.cc ('k') | base/test/test_mock_time_task_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698