Index: cc/base/delayed_unique_notifier_unittest.cc |
diff --git a/cc/base/delayed_unique_notifier_unittest.cc b/cc/base/delayed_unique_notifier_unittest.cc |
index ae9ad17e9972d9c2dc4d314c86edc62ba2627891..fbd3b1d379ff3229ddf8b2ddf870e3854d47c140 100644 |
--- a/cc/base/delayed_unique_notifier_unittest.cc |
+++ b/cc/base/delayed_unique_notifier_unittest.cc |
@@ -6,7 +6,7 @@ |
#include "base/bind.h" |
#include "base/bind_helpers.h" |
-#include "base/test/test_pending_task.h" |
+#include "base/test/test_pending_task_info.h" |
#include "base/test/test_simple_task_runner.h" |
#include "cc/base/delayed_unique_notifier.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -44,7 +44,7 @@ class DelayedUniqueNotifierTest : public testing::Test { |
int NotificationCount() const { return notification_count_; } |
- std::deque<base::TestPendingTask> TakePendingTasks() { |
+ base::TestPendingTaskQueue TakePendingTasks() { |
return task_runner_->TakePendingTasks(); |
} |
@@ -69,11 +69,14 @@ TEST_F(DelayedUniqueNotifierTest, ZeroDelay) { |
notifier.SetNow(schedule_time); |
notifier.Schedule(); |
- std::deque<base::TestPendingTask> tasks = TakePendingTasks(); |
+ base::TestPendingTaskQueue tasks = TakePendingTasks(); |
ASSERT_EQ(1u, tasks.size()); |
- EXPECT_EQ(base::TimeTicks() + delay, tasks[0].GetTimeToRun()); |
+ base::TestPendingTaskInfo task_info = tasks[0].first; |
+ base::OnceClosure task = std::move(tasks[0].second); |
- tasks[0].task.Run(); |
+ EXPECT_EQ(base::TimeTicks() + delay, task_info.GetTimeToRun()); |
+ |
+ std::move(task).Run(); |
EXPECT_EQ(1, NotificationCount()); |
// 5 schedules should result in only one run. |
@@ -82,9 +85,11 @@ TEST_F(DelayedUniqueNotifierTest, ZeroDelay) { |
tasks = TakePendingTasks(); |
ASSERT_EQ(1u, tasks.size()); |
- EXPECT_EQ(base::TimeTicks() + delay, tasks[0].GetTimeToRun()); |
+ task_info = tasks[0].first; |
+ task = std::move(tasks[0].second); |
+ EXPECT_EQ(base::TimeTicks() + delay, task_info.GetTimeToRun()); |
- tasks[0].task.Run(); |
+ std::move(task).Run(); |
EXPECT_EQ(2, NotificationCount()); |
} |
@@ -104,44 +109,50 @@ TEST_F(DelayedUniqueNotifierTest, SmallDelay) { |
notifier.SetNow(schedule_time); |
notifier.Schedule(); |
- std::deque<base::TestPendingTask> tasks = TakePendingTasks(); |
+ base::TestPendingTaskQueue tasks = TakePendingTasks(); |
ASSERT_EQ(1u, tasks.size()); |
- EXPECT_EQ(base::TimeTicks() + delay, tasks[0].GetTimeToRun()); |
+ base::TestPendingTaskInfo task_info = tasks[0].first; |
+ base::OnceClosure task = std::move(tasks[0].second); |
+ EXPECT_EQ(base::TimeTicks() + delay, task_info.GetTimeToRun()); |
// It's not yet time to run, so we expect no notifications. |
- tasks[0].task.Run(); |
+ std::move(task).Run(); |
EXPECT_EQ(0, NotificationCount()); |
tasks = TakePendingTasks(); |
- |
ASSERT_EQ(1u, tasks.size()); |
+ task_info = tasks[0].first; |
+ task = std::move(tasks[0].second); |
+ |
// Now the time should be delay minus whatever the value of now happens to be |
// (now: 30, run time: 50). |
base::TimeTicks scheduled_run_time = notifier.Now() + delay; |
base::TimeTicks scheduled_delay = |
base::TimeTicks() + (scheduled_run_time - notifier.Now()); |
- EXPECT_EQ(scheduled_delay, tasks[0].GetTimeToRun()); |
+ EXPECT_EQ(scheduled_delay, task_info.GetTimeToRun()); |
// Move closer to the run time (time: 49, run time: 50). |
notifier.SetNow(notifier.Now() + base::TimeDelta::FromInternalValue(19)); |
// It's not yet time to run, so we expect no notifications. |
- tasks[0].task.Run(); |
+ std::move(task).Run(); |
EXPECT_EQ(0, NotificationCount()); |
tasks = TakePendingTasks(); |
ASSERT_EQ(1u, tasks.size()); |
+ task_info = tasks[0].first; |
+ task = std::move(tasks[0].second); |
// Now the time should be delay minus whatever the value of now happens to be. |
scheduled_delay = base::TimeTicks() + (scheduled_run_time - notifier.Now()); |
- EXPECT_EQ(scheduled_delay, tasks[0].GetTimeToRun()); |
+ EXPECT_EQ(scheduled_delay, task_info.GetTimeToRun()); |
// Move to exactly the run time (time: 50, run time: 50). |
notifier.SetNow(notifier.Now() + base::TimeDelta::FromInternalValue(1)); |
// It's time to run! |
- tasks[0].task.Run(); |
+ std::move(task).Run(); |
EXPECT_EQ(1, NotificationCount()); |
tasks = TakePendingTasks(); |
@@ -166,13 +177,14 @@ TEST_F(DelayedUniqueNotifierTest, RescheduleDelay) { |
notifier.SetNow(schedule_time); |
notifier.Schedule(); |
- std::deque<base::TestPendingTask> tasks = TakePendingTasks(); |
- |
+ base::TestPendingTaskQueue tasks = TakePendingTasks(); |
ASSERT_EQ(1u, tasks.size()); |
- EXPECT_EQ(base::TimeTicks() + delay, tasks[0].GetTimeToRun()); |
+ base::TestPendingTaskInfo task_info = tasks[0].first; |
+ base::OnceClosure task = std::move(tasks[0].second); |
+ EXPECT_EQ(base::TimeTicks() + delay, task_info.GetTimeToRun()); |
// It's not yet time to run, so we expect no notifications. |
- tasks[0].task.Run(); |
+ std::move(task).Run(); |
EXPECT_EQ(0, NotificationCount()); |
} |
@@ -180,13 +192,14 @@ TEST_F(DelayedUniqueNotifierTest, RescheduleDelay) { |
schedule_time = notifier.Now() + base::TimeDelta::FromInternalValue(20); |
notifier.SetNow(schedule_time); |
- std::deque<base::TestPendingTask> tasks = TakePendingTasks(); |
- |
+ base::TestPendingTaskQueue tasks = TakePendingTasks(); |
ASSERT_EQ(1u, tasks.size()); |
- EXPECT_EQ(base::TimeTicks() + delay, tasks[0].GetTimeToRun()); |
+ base::TestPendingTaskInfo task_info = tasks[0].first; |
+ base::OnceClosure task = std::move(tasks[0].second); |
+ EXPECT_EQ(base::TimeTicks() + delay, task_info.GetTimeToRun()); |
// Time to run! |
- tasks[0].task.Run(); |
+ std::move(task).Run(); |
EXPECT_EQ(1, NotificationCount()); |
} |
@@ -210,13 +223,14 @@ TEST_F(DelayedUniqueNotifierTest, CancelAndHasPendingNotification) { |
notifier.Cancel(); |
EXPECT_FALSE(notifier.HasPendingNotification()); |
- std::deque<base::TestPendingTask> tasks = TakePendingTasks(); |
- |
+ base::TestPendingTaskQueue tasks = TakePendingTasks(); |
ASSERT_EQ(1u, tasks.size()); |
- EXPECT_EQ(base::TimeTicks() + delay, tasks[0].GetTimeToRun()); |
+ base::TestPendingTaskInfo task_info = tasks[0].first; |
+ base::OnceClosure task = std::move(tasks[0].second); |
+ EXPECT_EQ(base::TimeTicks() + delay, task_info.GetTimeToRun()); |
// Time to run, but a canceled task! |
- tasks[0].task.Run(); |
+ std::move(task).Run(); |
EXPECT_EQ(0, NotificationCount()); |
EXPECT_FALSE(notifier.HasPendingNotification()); |
@@ -228,13 +242,15 @@ TEST_F(DelayedUniqueNotifierTest, CancelAndHasPendingNotification) { |
tasks = TakePendingTasks(); |
ASSERT_EQ(1u, tasks.size()); |
- EXPECT_EQ(base::TimeTicks() + delay, tasks[0].GetTimeToRun()); |
+ task_info = tasks[0].first; |
+ task = std::move(tasks[0].second); |
+ EXPECT_EQ(base::TimeTicks() + delay, task_info.GetTimeToRun()); |
// Advance the time. |
notifier.SetNow(notifier.Now() + delay); |
// This should run since it wasn't canceled. |
- tasks[0].task.Run(); |
+ std::move(task).Run(); |
EXPECT_EQ(1, NotificationCount()); |
EXPECT_FALSE(notifier.HasPendingNotification()); |
@@ -246,13 +262,14 @@ TEST_F(DelayedUniqueNotifierTest, CancelAndHasPendingNotification) { |
} |
tasks = TakePendingTasks(); |
- |
ASSERT_EQ(1u, tasks.size()); |
- EXPECT_EQ(base::TimeTicks() + delay, tasks[0].GetTimeToRun()); |
+ task_info = tasks[0].first; |
+ task = std::move(tasks[0].second); |
+ EXPECT_EQ(base::TimeTicks() + delay, task_info.GetTimeToRun()); |
// Time to run, but a canceled task! |
notifier.SetNow(notifier.Now() + delay); |
- tasks[0].task.Run(); |
+ std::move(task).Run(); |
EXPECT_EQ(1, NotificationCount()); |
tasks = TakePendingTasks(); |
@@ -280,11 +297,11 @@ TEST_F(DelayedUniqueNotifierTest, ShutdownWithScheduledTask) { |
notifier.Shutdown(); |
// The task is still there, but... |
- std::deque<base::TestPendingTask> tasks = TakePendingTasks(); |
+ base::TestPendingTaskQueue tasks = TakePendingTasks(); |
ASSERT_EQ(1u, tasks.size()); |
// Running the task after shutdown does nothing since it's cancelled. |
- tasks[0].task.Run(); |
+ std::move(tasks[0].second).Run(); |
EXPECT_EQ(0, NotificationCount()); |
tasks = TakePendingTasks(); |
@@ -320,7 +337,7 @@ TEST_F(DelayedUniqueNotifierTest, ShutdownPreventsSchedule) { |
// Scheduling a task no longer does anything. |
notifier.Schedule(); |
- std::deque<base::TestPendingTask> tasks = TakePendingTasks(); |
+ base::TestPendingTaskQueue tasks = TakePendingTasks(); |
ASSERT_EQ(0u, tasks.size()); |
// Verify after the scheduled time happens there is still no task. |