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

Unified Diff: google_apis/gcm/engine/heartbeat_manager_unittest.cc

Issue 745123002: Link GCM heartbeat with wake on wifi preference (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up includes Created 6 years 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: google_apis/gcm/engine/heartbeat_manager_unittest.cc
diff --git a/google_apis/gcm/engine/heartbeat_manager_unittest.cc b/google_apis/gcm/engine/heartbeat_manager_unittest.cc
index e09707b2a21e9ffcc655257959622cebf4595b19..6efe2fe52eedb1e76c4c50079d97d0a718edd348 100644
--- a/google_apis/gcm/engine/heartbeat_manager_unittest.cc
+++ b/google_apis/gcm/engine/heartbeat_manager_unittest.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
@@ -175,6 +176,25 @@ TEST_F(HeartbeatManagerTest, StartThenUpdateInterval) {
EXPECT_NE(heartbeat, manager()->GetNextHeartbeatTime());
}
+// Updating the timer used for heartbeats before starting should not start the
+// timer.
+TEST_F(HeartbeatManagerTest, UpdateTimerBeforeStart) {
+ manager()->UpdateHeartbeatTimer(
+ make_scoped_ptr(new base::Timer(true, false)));
+ EXPECT_TRUE(manager()->GetNextHeartbeatTime().is_null());
+}
+
+// Updating the timer used for heartbeats after starting should restart the
+// timer but not change the heartbeat time.
+TEST_F(HeartbeatManagerTest, UpdateTimerAfterStart) {
+ StartManager();
+ base::TimeTicks heartbeat = manager()->GetNextHeartbeatTime();
+
+ manager()->UpdateHeartbeatTimer(
+ make_scoped_ptr(new base::Timer(true, false)));
+ EXPECT_EQ(heartbeat, manager()->GetNextHeartbeatTime());
+}
+
// Stopping the manager should reset the heartbeat timer.
TEST_F(HeartbeatManagerTest, Stop) {
StartManager();

Powered by Google App Engine
This is Rietveld 408576698