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

Side by Side 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 commit. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 zero(), NUDGE_SOURCE_NOTIFICATION, types3, FROM_HERE); 469 zero(), NUDGE_SOURCE_NOTIFICATION, types3, FROM_HERE);
470 RunLoop(); 470 RunLoop();
471 471
472 ASSERT_EQ(1U, r2.snapshots.size()); 472 ASSERT_EQ(1U, r2.snapshots.size());
473 EXPECT_TRUE(CompareModelTypeSetToModelTypePayloadMap(types3, 473 EXPECT_TRUE(CompareModelTypeSetToModelTypePayloadMap(types3,
474 r2.snapshots[0]->source.types)); 474 r2.snapshots[0]->source.types));
475 EXPECT_EQ(GetUpdatesCallerInfo::NOTIFICATION, 475 EXPECT_EQ(GetUpdatesCallerInfo::NOTIFICATION,
476 r2.snapshots[0]->source.updates_source); 476 r2.snapshots[0]->source.updates_source);
477 } 477 }
478 478
479 // Test that nudges are coalesced.
480 TEST_F(SyncSchedulerTest, NudgeCoalescingWithDifferentTimings) {
481 StartSyncScheduler(SyncScheduler::NORMAL_MODE);
482 RunLoop();
483
484 SyncShareRecords r;
485 EXPECT_CALL(*syncer(), SyncShare(_,_,_))
486 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess),
487 WithArg<0>(RecordSyncShare(&r))));
488 syncable::ModelTypeSet types1(syncable::BOOKMARKS),
489 types2(syncable::AUTOFILL), types3;
490
491 // Create a huge time delay.
492 TimeDelta delay = TimeDelta::FromDays(1);
493
494 scheduler()->ScheduleNudge(
495 delay, NUDGE_SOURCE_UNKNOWN, types1, FROM_HERE);
496
497 scheduler()->ScheduleNudge(
498 zero(), NUDGE_SOURCE_UNKNOWN, types2, FROM_HERE);
499
500 TimeTicks min_time = TimeTicks::Now();
501 TimeTicks max_time = TimeTicks::Now() + delay;
502
503 RunLoop();
504
505 // Make sure the sync has happened.
506 ASSERT_EQ(1U, r.snapshots.size());
507 EXPECT_TRUE(CompareModelTypeSetToModelTypePayloadMap(
508 Union(types1, types2), r.snapshots[0]->source.types));
509
510 // Make sure the sync happened at the right time.
511 EXPECT_GE(r.times[0], min_time);
512 EXPECT_LE(r.times[0], max_time);
513 }
514
479 // Test nudge scheduling. 515 // Test nudge scheduling.
480 TEST_F(SyncSchedulerTest, NudgeWithPayloads) { 516 TEST_F(SyncSchedulerTest, NudgeWithPayloads) {
481 StartSyncScheduler(SyncScheduler::NORMAL_MODE); 517 StartSyncScheduler(SyncScheduler::NORMAL_MODE);
482 RunLoop(); 518 RunLoop();
483 519
484 SyncShareRecords records; 520 SyncShareRecords records;
485 syncable::ModelTypePayloadMap model_types_with_payloads; 521 syncable::ModelTypePayloadMap model_types_with_payloads;
486 model_types_with_payloads[syncable::BOOKMARKS] = "test"; 522 model_types_with_payloads[syncable::BOOKMARKS] = "test";
487 523
488 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) 524 EXPECT_CALL(*syncer(), SyncShare(_,_,_))
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 PumpLoop(); 1104 PumpLoop();
1069 // Pump again to run job. 1105 // Pump again to run job.
1070 PumpLoop(); 1106 PumpLoop();
1071 1107
1072 StopSyncScheduler(); 1108 StopSyncScheduler();
1073 1109
1074 EXPECT_TRUE(expected == context()->previous_session_routing_info()); 1110 EXPECT_TRUE(expected == context()->previous_session_routing_info());
1075 } 1111 }
1076 1112
1077 } // namespace browser_sync 1113 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/sync_scheduler.cc ('k') | chrome/browser/sync/internal_api/sync_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698