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

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: Fix missing include 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
« no previous file with comments | « google_apis/gcm/engine/heartbeat_manager.cc ('k') | google_apis/gcm/engine/mcs_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9e8bc6db2ad518f32f5a21371797f89cd58de7b7 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"
@@ -24,10 +25,7 @@ mcs_proto::HeartbeatConfig BuildHeartbeatConfig(int interval_ms) {
class TestHeartbeatManager : public HeartbeatManager {
public:
- TestHeartbeatManager()
- : HeartbeatManager(make_scoped_ptr(
- new base::Timer(true, /* retain user task */
- false /* non repeating */))) {}
+ TestHeartbeatManager() {}
virtual ~TestHeartbeatManager() {}
// Bypass the heartbeat timer, and send the heartbeat now.
@@ -175,6 +173,26 @@ 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 increase the heartbeat time by more than a millisecond.
+TEST_F(HeartbeatManagerTest, UpdateTimerAfterStart) {
+ StartManager();
+ base::TimeTicks heartbeat = manager()->GetNextHeartbeatTime();
+
+ manager()->UpdateHeartbeatTimer(
+ make_scoped_ptr(new base::Timer(true, false)));
+ EXPECT_LT(manager()->GetNextHeartbeatTime() - heartbeat,
+ base::TimeDelta::FromMilliseconds(1));
+}
+
// Stopping the manager should reset the heartbeat timer.
TEST_F(HeartbeatManagerTest, Stop) {
StartManager();
« no previous file with comments | « google_apis/gcm/engine/heartbeat_manager.cc ('k') | google_apis/gcm/engine/mcs_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698