| OLD | NEW |
| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 } | 143 } |
| 144 | 144 |
| 145 // This stops the scheduler synchronously. | 145 // This stops the scheduler synchronously. |
| 146 void StopSyncScheduler() { | 146 void StopSyncScheduler() { |
| 147 scheduler()->RequestStop(base::Bind(&SyncSchedulerTest::DoQuitLoopNow, | 147 scheduler()->RequestStop(base::Bind(&SyncSchedulerTest::DoQuitLoopNow, |
| 148 weak_ptr_factory_.GetWeakPtr())); | 148 weak_ptr_factory_.GetWeakPtr())); |
| 149 RunLoop(); | 149 RunLoop(); |
| 150 } | 150 } |
| 151 | 151 |
| 152 bool GetBackoffAndResetTest() { | 152 bool GetBackoffAndResetTest() { |
| 153 syncable::ModelTypeBitSet nudge_types; | 153 syncable::ModelEnumSet nudge_types; |
| 154 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | 154 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
| 155 RunLoop(); | 155 RunLoop(); |
| 156 | 156 |
| 157 scheduler()->ScheduleNudge( | 157 scheduler()->ScheduleNudge( |
| 158 zero(), NUDGE_SOURCE_LOCAL, nudge_types, FROM_HERE); | 158 zero(), NUDGE_SOURCE_LOCAL, nudge_types, FROM_HERE); |
| 159 RunLoop(); | 159 RunLoop(); |
| 160 | 160 |
| 161 bool backing_off = scheduler()->IsBackingOff(); | 161 bool backing_off = scheduler()->IsBackingOff(); |
| 162 StopSyncScheduler(); | 162 StopSyncScheduler(); |
| 163 | 163 |
| 164 syncdb_.TearDown(); | 164 syncdb_.TearDown(); |
| 165 | 165 |
| 166 Mock::VerifyAndClearExpectations(syncer()); | 166 Mock::VerifyAndClearExpectations(syncer()); |
| 167 | 167 |
| 168 TearDown(); | 168 TearDown(); |
| 169 SetUp(); | 169 SetUp(); |
| 170 UseMockDelayProvider(); | 170 UseMockDelayProvider(); |
| 171 EXPECT_CALL(*delay(), GetDelay(_)) | 171 EXPECT_CALL(*delay(), GetDelay(_)) |
| 172 .WillRepeatedly(Return(TimeDelta::FromMilliseconds(1))); | 172 .WillRepeatedly(Return(TimeDelta::FromMilliseconds(1))); |
| 173 return backing_off; | 173 return backing_off; |
| 174 } | 174 } |
| 175 | 175 |
| 176 void UseMockDelayProvider() { | 176 void UseMockDelayProvider() { |
| 177 delay_ = new MockDelayProvider(); | 177 delay_ = new MockDelayProvider(); |
| 178 scheduler_->delay_provider_.reset(delay_); | 178 scheduler_->delay_provider_.reset(delay_); |
| 179 } | 179 } |
| 180 | 180 |
| 181 // Compare a ModelTypeBitSet to a ModelTypePayloadMap, ignoring | 181 // Compare a ModelEnumSet to a ModelTypePayloadMap, ignoring |
| 182 // payload values. | 182 // payload values. |
| 183 bool CompareModelTypeBitSetToModelTypePayloadMap( | 183 bool CompareModelEnumSetToModelTypePayloadMap( |
| 184 const syncable::ModelTypeBitSet& lhs, | 184 syncable::ModelEnumSet lhs, |
| 185 const syncable::ModelTypePayloadMap& rhs) { | 185 const syncable::ModelTypePayloadMap& rhs) { |
| 186 size_t count = 0; | 186 size_t count = 0; |
| 187 for (syncable::ModelTypePayloadMap::const_iterator i = rhs.begin(); | 187 for (syncable::ModelTypePayloadMap::const_iterator i = rhs.begin(); |
| 188 i != rhs.end(); ++i, ++count) { | 188 i != rhs.end(); ++i, ++count) { |
| 189 if (!lhs.test(i->first)) | 189 if (!lhs.Has(i->first)) |
| 190 return false; | 190 return false; |
| 191 } | 191 } |
| 192 if (lhs.count() != count) | 192 if (lhs.Size() != count) |
| 193 return false; | 193 return false; |
| 194 return true; | 194 return true; |
| 195 } | 195 } |
| 196 | 196 |
| 197 SyncSessionContext* context() { return context_; } | 197 SyncSessionContext* context() { return context_; } |
| 198 | 198 |
| 199 private: | 199 private: |
| 200 base::WeakPtrFactory<SyncSchedulerTest> weak_ptr_factory_; | 200 base::WeakPtrFactory<SyncSchedulerTest> weak_ptr_factory_; |
| 201 MessageLoop message_loop_; | 201 MessageLoop message_loop_; |
| 202 scoped_ptr<SyncScheduler> scheduler_; | 202 scoped_ptr<SyncScheduler> scheduler_; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 232 QuitLoopNow(); | 232 QuitLoopNow(); |
| 233 } | 233 } |
| 234 | 234 |
| 235 ACTION(QuitLoopNowAction) { | 235 ACTION(QuitLoopNowAction) { |
| 236 QuitLoopNow(); | 236 QuitLoopNow(); |
| 237 } | 237 } |
| 238 | 238 |
| 239 // Test nudge scheduling. | 239 // Test nudge scheduling. |
| 240 TEST_F(SyncSchedulerTest, Nudge) { | 240 TEST_F(SyncSchedulerTest, Nudge) { |
| 241 SyncShareRecords records; | 241 SyncShareRecords records; |
| 242 syncable::ModelTypeBitSet model_types; | 242 syncable::ModelEnumSet model_types(syncable::BOOKMARKS); |
| 243 model_types[syncable::BOOKMARKS] = true; | |
| 244 | 243 |
| 245 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) | 244 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) |
| 246 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess), | 245 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess), |
| 247 WithArg<0>(RecordSyncShare(&records)))) | 246 WithArg<0>(RecordSyncShare(&records)))) |
| 248 .RetiresOnSaturation(); | 247 .RetiresOnSaturation(); |
| 249 | 248 |
| 250 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | 249 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
| 251 RunLoop(); | 250 RunLoop(); |
| 252 | 251 |
| 253 scheduler()->ScheduleNudge( | 252 scheduler()->ScheduleNudge( |
| 254 zero(), NUDGE_SOURCE_LOCAL, model_types, FROM_HERE); | 253 zero(), NUDGE_SOURCE_LOCAL, model_types, FROM_HERE); |
| 255 RunLoop(); | 254 RunLoop(); |
| 256 | 255 |
| 257 ASSERT_EQ(1U, records.snapshots.size()); | 256 ASSERT_EQ(1U, records.snapshots.size()); |
| 258 EXPECT_TRUE(CompareModelTypeBitSetToModelTypePayloadMap(model_types, | 257 EXPECT_TRUE(CompareModelEnumSetToModelTypePayloadMap(model_types, |
| 259 records.snapshots[0]->source.types)); | 258 records.snapshots[0]->source.types)); |
| 260 EXPECT_EQ(GetUpdatesCallerInfo::LOCAL, | 259 EXPECT_EQ(GetUpdatesCallerInfo::LOCAL, |
| 261 records.snapshots[0]->source.updates_source); | 260 records.snapshots[0]->source.updates_source); |
| 262 | 261 |
| 263 Mock::VerifyAndClearExpectations(syncer()); | 262 Mock::VerifyAndClearExpectations(syncer()); |
| 264 | 263 |
| 265 // Make sure a second, later, nudge is unaffected by first (no coalescing). | 264 // Make sure a second, later, nudge is unaffected by first (no coalescing). |
| 266 SyncShareRecords records2; | 265 SyncShareRecords records2; |
| 267 model_types[syncable::BOOKMARKS] = false; | 266 model_types.Remove(syncable::BOOKMARKS); |
| 268 model_types[syncable::AUTOFILL] = true; | 267 model_types.Put(syncable::AUTOFILL); |
| 269 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) | 268 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) |
| 270 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess), | 269 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess), |
| 271 WithArg<0>(RecordSyncShare(&records2)))); | 270 WithArg<0>(RecordSyncShare(&records2)))); |
| 272 scheduler()->ScheduleNudge( | 271 scheduler()->ScheduleNudge( |
| 273 zero(), NUDGE_SOURCE_LOCAL, model_types, FROM_HERE); | 272 zero(), NUDGE_SOURCE_LOCAL, model_types, FROM_HERE); |
| 274 RunLoop(); | 273 RunLoop(); |
| 275 | 274 |
| 276 ASSERT_EQ(1U, records2.snapshots.size()); | 275 ASSERT_EQ(1U, records2.snapshots.size()); |
| 277 EXPECT_TRUE(CompareModelTypeBitSetToModelTypePayloadMap(model_types, | 276 EXPECT_TRUE(CompareModelEnumSetToModelTypePayloadMap(model_types, |
| 278 records2.snapshots[0]->source.types)); | 277 records2.snapshots[0]->source.types)); |
| 279 EXPECT_EQ(GetUpdatesCallerInfo::LOCAL, | 278 EXPECT_EQ(GetUpdatesCallerInfo::LOCAL, |
| 280 records2.snapshots[0]->source.updates_source); | 279 records2.snapshots[0]->source.updates_source); |
| 281 } | 280 } |
| 282 | 281 |
| 283 // Make sure a regular config command is scheduled fine in the absence of any | 282 // Make sure a regular config command is scheduled fine in the absence of any |
| 284 // errors. | 283 // errors. |
| 285 TEST_F(SyncSchedulerTest, Config) { | 284 TEST_F(SyncSchedulerTest, Config) { |
| 286 SyncShareRecords records; | 285 SyncShareRecords records; |
| 287 syncable::ModelTypeBitSet model_types; | 286 const syncable::ModelEnumSet model_types(syncable::BOOKMARKS); |
| 288 model_types[syncable::BOOKMARKS] = true; | |
| 289 | 287 |
| 290 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) | 288 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) |
| 291 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess), | 289 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess), |
| 292 WithArg<0>(RecordSyncShare(&records)))); | 290 WithArg<0>(RecordSyncShare(&records)))); |
| 293 | 291 |
| 294 StartSyncScheduler(SyncScheduler::CONFIGURATION_MODE); | 292 StartSyncScheduler(SyncScheduler::CONFIGURATION_MODE); |
| 295 RunLoop(); | 293 RunLoop(); |
| 296 | 294 |
| 297 scheduler()->ScheduleConfig( | 295 scheduler()->ScheduleConfig( |
| 298 model_types, GetUpdatesCallerInfo::RECONFIGURATION); | 296 model_types, GetUpdatesCallerInfo::RECONFIGURATION); |
| 299 RunLoop(); | 297 RunLoop(); |
| 300 | 298 |
| 301 ASSERT_EQ(1U, records.snapshots.size()); | 299 ASSERT_EQ(1U, records.snapshots.size()); |
| 302 EXPECT_TRUE(CompareModelTypeBitSetToModelTypePayloadMap(model_types, | 300 EXPECT_TRUE(CompareModelEnumSetToModelTypePayloadMap(model_types, |
| 303 records.snapshots[0]->source.types)); | 301 records.snapshots[0]->source.types)); |
| 304 EXPECT_EQ(GetUpdatesCallerInfo::RECONFIGURATION, | 302 EXPECT_EQ(GetUpdatesCallerInfo::RECONFIGURATION, |
| 305 records.snapshots[0]->source.updates_source); | 303 records.snapshots[0]->source.updates_source); |
| 306 } | 304 } |
| 307 | 305 |
| 308 // Simulate a failure and make sure the config request is retried. | 306 // Simulate a failure and make sure the config request is retried. |
| 309 TEST_F(SyncSchedulerTest, ConfigWithBackingOff) { | 307 TEST_F(SyncSchedulerTest, ConfigWithBackingOff) { |
| 310 UseMockDelayProvider(); | 308 UseMockDelayProvider(); |
| 311 EXPECT_CALL(*delay(), GetDelay(_)) | 309 EXPECT_CALL(*delay(), GetDelay(_)) |
| 312 .WillRepeatedly(Return(TimeDelta::FromMilliseconds(1))); | 310 .WillRepeatedly(Return(TimeDelta::FromMilliseconds(1))); |
| 313 SyncShareRecords records; | 311 SyncShareRecords records; |
| 314 syncable::ModelTypeBitSet model_types; | 312 const syncable::ModelEnumSet model_types(syncable::BOOKMARKS); |
| 315 model_types[syncable::BOOKMARKS] = true; | |
| 316 | 313 |
| 317 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) | 314 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) |
| 318 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateCommitFailed), | 315 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateCommitFailed), |
| 319 WithArg<0>(RecordSyncShare(&records)))) | 316 WithArg<0>(RecordSyncShare(&records)))) |
| 320 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess), | 317 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess), |
| 321 WithArg<0>(RecordSyncShare(&records)))); | 318 WithArg<0>(RecordSyncShare(&records)))); |
| 322 | 319 |
| 323 StartSyncScheduler(SyncScheduler::CONFIGURATION_MODE); | 320 StartSyncScheduler(SyncScheduler::CONFIGURATION_MODE); |
| 324 RunLoop(); | 321 RunLoop(); |
| 325 | 322 |
| 326 ASSERT_EQ(0U, records.snapshots.size()); | 323 ASSERT_EQ(0U, records.snapshots.size()); |
| 327 scheduler()->ScheduleConfig( | 324 scheduler()->ScheduleConfig( |
| 328 model_types, GetUpdatesCallerInfo::RECONFIGURATION); | 325 model_types, GetUpdatesCallerInfo::RECONFIGURATION); |
| 329 RunLoop(); | 326 RunLoop(); |
| 330 | 327 |
| 331 ASSERT_EQ(1U, records.snapshots.size()); | 328 ASSERT_EQ(1U, records.snapshots.size()); |
| 332 RunLoop(); | 329 RunLoop(); |
| 333 | 330 |
| 334 ASSERT_EQ(2U, records.snapshots.size()); | 331 ASSERT_EQ(2U, records.snapshots.size()); |
| 335 EXPECT_TRUE(CompareModelTypeBitSetToModelTypePayloadMap(model_types, | 332 EXPECT_TRUE(CompareModelEnumSetToModelTypePayloadMap(model_types, |
| 336 records.snapshots[1]->source.types)); | 333 records.snapshots[1]->source.types)); |
| 337 EXPECT_EQ(GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION, | 334 EXPECT_EQ(GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION, |
| 338 records.snapshots[1]->source.updates_source); | 335 records.snapshots[1]->source.updates_source); |
| 339 } | 336 } |
| 340 | 337 |
| 341 // Issue 2 config commands. Second one right after the first has failed | 338 // Issue 2 config commands. Second one right after the first has failed |
| 342 // and make sure LATEST is executed. | 339 // and make sure LATEST is executed. |
| 343 TEST_F(SyncSchedulerTest, MultipleConfigWithBackingOff) { | 340 TEST_F(SyncSchedulerTest, MultipleConfigWithBackingOff) { |
| 344 syncable::ModelTypeBitSet model_types1, model_types2; | 341 const syncable::ModelEnumSet |
| 345 model_types1[syncable::BOOKMARKS] = true; | 342 model_types1(syncable::BOOKMARKS), |
| 346 model_types2[syncable::AUTOFILL] = true; | 343 model_types2(syncable::AUTOFILL); |
| 347 UseMockDelayProvider(); | 344 UseMockDelayProvider(); |
| 348 EXPECT_CALL(*delay(), GetDelay(_)) | 345 EXPECT_CALL(*delay(), GetDelay(_)) |
| 349 .WillRepeatedly(Return(TimeDelta::FromMilliseconds(30))); | 346 .WillRepeatedly(Return(TimeDelta::FromMilliseconds(30))); |
| 350 SyncShareRecords records; | 347 SyncShareRecords records; |
| 351 | 348 |
| 352 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) | 349 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) |
| 353 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateCommitFailed), | 350 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateCommitFailed), |
| 354 WithArg<0>(RecordSyncShare(&records)))) | 351 WithArg<0>(RecordSyncShare(&records)))) |
| 355 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateCommitFailed), | 352 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateCommitFailed), |
| 356 WithArg<0>(RecordSyncShare(&records)))) | 353 WithArg<0>(RecordSyncShare(&records)))) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 367 | 364 |
| 368 ASSERT_EQ(1U, records.snapshots.size()); | 365 ASSERT_EQ(1U, records.snapshots.size()); |
| 369 scheduler()->ScheduleConfig( | 366 scheduler()->ScheduleConfig( |
| 370 model_types2, GetUpdatesCallerInfo::RECONFIGURATION); | 367 model_types2, GetUpdatesCallerInfo::RECONFIGURATION); |
| 371 RunLoop(); | 368 RunLoop(); |
| 372 | 369 |
| 373 ASSERT_EQ(2U, records.snapshots.size()); | 370 ASSERT_EQ(2U, records.snapshots.size()); |
| 374 RunLoop(); | 371 RunLoop(); |
| 375 | 372 |
| 376 ASSERT_EQ(3U, records.snapshots.size()); | 373 ASSERT_EQ(3U, records.snapshots.size()); |
| 377 EXPECT_TRUE(CompareModelTypeBitSetToModelTypePayloadMap(model_types2, | 374 EXPECT_TRUE(CompareModelEnumSetToModelTypePayloadMap(model_types2, |
| 378 records.snapshots[2]->source.types)); | 375 records.snapshots[2]->source.types)); |
| 379 EXPECT_EQ(GetUpdatesCallerInfo::RECONFIGURATION, | 376 EXPECT_EQ(GetUpdatesCallerInfo::RECONFIGURATION, |
| 380 records.snapshots[2]->source.updates_source); | 377 records.snapshots[2]->source.updates_source); |
| 381 } | 378 } |
| 382 | 379 |
| 383 // Issue a nudge when the config has failed. Make sure both the config and | 380 // Issue a nudge when the config has failed. Make sure both the config and |
| 384 // nudge are executed. | 381 // nudge are executed. |
| 385 TEST_F(SyncSchedulerTest, NudgeWithConfigWithBackingOff) { | 382 TEST_F(SyncSchedulerTest, NudgeWithConfigWithBackingOff) { |
| 386 syncable::ModelTypeBitSet model_types; | 383 const syncable::ModelEnumSet model_types(syncable::BOOKMARKS); |
| 387 model_types[syncable::BOOKMARKS] = true; | |
| 388 UseMockDelayProvider(); | 384 UseMockDelayProvider(); |
| 389 EXPECT_CALL(*delay(), GetDelay(_)) | 385 EXPECT_CALL(*delay(), GetDelay(_)) |
| 390 .WillRepeatedly(Return(TimeDelta::FromMilliseconds(50))); | 386 .WillRepeatedly(Return(TimeDelta::FromMilliseconds(50))); |
| 391 SyncShareRecords records; | 387 SyncShareRecords records; |
| 392 | 388 |
| 393 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) | 389 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) |
| 394 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateCommitFailed), | 390 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateCommitFailed), |
| 395 WithArg<0>(RecordSyncShare(&records)))) | 391 WithArg<0>(RecordSyncShare(&records)))) |
| 396 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateCommitFailed), | 392 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateCommitFailed), |
| 397 WithArg<0>(RecordSyncShare(&records)))) | 393 WithArg<0>(RecordSyncShare(&records)))) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 416 ASSERT_EQ(2U, records.snapshots.size()); | 412 ASSERT_EQ(2U, records.snapshots.size()); |
| 417 RunLoop(); | 413 RunLoop(); |
| 418 | 414 |
| 419 // Now change the mode so nudge can execute. | 415 // Now change the mode so nudge can execute. |
| 420 ASSERT_EQ(3U, records.snapshots.size()); | 416 ASSERT_EQ(3U, records.snapshots.size()); |
| 421 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | 417 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
| 422 RunLoop(); | 418 RunLoop(); |
| 423 | 419 |
| 424 ASSERT_EQ(4U, records.snapshots.size()); | 420 ASSERT_EQ(4U, records.snapshots.size()); |
| 425 | 421 |
| 426 EXPECT_TRUE(CompareModelTypeBitSetToModelTypePayloadMap(model_types, | 422 EXPECT_TRUE(CompareModelEnumSetToModelTypePayloadMap(model_types, |
| 427 records.snapshots[2]->source.types)); | 423 records.snapshots[2]->source.types)); |
| 428 EXPECT_EQ(GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION, | 424 EXPECT_EQ(GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION, |
| 429 records.snapshots[2]->source.updates_source); | 425 records.snapshots[2]->source.updates_source); |
| 430 | 426 |
| 431 EXPECT_TRUE(CompareModelTypeBitSetToModelTypePayloadMap(model_types, | 427 EXPECT_TRUE(CompareModelEnumSetToModelTypePayloadMap(model_types, |
| 432 records.snapshots[3]->source.types)); | 428 records.snapshots[3]->source.types)); |
| 433 EXPECT_EQ(GetUpdatesCallerInfo::LOCAL, | 429 EXPECT_EQ(GetUpdatesCallerInfo::LOCAL, |
| 434 records.snapshots[3]->source.updates_source); | 430 records.snapshots[3]->source.updates_source); |
| 435 | 431 |
| 436 } | 432 } |
| 437 | 433 |
| 438 // Test that nudges are coalesced. | 434 // Test that nudges are coalesced. |
| 439 TEST_F(SyncSchedulerTest, NudgeCoalescing) { | 435 TEST_F(SyncSchedulerTest, NudgeCoalescing) { |
| 440 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | 436 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
| 441 RunLoop(); | 437 RunLoop(); |
| 442 | 438 |
| 443 SyncShareRecords r; | 439 SyncShareRecords r; |
| 444 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) | 440 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) |
| 445 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess), | 441 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess), |
| 446 WithArg<0>(RecordSyncShare(&r)))); | 442 WithArg<0>(RecordSyncShare(&r)))); |
| 447 syncable::ModelTypeBitSet types1, types2, types3; | 443 const syncable::ModelEnumSet |
| 448 types1[syncable::BOOKMARKS] = true; | 444 types1(syncable::BOOKMARKS), |
| 449 types2[syncable::AUTOFILL] = true; | 445 types2(syncable::AUTOFILL), |
| 450 types3[syncable::THEMES] = true; | 446 types3(syncable::THEMES); |
| 451 TimeDelta delay = zero(); | 447 TimeDelta delay = zero(); |
| 452 TimeTicks optimal_time = TimeTicks::Now() + delay; | 448 TimeTicks optimal_time = TimeTicks::Now() + delay; |
| 453 scheduler()->ScheduleNudge( | 449 scheduler()->ScheduleNudge( |
| 454 delay, NUDGE_SOURCE_UNKNOWN, types1, FROM_HERE); | 450 delay, NUDGE_SOURCE_UNKNOWN, types1, FROM_HERE); |
| 455 scheduler()->ScheduleNudge( | 451 scheduler()->ScheduleNudge( |
| 456 zero(), NUDGE_SOURCE_LOCAL, types2, FROM_HERE); | 452 zero(), NUDGE_SOURCE_LOCAL, types2, FROM_HERE); |
| 457 RunLoop(); | 453 RunLoop(); |
| 458 | 454 |
| 459 ASSERT_EQ(1U, r.snapshots.size()); | 455 ASSERT_EQ(1U, r.snapshots.size()); |
| 460 EXPECT_GE(r.times[0], optimal_time); | 456 EXPECT_GE(r.times[0], optimal_time); |
| 461 EXPECT_TRUE(CompareModelTypeBitSetToModelTypePayloadMap( | 457 EXPECT_TRUE(CompareModelEnumSetToModelTypePayloadMap( |
| 462 types1 | types2, r.snapshots[0]->source.types)); | 458 Union(types1, types2), r.snapshots[0]->source.types)); |
| 463 EXPECT_EQ(GetUpdatesCallerInfo::LOCAL, | 459 EXPECT_EQ(GetUpdatesCallerInfo::LOCAL, |
| 464 r.snapshots[0]->source.updates_source); | 460 r.snapshots[0]->source.updates_source); |
| 465 | 461 |
| 466 Mock::VerifyAndClearExpectations(syncer()); | 462 Mock::VerifyAndClearExpectations(syncer()); |
| 467 | 463 |
| 468 SyncShareRecords r2; | 464 SyncShareRecords r2; |
| 469 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) | 465 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) |
| 470 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess), | 466 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess), |
| 471 WithArg<0>(RecordSyncShare(&r2)))); | 467 WithArg<0>(RecordSyncShare(&r2)))); |
| 472 scheduler()->ScheduleNudge( | 468 scheduler()->ScheduleNudge( |
| 473 zero(), NUDGE_SOURCE_NOTIFICATION, types3, FROM_HERE); | 469 zero(), NUDGE_SOURCE_NOTIFICATION, types3, FROM_HERE); |
| 474 RunLoop(); | 470 RunLoop(); |
| 475 | 471 |
| 476 ASSERT_EQ(1U, r2.snapshots.size()); | 472 ASSERT_EQ(1U, r2.snapshots.size()); |
| 477 EXPECT_TRUE(CompareModelTypeBitSetToModelTypePayloadMap(types3, | 473 EXPECT_TRUE(CompareModelEnumSetToModelTypePayloadMap(types3, |
| 478 r2.snapshots[0]->source.types)); | 474 r2.snapshots[0]->source.types)); |
| 479 EXPECT_EQ(GetUpdatesCallerInfo::NOTIFICATION, | 475 EXPECT_EQ(GetUpdatesCallerInfo::NOTIFICATION, |
| 480 r2.snapshots[0]->source.updates_source); | 476 r2.snapshots[0]->source.updates_source); |
| 481 } | 477 } |
| 482 | 478 |
| 483 // Test nudge scheduling. | 479 // Test nudge scheduling. |
| 484 TEST_F(SyncSchedulerTest, NudgeWithPayloads) { | 480 TEST_F(SyncSchedulerTest, NudgeWithPayloads) { |
| 485 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | 481 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
| 486 RunLoop(); | 482 RunLoop(); |
| 487 | 483 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 sessions::test_util::SimulateSessionsCommitDelayUpdate( | 645 sessions::test_util::SimulateSessionsCommitDelayUpdate( |
| 650 delay2)), | 646 delay2)), |
| 651 Invoke(sessions::test_util::SimulateSuccess), | 647 Invoke(sessions::test_util::SimulateSuccess), |
| 652 QuitLoopNowAction())); | 648 QuitLoopNowAction())); |
| 653 | 649 |
| 654 EXPECT_EQ(delay1, scheduler()->sessions_commit_delay()); | 650 EXPECT_EQ(delay1, scheduler()->sessions_commit_delay()); |
| 655 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | 651 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
| 656 RunLoop(); | 652 RunLoop(); |
| 657 | 653 |
| 658 EXPECT_EQ(delay1, scheduler()->sessions_commit_delay()); | 654 EXPECT_EQ(delay1, scheduler()->sessions_commit_delay()); |
| 659 syncable::ModelTypeBitSet model_types; | 655 const syncable::ModelEnumSet model_types(syncable::BOOKMARKS); |
| 660 model_types[syncable::BOOKMARKS] = true; | |
| 661 scheduler()->ScheduleNudge( | 656 scheduler()->ScheduleNudge( |
| 662 zero(), NUDGE_SOURCE_LOCAL, model_types, FROM_HERE); | 657 zero(), NUDGE_SOURCE_LOCAL, model_types, FROM_HERE); |
| 663 RunLoop(); | 658 RunLoop(); |
| 664 | 659 |
| 665 EXPECT_EQ(delay2, scheduler()->sessions_commit_delay()); | 660 EXPECT_EQ(delay2, scheduler()->sessions_commit_delay()); |
| 666 StopSyncScheduler(); | 661 StopSyncScheduler(); |
| 667 } | 662 } |
| 668 | 663 |
| 669 // Test that a sync session is run through to completion. | 664 // Test that a sync session is run through to completion. |
| 670 TEST_F(SyncSchedulerTest, HasMoreToSync) { | 665 TEST_F(SyncSchedulerTest, HasMoreToSync) { |
| 671 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) | 666 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) |
| 672 .WillOnce(Invoke(sessions::test_util::SimulateHasMoreToSync)) | 667 .WillOnce(Invoke(sessions::test_util::SimulateHasMoreToSync)) |
| 673 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess), | 668 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess), |
| 674 QuitLoopNowAction())); | 669 QuitLoopNowAction())); |
| 675 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | 670 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
| 676 RunLoop(); | 671 RunLoop(); |
| 677 | 672 |
| 678 scheduler()->ScheduleNudge( | 673 scheduler()->ScheduleNudge( |
| 679 zero(), NUDGE_SOURCE_LOCAL, ModelTypeBitSet(), FROM_HERE); | 674 zero(), NUDGE_SOURCE_LOCAL, syncable::ModelEnumSet(), FROM_HERE); |
| 680 RunLoop(); | 675 RunLoop(); |
| 681 // If more nudges are scheduled, they'll be waited on by TearDown, and would | 676 // If more nudges are scheduled, they'll be waited on by TearDown, and would |
| 682 // cause our expectation to break. | 677 // cause our expectation to break. |
| 683 } | 678 } |
| 684 | 679 |
| 685 // Test that no syncing occurs when throttled. | 680 // Test that no syncing occurs when throttled. |
| 686 TEST_F(SyncSchedulerTest, ThrottlingDoesThrottle) { | 681 TEST_F(SyncSchedulerTest, ThrottlingDoesThrottle) { |
| 687 syncable::ModelTypeBitSet types; | 682 const syncable::ModelEnumSet types(syncable::BOOKMARKS); |
| 688 types[syncable::BOOKMARKS] = true; | |
| 689 TimeDelta poll(TimeDelta::FromMilliseconds(5)); | 683 TimeDelta poll(TimeDelta::FromMilliseconds(5)); |
| 690 TimeDelta throttle(TimeDelta::FromMinutes(10)); | 684 TimeDelta throttle(TimeDelta::FromMinutes(10)); |
| 691 scheduler()->OnReceivedLongPollIntervalUpdate(poll); | 685 scheduler()->OnReceivedLongPollIntervalUpdate(poll); |
| 692 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) | 686 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) |
| 693 .WillOnce(WithArg<0>(sessions::test_util::SimulateThrottled(throttle))) | 687 .WillOnce(WithArg<0>(sessions::test_util::SimulateThrottled(throttle))) |
| 694 .WillRepeatedly(AddFailureAndQuitLoopNow()); | 688 .WillRepeatedly(AddFailureAndQuitLoopNow()); |
| 695 | 689 |
| 696 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | 690 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
| 697 RunLoop(); | 691 RunLoop(); |
| 698 | 692 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 TimeDelta poll(TimeDelta::FromMilliseconds(15)); | 733 TimeDelta poll(TimeDelta::FromMilliseconds(15)); |
| 740 SyncShareRecords records; | 734 SyncShareRecords records; |
| 741 scheduler()->OnReceivedLongPollIntervalUpdate(poll); | 735 scheduler()->OnReceivedLongPollIntervalUpdate(poll); |
| 742 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) | 736 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) |
| 743 .WillOnce((Invoke(sessions::test_util::SimulateSuccess), | 737 .WillOnce((Invoke(sessions::test_util::SimulateSuccess), |
| 744 WithArg<0>(RecordSyncShare(&records)))); | 738 WithArg<0>(RecordSyncShare(&records)))); |
| 745 | 739 |
| 746 StartSyncScheduler(SyncScheduler::CONFIGURATION_MODE); | 740 StartSyncScheduler(SyncScheduler::CONFIGURATION_MODE); |
| 747 RunLoop(); | 741 RunLoop(); |
| 748 | 742 |
| 749 syncable::ModelTypeBitSet nudge_types; | 743 const syncable::ModelEnumSet nudge_types(syncable::AUTOFILL); |
| 750 nudge_types[syncable::AUTOFILL] = true; | |
| 751 scheduler()->ScheduleNudge( | 744 scheduler()->ScheduleNudge( |
| 752 zero(), NUDGE_SOURCE_LOCAL, nudge_types, FROM_HERE); | 745 zero(), NUDGE_SOURCE_LOCAL, nudge_types, FROM_HERE); |
| 753 scheduler()->ScheduleNudge( | 746 scheduler()->ScheduleNudge( |
| 754 zero(), NUDGE_SOURCE_LOCAL, nudge_types, FROM_HERE); | 747 zero(), NUDGE_SOURCE_LOCAL, nudge_types, FROM_HERE); |
| 755 | 748 |
| 756 syncable::ModelTypeBitSet config_types; | 749 const syncable::ModelEnumSet config_types(syncable::BOOKMARKS); |
| 757 config_types[syncable::BOOKMARKS] = true; | |
| 758 | 750 |
| 759 scheduler()->ScheduleConfig( | 751 scheduler()->ScheduleConfig( |
| 760 config_types, GetUpdatesCallerInfo::RECONFIGURATION); | 752 config_types, GetUpdatesCallerInfo::RECONFIGURATION); |
| 761 RunLoop(); | 753 RunLoop(); |
| 762 | 754 |
| 763 ASSERT_EQ(1U, records.snapshots.size()); | 755 ASSERT_EQ(1U, records.snapshots.size()); |
| 764 EXPECT_TRUE(CompareModelTypeBitSetToModelTypePayloadMap(config_types, | 756 EXPECT_TRUE(CompareModelEnumSetToModelTypePayloadMap(config_types, |
| 765 records.snapshots[0]->source.types)); | 757 records.snapshots[0]->source.types)); |
| 766 } | 758 } |
| 767 | 759 |
| 768 // Test that exponential backoff is properly triggered. | 760 // Test that exponential backoff is properly triggered. |
| 769 TEST_F(SyncSchedulerTest, BackoffTriggers) { | 761 TEST_F(SyncSchedulerTest, BackoffTriggers) { |
| 770 UseMockDelayProvider(); | 762 UseMockDelayProvider(); |
| 771 | 763 |
| 772 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) | 764 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) |
| 773 .WillOnce(Invoke(sessions::test_util::SimulateDownloadUpdatesFailed)) | 765 .WillOnce(Invoke(sessions::test_util::SimulateDownloadUpdatesFailed)) |
| 774 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess), | 766 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess), |
| (...skipping 27 matching lines...) Expand all Loading... |
| 802 .WillOnce(Invoke(sessions::test_util::SimulateCommitFailed)) | 794 .WillOnce(Invoke(sessions::test_util::SimulateCommitFailed)) |
| 803 .WillRepeatedly(DoAll(Invoke(sessions::test_util::SimulateSuccess), | 795 .WillRepeatedly(DoAll(Invoke(sessions::test_util::SimulateSuccess), |
| 804 QuitLoopNowAction())); | 796 QuitLoopNowAction())); |
| 805 EXPECT_FALSE(GetBackoffAndResetTest()); | 797 EXPECT_FALSE(GetBackoffAndResetTest()); |
| 806 } | 798 } |
| 807 | 799 |
| 808 // Test that no polls or extraneous nudges occur when in backoff. | 800 // Test that no polls or extraneous nudges occur when in backoff. |
| 809 TEST_F(SyncSchedulerTest, BackoffDropsJobs) { | 801 TEST_F(SyncSchedulerTest, BackoffDropsJobs) { |
| 810 SyncShareRecords r; | 802 SyncShareRecords r; |
| 811 TimeDelta poll(TimeDelta::FromMilliseconds(5)); | 803 TimeDelta poll(TimeDelta::FromMilliseconds(5)); |
| 812 syncable::ModelTypeBitSet types; | 804 const syncable::ModelEnumSet types(syncable::BOOKMARKS); |
| 813 types[syncable::BOOKMARKS] = true; | |
| 814 scheduler()->OnReceivedLongPollIntervalUpdate(poll); | 805 scheduler()->OnReceivedLongPollIntervalUpdate(poll); |
| 815 UseMockDelayProvider(); | 806 UseMockDelayProvider(); |
| 816 | 807 |
| 817 EXPECT_CALL(*syncer(), SyncShare(_,_,_)).Times(2) | 808 EXPECT_CALL(*syncer(), SyncShare(_,_,_)).Times(2) |
| 818 .WillRepeatedly(DoAll(Invoke(sessions::test_util::SimulateCommitFailed), | 809 .WillRepeatedly(DoAll(Invoke(sessions::test_util::SimulateCommitFailed), |
| 819 RecordSyncShareMultiple(&r, 2U))); | 810 RecordSyncShareMultiple(&r, 2U))); |
| 820 EXPECT_CALL(*delay(), GetDelay(_)). | 811 EXPECT_CALL(*delay(), GetDelay(_)). |
| 821 WillRepeatedly(Return(TimeDelta::FromDays(1))); | 812 WillRepeatedly(Return(TimeDelta::FromDays(1))); |
| 822 | 813 |
| 823 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | 814 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 | 958 |
| 968 // Test that appropriate syncer steps are requested for each job type. | 959 // Test that appropriate syncer steps are requested for each job type. |
| 969 TEST_F(SyncSchedulerTest, SyncerSteps) { | 960 TEST_F(SyncSchedulerTest, SyncerSteps) { |
| 970 // Nudges. | 961 // Nudges. |
| 971 EXPECT_CALL(*syncer(), SyncShare(_, SYNCER_BEGIN, SYNCER_END)) | 962 EXPECT_CALL(*syncer(), SyncShare(_, SYNCER_BEGIN, SYNCER_END)) |
| 972 .Times(1); | 963 .Times(1); |
| 973 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | 964 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
| 974 RunLoop(); | 965 RunLoop(); |
| 975 | 966 |
| 976 scheduler()->ScheduleNudge( | 967 scheduler()->ScheduleNudge( |
| 977 zero(), NUDGE_SOURCE_LOCAL, ModelTypeBitSet(), FROM_HERE); | 968 zero(), NUDGE_SOURCE_LOCAL, syncable::ModelEnumSet(), FROM_HERE); |
| 978 PumpLoop(); | 969 PumpLoop(); |
| 979 // Pump again to run job. | 970 // Pump again to run job. |
| 980 PumpLoop(); | 971 PumpLoop(); |
| 981 | 972 |
| 982 StopSyncScheduler(); | 973 StopSyncScheduler(); |
| 983 Mock::VerifyAndClearExpectations(syncer()); | 974 Mock::VerifyAndClearExpectations(syncer()); |
| 984 | 975 |
| 985 // ClearUserData. | 976 // ClearUserData. |
| 986 EXPECT_CALL(*syncer(), SyncShare(_, CLEAR_PRIVATE_DATA, CLEAR_PRIVATE_DATA)) | 977 EXPECT_CALL(*syncer(), SyncShare(_, CLEAR_PRIVATE_DATA, CLEAR_PRIVATE_DATA)) |
| 987 .Times(1); | 978 .Times(1); |
| 988 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | 979 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
| 989 RunLoop(); | 980 RunLoop(); |
| 990 | 981 |
| 991 scheduler()->ScheduleClearUserData(); | 982 scheduler()->ScheduleClearUserData(); |
| 992 PumpLoop(); | 983 PumpLoop(); |
| 993 PumpLoop(); | 984 PumpLoop(); |
| 994 | 985 |
| 995 StopSyncScheduler(); | 986 StopSyncScheduler(); |
| 996 Mock::VerifyAndClearExpectations(syncer()); | 987 Mock::VerifyAndClearExpectations(syncer()); |
| 997 | 988 |
| 998 // Configuration. | 989 // Configuration. |
| 999 EXPECT_CALL(*syncer(), SyncShare(_, DOWNLOAD_UPDATES, APPLY_UPDATES)); | 990 EXPECT_CALL(*syncer(), SyncShare(_, DOWNLOAD_UPDATES, APPLY_UPDATES)); |
| 1000 StartSyncScheduler(SyncScheduler::CONFIGURATION_MODE); | 991 StartSyncScheduler(SyncScheduler::CONFIGURATION_MODE); |
| 1001 RunLoop(); | 992 RunLoop(); |
| 1002 | 993 |
| 1003 scheduler()->ScheduleConfig( | 994 scheduler()->ScheduleConfig( |
| 1004 ModelTypeBitSet(), GetUpdatesCallerInfo::RECONFIGURATION); | 995 syncable::ModelEnumSet(), GetUpdatesCallerInfo::RECONFIGURATION); |
| 1005 PumpLoop(); | 996 PumpLoop(); |
| 1006 PumpLoop(); | 997 PumpLoop(); |
| 1007 | 998 |
| 1008 StopSyncScheduler(); | 999 StopSyncScheduler(); |
| 1009 Mock::VerifyAndClearExpectations(syncer()); | 1000 Mock::VerifyAndClearExpectations(syncer()); |
| 1010 | 1001 |
| 1011 // Cleanup disabled types. | 1002 // Cleanup disabled types. |
| 1012 EXPECT_CALL(*syncer(), | 1003 EXPECT_CALL(*syncer(), |
| 1013 SyncShare(_, CLEANUP_DISABLED_TYPES, CLEANUP_DISABLED_TYPES)); | 1004 SyncShare(_, CLEANUP_DISABLED_TYPES, CLEANUP_DISABLED_TYPES)); |
| 1014 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | 1005 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1046 | 1037 |
| 1047 // Test that starting the syncer thread without a valid connection doesn't | 1038 // Test that starting the syncer thread without a valid connection doesn't |
| 1048 // break things when a connection is detected. | 1039 // break things when a connection is detected. |
| 1049 TEST_F(SyncSchedulerTest, StartWhenNotConnected) { | 1040 TEST_F(SyncSchedulerTest, StartWhenNotConnected) { |
| 1050 connection()->SetServerNotReachable(); | 1041 connection()->SetServerNotReachable(); |
| 1051 EXPECT_CALL(*syncer(), SyncShare(_,_,_)).WillOnce(QuitLoopNowAction()); | 1042 EXPECT_CALL(*syncer(), SyncShare(_,_,_)).WillOnce(QuitLoopNowAction()); |
| 1052 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | 1043 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
| 1053 RunLoop(); | 1044 RunLoop(); |
| 1054 | 1045 |
| 1055 scheduler()->ScheduleNudge( | 1046 scheduler()->ScheduleNudge( |
| 1056 zero(), NUDGE_SOURCE_LOCAL, ModelTypeBitSet(), FROM_HERE); | 1047 zero(), NUDGE_SOURCE_LOCAL, syncable::ModelEnumSet(), FROM_HERE); |
| 1057 // Should save the nudge for until after the server is reachable. | 1048 // Should save the nudge for until after the server is reachable. |
| 1058 PumpLoop(); | 1049 PumpLoop(); |
| 1059 | 1050 |
| 1060 connection()->SetServerReachable(); | 1051 connection()->SetServerReachable(); |
| 1061 PumpLoop(); | 1052 PumpLoop(); |
| 1062 } | 1053 } |
| 1063 | 1054 |
| 1064 TEST_F(SyncSchedulerTest, SetsPreviousRoutingInfo) { | 1055 TEST_F(SyncSchedulerTest, SetsPreviousRoutingInfo) { |
| 1065 ModelSafeRoutingInfo info; | 1056 ModelSafeRoutingInfo info; |
| 1066 EXPECT_TRUE(info == context()->previous_session_routing_info()); | 1057 EXPECT_TRUE(info == context()->previous_session_routing_info()); |
| 1067 ModelSafeRoutingInfo expected; | 1058 ModelSafeRoutingInfo expected; |
| 1068 context()->registrar()->GetModelSafeRoutingInfo(&expected); | 1059 context()->registrar()->GetModelSafeRoutingInfo(&expected); |
| 1069 ASSERT_FALSE(expected.empty()); | 1060 ASSERT_FALSE(expected.empty()); |
| 1070 EXPECT_CALL(*syncer(), SyncShare(_,_,_)).Times(1); | 1061 EXPECT_CALL(*syncer(), SyncShare(_,_,_)).Times(1); |
| 1071 | 1062 |
| 1072 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | 1063 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
| 1073 RunLoop(); | 1064 RunLoop(); |
| 1074 | 1065 |
| 1075 scheduler()->ScheduleNudge( | 1066 scheduler()->ScheduleNudge( |
| 1076 zero(), NUDGE_SOURCE_LOCAL, ModelTypeBitSet(), FROM_HERE); | 1067 zero(), NUDGE_SOURCE_LOCAL, syncable::ModelEnumSet(), FROM_HERE); |
| 1077 PumpLoop(); | 1068 PumpLoop(); |
| 1078 // Pump again to run job. | 1069 // Pump again to run job. |
| 1079 PumpLoop(); | 1070 PumpLoop(); |
| 1080 | 1071 |
| 1081 StopSyncScheduler(); | 1072 StopSyncScheduler(); |
| 1082 | 1073 |
| 1083 EXPECT_TRUE(expected == context()->previous_session_routing_info()); | 1074 EXPECT_TRUE(expected == context()->previous_session_routing_info()); |
| 1084 } | 1075 } |
| 1085 | 1076 |
| 1086 } // namespace browser_sync | 1077 } // namespace browser_sync |
| OLD | NEW |