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

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

Issue 1758573004: [GCM] Fixing the client interval interaction with heartbeat ack (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing final feedback Created 4 years, 10 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 | « google_apis/gcm/engine/heartbeat_manager.cc ('k') | no next file » | 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 b7ee684734f557c40d6371569df61c17f1c2df1f..7efd2f757fd054ad735a109df5a0d1651935bddc 100644
--- a/google_apis/gcm/engine/heartbeat_manager_unittest.cc
+++ b/google_apis/gcm/engine/heartbeat_manager_unittest.cc
@@ -287,6 +287,29 @@ TEST_F(HeartbeatManagerTest, ClientIntervalInvalid) {
manager()->GetMaxClientHeartbeatIntervalMs()));
}
+// Verifies that client interval is reset appropriately after the heartbeat is
+// triggered. See http://crbug.com/591490 for details.
+TEST_F(HeartbeatManagerTest, ClientIntervalAfterHeartbeatTriggered) {
+ const int kCustomIntervalMs = 180 * 1000; // 180 seconds.
+ manager()->SetClientHeartbeatIntervalMs(kCustomIntervalMs);
+ StartManager();
+
+ // This changes the interval as manager awaits a heartbeat ack.
+ manager()->TriggerHearbeat();
+ const int kDefaultAckIntervalMs = 60 * 1000; // 60 seconds.
+ base::TimeTicks heartbeat = manager()->GetNextHeartbeatTime();
+ EXPECT_LE(heartbeat - base::TimeTicks::Now(),
+ base::TimeDelta::FromMilliseconds(kDefaultAckIntervalMs));
+
+ // This should reset the interval to the custom interval.
+ manager()->OnHeartbeatAcked();
+ heartbeat = manager()->GetNextHeartbeatTime();
+ EXPECT_GT(heartbeat - base::TimeTicks::Now(),
+ base::TimeDelta::FromMilliseconds(kDefaultAckIntervalMs));
+ EXPECT_LE(heartbeat - base::TimeTicks::Now(),
+ base::TimeDelta::FromMilliseconds(kCustomIntervalMs));
+}
+
} // namespace
} // namespace gcm
« no previous file with comments | « google_apis/gcm/engine/heartbeat_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698