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

Side by Side 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, 9 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 unified diff | Download patch
« no previous file with comments | « google_apis/gcm/engine/heartbeat_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "google_apis/gcm/engine/heartbeat_manager.h" 5 #include "google_apis/gcm/engine/heartbeat_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/test/test_simple_task_runner.h" 10 #include "base/test/test_simple_task_runner.h"
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 // Triggering and acking the heartbeat should result in a heartbeat being 280 // Triggering and acking the heartbeat should result in a heartbeat being
281 // posted with the new interval. 281 // posted with the new interval.
282 manager()->TriggerHearbeat(); 282 manager()->TriggerHearbeat();
283 manager()->OnHeartbeatAcked(); 283 manager()->OnHeartbeatAcked();
284 284
285 till_heartbeat = manager()->GetNextHeartbeatTime() - base::TimeTicks::Now(); 285 till_heartbeat = manager()->GetNextHeartbeatTime() - base::TimeTicks::Now();
286 EXPECT_LE(till_heartbeat, base::TimeDelta::FromMilliseconds( 286 EXPECT_LE(till_heartbeat, base::TimeDelta::FromMilliseconds(
287 manager()->GetMaxClientHeartbeatIntervalMs())); 287 manager()->GetMaxClientHeartbeatIntervalMs()));
288 } 288 }
289 289
290 // Verifies that client interval is reset appropriately after the heartbeat is
291 // triggered. See http://crbug.com/591490 for details.
292 TEST_F(HeartbeatManagerTest, ClientIntervalAfterHeartbeatTriggered) {
293 const int kCustomIntervalMs = 180 * 1000; // 180 seconds.
294 manager()->SetClientHeartbeatIntervalMs(kCustomIntervalMs);
295 StartManager();
296
297 // This changes the interval as manager awaits a heartbeat ack.
298 manager()->TriggerHearbeat();
299 const int kDefaultAckIntervalMs = 60 * 1000; // 60 seconds.
300 base::TimeTicks heartbeat = manager()->GetNextHeartbeatTime();
301 EXPECT_LE(heartbeat - base::TimeTicks::Now(),
302 base::TimeDelta::FromMilliseconds(kDefaultAckIntervalMs));
303
304 // This should reset the interval to the custom interval.
305 manager()->OnHeartbeatAcked();
306 heartbeat = manager()->GetNextHeartbeatTime();
307 EXPECT_GT(heartbeat - base::TimeTicks::Now(),
308 base::TimeDelta::FromMilliseconds(kDefaultAckIntervalMs));
309 EXPECT_LE(heartbeat - base::TimeTicks::Now(),
310 base::TimeDelta::FromMilliseconds(kCustomIntervalMs));
311 }
312
290 } // namespace 313 } // namespace
291 314
292 } // namespace gcm 315 } // namespace gcm
OLDNEW
« 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