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

Unified Diff: cc/base/delayed_unique_notifier_unittest.cc

Issue 302003004: cc: Add HasPendingNotification to delayed unique notifier. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | « cc/base/delayed_unique_notifier.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 113146a082cbb58a4da62902d13382428a87f2da..a2dd273b9109c3aa3a822795acce54452331b5e9 100644
--- a/cc/base/delayed_unique_notifier_unittest.cc
+++ b/cc/base/delayed_unique_notifier_unittest.cc
@@ -192,7 +192,7 @@ TEST_F(DelayedUniqueNotifierTest, RescheduleDelay) {
EXPECT_EQ(1, NotificationCount());
}
-TEST_F(DelayedUniqueNotifierTest, Cancel) {
+TEST_F(DelayedUniqueNotifierTest, CancelAndHasPendingNotification) {
base::TimeDelta delay = base::TimeDelta::FromInternalValue(20);
TestNotifier notifier(
task_runner_,
@@ -206,9 +206,11 @@ TEST_F(DelayedUniqueNotifierTest, Cancel) {
notifier.Now() + base::TimeDelta::FromInternalValue(10);
notifier.SetNow(schedule_time);
notifier.Schedule();
+ EXPECT_TRUE(notifier.HasPendingNotification());
// Cancel the run.
notifier.Cancel();
+ EXPECT_FALSE(notifier.HasPendingNotification());
std::deque<base::TestPendingTask> tasks = TakePendingTasks();
@@ -218,11 +220,13 @@ TEST_F(DelayedUniqueNotifierTest, Cancel) {
// Time to run, but a canceled task!
tasks[0].task.Run();
EXPECT_EQ(0, NotificationCount());
+ EXPECT_FALSE(notifier.HasPendingNotification());
tasks = TakePendingTasks();
EXPECT_EQ(0u, tasks.size());
notifier.Schedule();
+ EXPECT_TRUE(notifier.HasPendingNotification());
tasks = TakePendingTasks();
ASSERT_EQ(1u, tasks.size());
@@ -234,11 +238,14 @@ TEST_F(DelayedUniqueNotifierTest, Cancel) {
// This should run since it wasn't scheduled.
tasks[0].task.Run();
EXPECT_EQ(1, NotificationCount());
+ EXPECT_FALSE(notifier.HasPendingNotification());
for (int i = 0; i < 10; ++i)
notifier.Schedule();
+ EXPECT_TRUE(notifier.HasPendingNotification());
notifier.Cancel();
reveman 2014/05/30 00:19:28 While here, can you move this Cancel() call to the
vmpstr 2014/05/30 00:38:34 Done.
+ EXPECT_FALSE(notifier.HasPendingNotification());
tasks = TakePendingTasks();
ASSERT_EQ(1u, tasks.size());
@@ -251,6 +258,7 @@ TEST_F(DelayedUniqueNotifierTest, Cancel) {
tasks = TakePendingTasks();
EXPECT_EQ(0u, tasks.size());
+ EXPECT_FALSE(notifier.HasPendingNotification());
}
} // namespace
« no previous file with comments | « cc/base/delayed_unique_notifier.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698