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

Unified Diff: sync/engine/sync_scheduler_unittest.cc

Issue 10823061: Revert 148792 - [Sync] Remove CleanupDisabledTypes command and move purge logic into SyncManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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/syncer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/engine/sync_scheduler_unittest.cc
===================================================================
--- sync/engine/sync_scheduler_unittest.cc (revision 148811)
+++ sync/engine/sync_scheduler_unittest.cc (working copy)
@@ -300,7 +300,9 @@
SyncShareRecords records;
const ModelTypeSet model_types(BOOKMARKS);
- EXPECT_CALL(*syncer(), SyncShare(_,_,_))
+ EXPECT_CALL(*syncer(),
+ SyncShare(_,_,_))
+ .WillOnce(Invoke(sessions::test_util::SimulateSuccess))
.WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess),
WithArg<0>(RecordSyncShare(&records))));
@@ -331,7 +333,9 @@
SyncShareRecords records;
const ModelTypeSet model_types(BOOKMARKS);
- EXPECT_CALL(*syncer(), SyncShare(_,_,_))
+ EXPECT_CALL(*syncer(),
+ SyncShare(_,_,_))
+ .WillOnce(Invoke(sessions::test_util::SimulateSuccess))
.WillOnce(DoAll(Invoke(sessions::test_util::SimulateCommitFailed),
WithArg<0>(RecordSyncShare(&records))))
.WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess),
@@ -705,14 +709,19 @@
EXPECT_TRUE(RunAndGetBackoff());
}
-// Test that no syncing occurs when throttled.
+// Test that no syncing occurs when throttled (although CleanupDisabledTypes
+// is allowed).
TEST_F(SyncSchedulerTest, ThrottlingDoesThrottle) {
const ModelTypeSet types(BOOKMARKS);
TimeDelta poll(TimeDelta::FromMilliseconds(5));
TimeDelta throttle(TimeDelta::FromMinutes(10));
scheduler()->OnReceivedLongPollIntervalUpdate(poll);
- EXPECT_CALL(*syncer(), SyncShare(_,_,_))
+ EXPECT_CALL(*syncer(),
+ SyncShare(_, CLEANUP_DISABLED_TYPES, CLEANUP_DISABLED_TYPES))
+ .WillOnce(Invoke(sessions::test_util::SimulateSuccess));
+ EXPECT_CALL(*syncer(), SyncShare(_,Not(CLEANUP_DISABLED_TYPES),
+ Not(CLEANUP_DISABLED_TYPES)))
.WillOnce(WithArg<0>(sessions::test_util::SimulateThrottled(throttle)))
.WillRepeatedly(AddFailureAndQuitLoopNow());
@@ -765,6 +774,7 @@
SyncShareRecords records;
scheduler()->OnReceivedLongPollIntervalUpdate(poll);
EXPECT_CALL(*syncer(), SyncShare(_,_,_))
+ .WillOnce(Invoke(sessions::test_util::SimulateSuccess))
.WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess),
WithArg<0>(RecordSyncShare(&records))));
@@ -889,6 +899,10 @@
EXPECT_EQ(GetUpdatesCallerInfo::LOCAL,
r.snapshots[1].source().updates_source);
+ // Cleanup is not affected by backoff, but it should not relieve it either.
+ EXPECT_CALL(*syncer(),
+ SyncShare(_, CLEANUP_DISABLED_TYPES, CLEANUP_DISABLED_TYPES))
+ .WillOnce(Invoke(sessions::test_util::SimulateSuccess));
EXPECT_CALL(*delay(), GetDelay(_)).Times(0);
StartSyncScheduler(SyncScheduler::CONFIGURATION_MODE);
@@ -1062,7 +1076,10 @@
StopSyncScheduler();
Mock::VerifyAndClearExpectations(syncer());
- // Configuration.
+ // Configuration (always includes a cleanup disabled types).
+ EXPECT_CALL(*syncer(),
+ SyncShare(_, CLEANUP_DISABLED_TYPES, CLEANUP_DISABLED_TYPES))
+ .WillOnce(Invoke(sessions::test_util::SimulateSuccess));
EXPECT_CALL(*syncer(), SyncShare(_, DOWNLOAD_UPDATES, APPLY_UPDATES))
.WillOnce(Invoke(sessions::test_util::SimulateSuccess));
StartSyncScheduler(SyncScheduler::CONFIGURATION_MODE);
@@ -1081,6 +1098,25 @@
StopSyncScheduler();
Mock::VerifyAndClearExpectations(syncer());
+ // Cleanup disabled types. Because no types are being configured, we just
+ // perform the cleanup.
+ EXPECT_CALL(*syncer(),
+ SyncShare(_, CLEANUP_DISABLED_TYPES, CLEANUP_DISABLED_TYPES)).
+ WillOnce(Invoke(sessions::test_util::SimulateSuccess));
+ StartSyncScheduler(SyncScheduler::CONFIGURATION_MODE);
+
+ CallbackCounter counter2;
+ ConfigurationParams params2(
+ GetUpdatesCallerInfo::RECONFIGURATION,
+ ModelTypeSet(),
+ ModelSafeRoutingInfo(),
+ ConfigurationParams::KEYSTORE_KEY_UNNECESSARY,
+ base::Bind(&CallbackCounter::Callback, base::Unretained(&counter2)));
+ ASSERT_TRUE(scheduler()->ScheduleConfiguration(params2));
+ ASSERT_EQ(1, counter2.times_called());
+ StopSyncScheduler();
+ Mock::VerifyAndClearExpectations(syncer());
+
StartSyncScheduler(SyncScheduler::NORMAL_MODE);
// Poll.
@@ -1126,4 +1162,24 @@
MessageLoop::current()->RunAllPending();
}
+TEST_F(SyncSchedulerTest, SetsPreviousRoutingInfo) {
+ ModelSafeRoutingInfo info;
+ EXPECT_TRUE(info == context()->previous_session_routing_info());
+ ModelSafeRoutingInfo expected(context()->routing_info());
+ ASSERT_FALSE(expected.empty());
+ EXPECT_CALL(*syncer(), SyncShare(_,_,_)).Times(1);
+
+ StartSyncScheduler(SyncScheduler::NORMAL_MODE);
+
+ scheduler()->ScheduleNudgeAsync(
+ zero(), NUDGE_SOURCE_LOCAL, ModelTypeSet(), FROM_HERE);
+ PumpLoop();
+ // Pump again to run job.
+ PumpLoop();
+
+ StopSyncScheduler();
+
+ EXPECT_TRUE(expected == context()->previous_session_routing_info());
+}
+
} // namespace syncer
« no previous file with comments | « sync/engine/sync_scheduler_impl.cc ('k') | sync/engine/syncer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698