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

Unified Diff: chrome/browser/sync/glue/sync_backend_host_unittest.cc

Issue 10804039: Make SyncBackendRegistrar aware of loaded data (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase 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 | « chrome/browser/sync/glue/sync_backend_host.cc ('k') | chrome/browser/sync/glue/sync_backend_registrar.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 57d30eb842f8f1dd7e08d70d62659e04ce4d7603..dcaddef32c73255f1be80d5f3ade4849a8d325d8 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_,
@@ -211,26 +210,22 @@ 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(
syncer::ModelTypeSet(syncer::NIGORI)));
- EXPECT_TRUE(fake_manager_->GetAndResetEnabledTypes().Equals(
- syncer::ModelTypeSet(syncer::NIGORI)));
EXPECT_TRUE(fake_manager_->GetTypesWithEmptyProgressMarkerToken(
syncer::ModelTypeSet(syncer::NIGORI)).Empty());
}
// 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(
syncer::ModelTypeSet(syncer::NIGORI)));
- EXPECT_TRUE(fake_manager_->GetAndResetEnabledTypes().Equals(
- syncer::ModelTypeSet(syncer::NIGORI)));
EXPECT_TRUE(fake_manager_->GetTypesWithEmptyProgressMarkerToken(
syncer::ModelTypeSet(syncer::NIGORI)).Empty());
@@ -253,12 +248,11 @@ TEST_F(SyncBackendHostTest, Restart) {
syncer::ModelTypeSet all_but_nigori = enabled_types_;
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());
EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals(enabled_types_));
- EXPECT_TRUE(fake_manager_->GetAndResetEnabledTypes().Empty());
EXPECT_TRUE(fake_manager_->GetTypesWithEmptyProgressMarkerToken(
enabled_types_).Empty());
@@ -287,20 +281,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));
- EXPECT_TRUE(fake_manager_->GetAndResetEnabledTypes().Empty());
+ 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_),
@@ -319,16 +312,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());
- EXPECT_TRUE(fake_manager_->GetAndResetEnabledTypes().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_,
@@ -347,7 +344,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(),
@@ -358,7 +355,6 @@ TEST_F(SyncBackendHostTest, DisableTypes) {
EXPECT_TRUE(Intersection(fake_manager_->GetAndResetCleanedTypes(),
enabled_types_).Empty());
EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals(enabled_types_));
- EXPECT_TRUE(fake_manager_->GetAndResetEnabledTypes().Equals(enabled_types_));
EXPECT_TRUE(fake_manager_->GetTypesWithEmptyProgressMarkerToken(
enabled_types_).Empty());
@@ -385,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(),
@@ -396,7 +392,6 @@ TEST_F(SyncBackendHostTest, AddTypes) {
EXPECT_TRUE(Intersection(fake_manager_->GetAndResetCleanedTypes(),
enabled_types_).Empty());
EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals(enabled_types_));
- EXPECT_TRUE(fake_manager_->GetAndResetEnabledTypes().Equals(enabled_types_));
EXPECT_TRUE(fake_manager_->GetTypesWithEmptyProgressMarkerToken(
enabled_types_).Empty());
@@ -424,7 +419,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(),
@@ -435,7 +430,6 @@ TEST_F(SyncBackendHostTest, AddDisableTypes) {
EXPECT_TRUE(Intersection(fake_manager_->GetAndResetCleanedTypes(),
enabled_types_).Empty());
EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals(enabled_types_));
- EXPECT_TRUE(fake_manager_->GetAndResetEnabledTypes().Equals(enabled_types_));
EXPECT_TRUE(fake_manager_->GetTypesWithEmptyProgressMarkerToken(
enabled_types_).Empty());
@@ -478,12 +472,11 @@ 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_->GetAndResetEnabledTypes().Empty());
EXPECT_TRUE(fake_manager_->GetTypesWithEmptyProgressMarkerToken(
enabled_types_).Equals(new_types));
@@ -519,15 +512,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));
- EXPECT_TRUE(fake_manager_->GetAndResetEnabledTypes().Empty());
+ // 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).
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_host.cc ('k') | chrome/browser/sync/glue/sync_backend_registrar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698