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

Unified Diff: chrome/browser/sync/engine/sync_scheduler_unittest.cc

Issue 8787006: Delay autofill commits to reduce client to server traffic. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: For review. Created 9 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: chrome/browser/sync/engine/sync_scheduler_unittest.cc
diff --git a/chrome/browser/sync/engine/sync_scheduler_unittest.cc b/chrome/browser/sync/engine/sync_scheduler_unittest.cc
index b44a88c037838c32eeed855521c44e49d970d923..0bc81f4fced69a347179993e1516e5cdec21777f 100644
--- a/chrome/browser/sync/engine/sync_scheduler_unittest.cc
+++ b/chrome/browser/sync/engine/sync_scheduler_unittest.cc
@@ -476,6 +476,42 @@ TEST_F(SyncSchedulerTest, NudgeCoalescing) {
r2.snapshots[0]->source.updates_source);
}
+// Test that nudges are coalesced.
+TEST_F(SyncSchedulerTest, NudgeCoalescingWithDifferentTimings) {
+ StartSyncScheduler(SyncScheduler::NORMAL_MODE);
+ RunLoop();
+
+ SyncShareRecords r;
+ EXPECT_CALL(*syncer(), SyncShare(_,_,_))
+ .WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess),
+ WithArg<0>(RecordSyncShare(&r))));
+ syncable::ModelTypeSet types1(syncable::BOOKMARKS),
+ types2(syncable::AUTOFILL), types3;
+
+ // Create a huge time delay.
+ TimeDelta delay = TimeDelta::FromDays(1);
+
+ scheduler()->ScheduleNudge(
+ delay, NUDGE_SOURCE_UNKNOWN, types1, FROM_HERE);
+
+ scheduler()->ScheduleNudge(
+ zero(), NUDGE_SOURCE_UNKNOWN, types2, FROM_HERE);
+
+ TimeTicks min_time = TimeTicks::Now();
+ TimeTicks max_time = TimeTicks::Now() + delay;
+
+ RunLoop();
+
+ // Make sure the sync has happened.
+ ASSERT_EQ(1U, r.snapshots.size());
+ EXPECT_TRUE(CompareModelTypeSetToModelTypePayloadMap(
+ Union(types1, types2), r.snapshots[0]->source.types));
+
+ // Make sure the sync happened at the right time.
+ EXPECT_GE(r.times[0], min_time);
+ EXPECT_LE(r.times[0], max_time);
+}
+
// Test nudge scheduling.
TEST_F(SyncSchedulerTest, NudgeWithPayloads) {
StartSyncScheduler(SyncScheduler::NORMAL_MODE);

Powered by Google App Engine
This is Rietveld 408576698