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

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: Make GCM wake from suspend aware 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..5d6838f8375c132c646c08ce85d0737bbbba038a 100644
--- a/google_apis/gcm/engine/heartbeat_manager_unittest.cc
+++ b/google_apis/gcm/engine/heartbeat_manager_unittest.cc
@@ -6,7 +6,9 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
+#include "base/threading/platform_thread.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "google_apis/gcm/protocol/mcs.pb.h"
@@ -175,6 +177,27 @@ 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 and update the heartbeat time.
+TEST_F(HeartbeatManagerTest, UpdateTimerAfterStart) {
+ StartManager();
+ base::TimeTicks heartbeat = manager()->GetNextHeartbeatTime();
+
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(2));
Nicolas Zea 2014/12/05 00:53:05 why is this necessary?
Chirantan Ekbote 2014/12/05 21:49:05 Because otherwise the test would be too fast to re
+
+ manager()->UpdateHeartbeatTimer(
+ make_scoped_ptr(new base::Timer(true, false)));
+ EXPECT_NE(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