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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
473 zero(), NUDGE_SOURCE_NOTIFICATION, types3, FROM_HERE); | 473 zero(), NUDGE_SOURCE_NOTIFICATION, types3, FROM_HERE); |
474 RunLoop(); | 474 RunLoop(); |
475 | 475 |
476 ASSERT_EQ(1U, r2.snapshots.size()); | 476 ASSERT_EQ(1U, r2.snapshots.size()); |
477 EXPECT_TRUE(CompareModelTypeBitSetToModelTypePayloadMap(types3, | 477 EXPECT_TRUE(CompareModelTypeBitSetToModelTypePayloadMap(types3, |
478 r2.snapshots[0]->source.types)); | 478 r2.snapshots[0]->source.types)); |
479 EXPECT_EQ(GetUpdatesCallerInfo::NOTIFICATION, | 479 EXPECT_EQ(GetUpdatesCallerInfo::NOTIFICATION, |
480 r2.snapshots[0]->source.updates_source); | 480 r2.snapshots[0]->source.updates_source); |
481 } | 481 } |
482 | 482 |
483 // Test that nudges are coalesced. | |
484 TEST_F(SyncSchedulerTest, NudgeCoalescingWithDifferentTimings) { | |
485 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | |
486 RunLoop(); | |
487 | |
488 SyncShareRecords r; | |
489 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) | |
490 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess), | |
491 WithArg<0>(RecordSyncShare(&r)))); | |
492 syncable::ModelTypeBitSet types1, types2, types3; | |
493 types1[syncable::BOOKMARKS] = true; | |
494 types2[syncable::AUTOFILL] = true; | |
495 | |
496 // Create a huge time delay. | |
497 TimeDelta delay = TimeDelta::FromSeconds(1200); | |
tim (not reviewing)
2011/12/09 23:07:22
OCD nit :) I think FromDays(1) is more readable fo
lipalani1
2011/12/15 01:35:16
Done.
| |
498 | |
499 scheduler()->ScheduleNudge( | |
500 delay, NUDGE_SOURCE_UNKNOWN, types1, FROM_HERE); | |
501 | |
502 scheduler()->ScheduleNudge( | |
503 zero(), NUDGE_SOURCE_UNKNOWN, types2, FROM_HERE); | |
504 | |
505 TimeTicks min_time = TimeTicks::Now(); | |
506 TimeTicks max_time = TimeTicks::Now() + delay; | |
507 | |
508 RunLoop(); | |
509 | |
510 // Make sure the sync has happened. | |
511 ASSERT_EQ(1U, r.snapshots.size()); | |
512 EXPECT_TRUE(CompareModelTypeBitSetToModelTypePayloadMap( | |
513 types1 | types2, r.snapshots[0]->source.types)); | |
514 | |
515 // Make sure the sync happened at the right time. | |
516 EXPECT_GE(r.times[0], min_time); | |
517 EXPECT_LE(r.times[0], max_time); | |
518 } | |
519 | |
483 // Test nudge scheduling. | 520 // Test nudge scheduling. |
484 TEST_F(SyncSchedulerTest, NudgeWithPayloads) { | 521 TEST_F(SyncSchedulerTest, NudgeWithPayloads) { |
485 StartSyncScheduler(SyncScheduler::NORMAL_MODE); | 522 StartSyncScheduler(SyncScheduler::NORMAL_MODE); |
486 RunLoop(); | 523 RunLoop(); |
487 | 524 |
488 SyncShareRecords records; | 525 SyncShareRecords records; |
489 syncable::ModelTypePayloadMap model_types_with_payloads; | 526 syncable::ModelTypePayloadMap model_types_with_payloads; |
490 model_types_with_payloads[syncable::BOOKMARKS] = "test"; | 527 model_types_with_payloads[syncable::BOOKMARKS] = "test"; |
491 | 528 |
492 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) | 529 EXPECT_CALL(*syncer(), SyncShare(_,_,_)) |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1077 PumpLoop(); | 1114 PumpLoop(); |
1078 // Pump again to run job. | 1115 // Pump again to run job. |
1079 PumpLoop(); | 1116 PumpLoop(); |
1080 | 1117 |
1081 StopSyncScheduler(); | 1118 StopSyncScheduler(); |
1082 | 1119 |
1083 EXPECT_TRUE(expected == context()->previous_session_routing_info()); | 1120 EXPECT_TRUE(expected == context()->previous_session_routing_info()); |
1084 } | 1121 } |
1085 | 1122 |
1086 } // namespace browser_sync | 1123 } // namespace browser_sync |
OLD | NEW |