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

Unified Diff: sync/internal_api/syncapi_unittest.cc

Issue 10541079: [Sync] Remove CleanupDisabledTypes command and move purge logic into SyncManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix rebase conflict 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
Index: sync/internal_api/syncapi_unittest.cc
diff --git a/sync/internal_api/syncapi_unittest.cc b/sync/internal_api/syncapi_unittest.cc
index f5eb675e17e30bf054dab6918b9fadbfac026a06..ca81a4ee08a468244d42e01398c1f1d3345a74fe 100644
--- a/sync/internal_api/syncapi_unittest.cc
+++ b/sync/internal_api/syncapi_unittest.cc
@@ -919,6 +919,22 @@ class SyncManagerTest : public testing::Test,
TestInternalComponentsFactory::IN_MEMORY);
}
+ void SetProgressMarkerForType(ModelType type, bool set) {
+ if (set) {
+ sync_pb::DataTypeProgressMarker marker;
+ marker.set_token("token");
+ marker.set_data_type_id(GetSpecificsFieldNumberFromModelType(type));
+ sync_manager_.directory()->SetDownloadProgress(type, marker);
+ } else {
+ sync_pb::DataTypeProgressMarker marker;
+ sync_manager_.directory()->SetDownloadProgress(type, marker);
+ }
+ }
+
+ void SetInitialSyncEndedForType(ModelType type, bool value) {
+ sync_manager_.directory()->set_initial_sync_ended_for_type(type, value);
+ }
+
private:
// Needed by |sync_manager_|.
MessageLoop message_loop_;
@@ -2534,18 +2550,29 @@ class SyncManagerTestWithMockScheduler : public SyncManagerTest {
};
// Test that the configuration params are properly created and sent to
-// ScheduleConfigure. No callback should be invoked.
+// ScheduleConfigure. No callback should be invoked. Any disabled datatypes
+// should be purged (but only the types that were just disabled).
tim (not reviewing) 2012/07/26 21:39:45 I don't see a test that covers a case where both p
Nicolas Zea 2012/07/26 23:29:59 The purging of both at startup is actually going a
TEST_F(SyncManagerTestWithMockScheduler, BasicConfiguration) {
ConfigureReason reason = CONFIGURE_REASON_RECONFIGURATION;
ModelTypeSet types_to_download(BOOKMARKS, PREFERENCES);
ModelSafeRoutingInfo new_routing_info;
GetModelSafeRoutingInfo(&new_routing_info);
+ ModelTypeSet disabled_types(THEMES, SESSIONS);
+ new_routing_info.erase(THEMES);
+ new_routing_info.erase(SESSIONS);
ConfigurationParams params;
EXPECT_CALL(*scheduler_, Start(SyncScheduler::CONFIGURATION_MODE));
EXPECT_CALL(*scheduler_, ScheduleConfiguration(_)).
WillOnce(DoAll(SaveArg<0>(&params), Return(true)));
+ // Set data for all types.
+ for (ModelTypeSet::Iterator iter = ModelTypeSet::All().First(); iter.Good();
+ iter.Inc()) {
+ SetProgressMarkerForType(iter.Get(), true);
+ SetInitialSyncEndedForType(iter.Get(), true);
+ }
+
CallbackCounter ready_task_counter, retry_task_counter;
sync_manager_.ConfigureSyncer(
reason,
@@ -2561,6 +2588,12 @@ TEST_F(SyncManagerTestWithMockScheduler, BasicConfiguration) {
params.source);
EXPECT_TRUE(types_to_download.Equals(params.types_to_download));
EXPECT_EQ(new_routing_info, params.routing_info);
+
+ // Verify only the disabled types were purged.
+ EXPECT_TRUE(Intersection(sync_manager_.InitialSyncEndedTypes(),
+ disabled_types).Empty());
+ EXPECT_TRUE(disabled_types.Equals(
+ sync_manager_.GetTypesWithEmptyProgressMarkerToken(ModelTypeSet::All())));
}
// Test that the retry callback is invoked on configuration failure.
@@ -2634,4 +2667,38 @@ TEST_F(SyncManagerTest, PurgePartiallySyncedTypes) {
EXPECT_FALSE(partial_types.Has(PREFERENCES));
}
+// Test CleanipDisabledTypes properly purges all disabled types as specified
+// by the previous and current enabled params.
+TEST_F(SyncManagerTest, CleanupDisabledTypes) {
+ ModelSafeRoutingInfo routing_info;
+ GetModelSafeRoutingInfo(&routing_info);
+ ModelTypeSet enabled_types = GetRoutingInfoTypes(routing_info);
+ ModelTypeSet disabled_types = Difference(ModelTypeSet::All(), enabled_types);
+
+ // Set data for all types.
+ for (ModelTypeSet::Iterator iter = ModelTypeSet::All().First(); iter.Good();
+ iter.Inc()) {
+ SetProgressMarkerForType(iter.Get(), true);
+ SetInitialSyncEndedForType(iter.Get(), true);
+ }
+
+ // Verify only the enabled types remain after cleanup.
+ sync_manager_.CleanupDisabledTypes(ModelTypeSet::All(), enabled_types);
+ EXPECT_TRUE(enabled_types.Equals(sync_manager_.InitialSyncEndedTypes()));
+ EXPECT_TRUE(disabled_types.Equals(
+ sync_manager_.GetTypesWithEmptyProgressMarkerToken(ModelTypeSet::All())));
+
+ // Disable some more types.
+ disabled_types.Put(BOOKMARKS);
+ disabled_types.Put(PREFERENCES);
+ ModelTypeSet new_enabled_types =
+ Difference(ModelTypeSet::All(), disabled_types);
+
+ // Verify only the non-disabled types remain after cleanup.
+ sync_manager_.CleanupDisabledTypes(enabled_types, new_enabled_types);
+ EXPECT_TRUE(new_enabled_types.Equals(sync_manager_.InitialSyncEndedTypes()));
+ EXPECT_TRUE(disabled_types.Equals(
+ sync_manager_.GetTypesWithEmptyProgressMarkerToken(ModelTypeSet::All())));
+}
+
} // namespace

Powered by Google App Engine
This is Rietveld 408576698