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

Unified Diff: sync/engine/sync_scheduler_unittest.cc

Issue 13422003: sync: Refactor job ownership in SyncScheduler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update comment Created 7 years, 8 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 | « sync/engine/sync_scheduler_impl.cc ('k') | sync/engine/sync_scheduler_whitebox_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/engine/sync_scheduler_unittest.cc
diff --git a/sync/engine/sync_scheduler_unittest.cc b/sync/engine/sync_scheduler_unittest.cc
index 406be4eb7f7f55675edeb497eb29bb1cb1019f7c..444f5eb27eea5ff671f2676bd0377d862ebb6fd7 100644
--- a/sync/engine/sync_scheduler_unittest.cc
+++ b/sync/engine/sync_scheduler_unittest.cc
@@ -72,6 +72,14 @@ void PumpLoop() {
RunLoop();
}
+void PumpLoopFor(base::TimeDelta time) {
+ // Allow the loop to run for the specified amount of time.
+ MessageLoop::current()->PostDelayedTask(FROM_HERE,
+ base::Bind(&QuitLoopNow),
+ time);
+ RunLoop();
+}
+
ModelSafeRoutingInfo TypesToRoutingInfo(ModelTypeSet types) {
ModelSafeRoutingInfo routes;
for (ModelTypeSet::Iterator iter = types.First(); iter.Good(); iter.Inc()) {
@@ -975,21 +983,20 @@ TEST_F(SyncSchedulerTest, BackoffDropsJobs) {
EXPECT_EQ(GetUpdatesCallerInfo::LOCAL,
r.snapshots[0].source().updates_source);
- EXPECT_CALL(*syncer(), SyncShare(_,_,_)).Times(1)
- .WillOnce(DoAll(Invoke(sessions::test_util::SimulateCommitFailed),
- RecordSyncShare(&r)));
+ // Wait a while (10x poll interval) so a few poll jobs will be attempted.
+ PumpLoopFor(poll * 10);
- // We schedule a nudge with enough delay (10X poll interval) that at least
- // one or two polls would have taken place. The nudge should succeed.
+ // Try (and fail) to schedule a nudge.
scheduler()->ScheduleNudgeAsync(
- poll * 10, NUDGE_SOURCE_LOCAL, types, FROM_HERE);
- RunLoop();
+ base::TimeDelta::FromMilliseconds(1),
+ NUDGE_SOURCE_LOCAL,
+ types,
+ FROM_HERE);
Mock::VerifyAndClearExpectations(syncer());
Mock::VerifyAndClearExpectations(delay());
- ASSERT_EQ(2U, r.snapshots.size());
- EXPECT_EQ(GetUpdatesCallerInfo::LOCAL,
- r.snapshots[1].source().updates_source);
+
+ ASSERT_EQ(1U, r.snapshots.size());
EXPECT_CALL(*delay(), GetDelay(_)).Times(0);
« no previous file with comments | « sync/engine/sync_scheduler_impl.cc ('k') | sync/engine/sync_scheduler_whitebox_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698