Index: chrome/browser/sync/glue/sync_backend_host_unittest.cc |
diff --git a/chrome/browser/sync/glue/sync_backend_host_unittest.cc b/chrome/browser/sync/glue/sync_backend_host_unittest.cc |
index 6fbc142a1b9469e7f757836e018eeb70c817e267..9f3e01913a8a0f5731a25b849433590e03ed55c7 100644 |
--- a/chrome/browser/sync/glue/sync_backend_host_unittest.cc |
+++ b/chrome/browser/sync/glue/sync_backend_host_unittest.cc |
@@ -149,13 +149,12 @@ class SyncBackendHostTest : public testing::Test { |
} |
// Synchronously initializes the backend. |
- void InitializeBackend(syncer::ModelTypeSet enabled_types) { |
+ void InitializeBackend() { |
EXPECT_CALL(mock_frontend_, OnBackendInitialized(_, true)). |
WillOnce(InvokeWithoutArgs(QuitMessageLoop)); |
backend_->Initialize(&mock_frontend_, |
syncer::WeakHandle<syncer::JsEventHandler>(), |
GURL(""), |
- enabled_types, |
credentials_, |
true, |
&fake_sync_manager_factory_, |
@@ -215,7 +214,7 @@ class SyncBackendHostTest : public testing::Test { |
// Test basic initialization with no initial types (first time initialization). |
// Only the nigori should be configured. |
TEST_F(SyncBackendHostTest, InitShutdown) { |
- InitializeBackend(syncer::ModelTypeSet()); |
+ InitializeBackend(); |
EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Equals( |
syncer::ModelTypeSet(syncer::NIGORI))); |
EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals( |
@@ -226,7 +225,7 @@ TEST_F(SyncBackendHostTest, InitShutdown) { |
// Test first time sync scenario. All types should be properly configured. |
TEST_F(SyncBackendHostTest, FirstTimeSync) { |
- InitializeBackend(syncer::ModelTypeSet()); |
+ InitializeBackend(); |
EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Equals( |
syncer::ModelTypeSet(syncer::NIGORI))); |
EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals( |
@@ -253,7 +252,7 @@ TEST_F(SyncBackendHostTest, Restart) { |
fake_manager_->set_progress_marker_types( |
enabled_types_); |
fake_manager_->set_initial_sync_ended_types(enabled_types_); |
- InitializeBackend(enabled_types_); |
+ InitializeBackend(); |
EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Empty()); |
EXPECT_TRUE(Intersection(fake_manager_->GetAndResetCleanedTypes(), |
enabled_types_).Empty()); |
@@ -285,19 +284,19 @@ TEST_F(SyncBackendHostTest, PartialTypes) { |
fake_manager_->set_progress_marker_types(enabled_types_); |
fake_manager_->set_initial_sync_ended_types(full_types); |
- // All partial types should have been purged with nothing downloaded as part |
- // of bringing up the backend. |
- InitializeBackend(enabled_types_); |
- EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Empty()); |
- EXPECT_TRUE(Intersection(fake_manager_->GetAndResetCleanedTypes(), |
- enabled_types_).Empty()); |
+ // Bringing up the backend should purge all partial types, then proceed to |
+ // download the Nigori. |
+ InitializeBackend(); |
+ EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Equals( |
+ syncer::ModelTypeSet(syncer::NIGORI))); |
+ EXPECT_TRUE(fake_manager_->GetAndResetCleanedTypes().HasAll(partial_types)); |
EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals( |
- full_types)); |
+ Union(full_types, syncer::ModelTypeSet(syncer::NIGORI)))); |
EXPECT_TRUE(fake_manager_->GetTypesWithEmptyProgressMarkerToken( |
- enabled_types_).Equals(partial_types)); |
+ enabled_types_).Equals( |
+ Difference(partial_types, syncer::ModelTypeSet(syncer::NIGORI)))); |
- // Now do the actual configuration, which should download and apply both |
- // nigori and bookmarks. |
+ // Now do the actual configuration, which should download and apply bookmarks. |
ConfigureDataTypes(enabled_types_, |
Difference(syncer::ModelTypeSet::All(), |
enabled_types_), |
@@ -315,15 +314,20 @@ TEST_F(SyncBackendHostTest, PartialTypes) { |
// enabled, we should re-download all of them because we lost their data. |
TEST_F(SyncBackendHostTest, LostDB) { |
sync_prefs_->SetSyncSetupCompleted(); |
- // Don't set any progress marker or initial_sync_ended types before |
- // initializing. Initialization should not affect the datatypes. |
- InitializeBackend(enabled_types_); |
- EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Empty()); |
- EXPECT_TRUE(Intersection(fake_manager_->GetAndResetCleanedTypes(), |
- enabled_types_).Empty()); |
- EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Empty()); |
+ // Initialization should fetch the Nigori node. Everything else should be |
+ // left untouched. |
+ InitializeBackend(); |
+ EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Equals( |
+ syncer::ModelTypeSet(syncer::NIGORI))); |
+ EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals( |
+ syncer::ModelTypeSet(syncer::NIGORI))); |
EXPECT_TRUE(fake_manager_->GetTypesWithEmptyProgressMarkerToken( |
- enabled_types_).Equals(enabled_types_)); |
+ enabled_types_).Equals( |
+ Difference(enabled_types_, syncer::ModelTypeSet(syncer::NIGORI)))); |
+ |
+ // The database was empty, so any cleaning is entirely optional. We want to |
+ // reset this value before running the next part of the test, though. |
+ fake_manager_->GetAndResetCleanedTypes(); |
// The actual configuration should redownload and apply all the enabled types. |
ConfigureDataTypes(enabled_types_, |
@@ -341,7 +345,7 @@ TEST_F(SyncBackendHostTest, LostDB) { |
TEST_F(SyncBackendHostTest, DisableTypes) { |
// Simulate first time sync. |
- InitializeBackend(syncer::ModelTypeSet()); |
+ InitializeBackend(); |
fake_manager_->GetAndResetCleanedTypes(); |
ConfigureDataTypes(enabled_types_, |
Difference(syncer::ModelTypeSet::All(), |
@@ -377,7 +381,7 @@ TEST_F(SyncBackendHostTest, DisableTypes) { |
TEST_F(SyncBackendHostTest, AddTypes) { |
// Simulate first time sync. |
- InitializeBackend(syncer::ModelTypeSet()); |
+ InitializeBackend(); |
fake_manager_->GetAndResetCleanedTypes(); |
ConfigureDataTypes(enabled_types_, |
Difference(syncer::ModelTypeSet::All(), |
@@ -414,7 +418,7 @@ TEST_F(SyncBackendHostTest, AddTypes) { |
// And and disable in the same configuration. |
TEST_F(SyncBackendHostTest, AddDisableTypes) { |
// Simulate first time sync. |
- InitializeBackend(syncer::ModelTypeSet()); |
+ InitializeBackend(); |
fake_manager_->GetAndResetCleanedTypes(); |
ConfigureDataTypes(enabled_types_, |
Difference(syncer::ModelTypeSet::All(), |
@@ -466,10 +470,10 @@ TEST_F(SyncBackendHostTest, NewlySupportedTypes) { |
enabled_types_.PutAll(new_types); |
// Does nothing. |
- InitializeBackend(enabled_types_); |
+ InitializeBackend(); |
EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Empty()); |
EXPECT_TRUE(Intersection(fake_manager_->GetAndResetCleanedTypes(), |
- enabled_types_).Empty()); |
+ old_types).Empty()); |
EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals(old_types)); |
EXPECT_TRUE(fake_manager_->GetTypesWithEmptyProgressMarkerToken( |
enabled_types_).Equals(new_types)); |
@@ -505,14 +509,17 @@ TEST_F(SyncBackendHostTest, NewlySupportedTypesWithPartialTypes) { |
syncer::EXTENSION_SETTINGS); |
enabled_types_.PutAll(new_types); |
- // Purge the partial types. |
- InitializeBackend(enabled_types_); |
- EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Empty()); |
- EXPECT_TRUE(Intersection(fake_manager_->GetAndResetCleanedTypes(), |
- enabled_types_).Empty()); |
- EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals(full_types)); |
+ // Purge the partial types. The nigori will be among the purged types, but |
+ // the syncer will re-download it by the time the initialization is complete. |
+ InitializeBackend(); |
+ EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Equals( |
+ syncer::ModelTypeSet(syncer::NIGORI))); |
+ EXPECT_TRUE(fake_manager_->GetAndResetCleanedTypes().HasAll(partial_types)); |
+ EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals( |
+ syncer::Union(full_types, syncer::ModelTypeSet(syncer::NIGORI)))); |
EXPECT_TRUE(fake_manager_->GetTypesWithEmptyProgressMarkerToken( |
- enabled_types_).Equals(Union(new_types, partial_types))); |
+ enabled_types_).Equals(Union(new_types, Difference( |
+ partial_types, syncer::ModelTypeSet(syncer::NIGORI))))); |
// Downloads and applies the new types and partial types (which includes |
// nigori anyways). |