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

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: 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: 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..03c81eec4453eae4d538ad5698d832131ce08df4 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());
@@ -287,14 +286,15 @@ TEST_F(SyncBackendHostTest, PartialTypes) {
// All partial types should have been purged with nothing downloaded as part
Nicolas Zea 2012/07/20 21:35:39 update comment
rlarocque 2012/07/23 20:50:30 Done.
// of bringing up the backend.
- InitializeBackend(enabled_types_);
- EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Empty());
- EXPECT_TRUE(Intersection(fake_manager_->GetAndResetCleanedTypes(),
- enabled_types_).Empty());
+ InitializeBackend();
+ EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Equals(
+ syncer::ModelTypeSet(syncer::NIGORI)));
Nicolas Zea 2012/07/20 21:35:39 Fix indents in this test and the next.
rlarocque 2012/07/20 23:20:05 My editor seems to like these indents as is. It's
+ 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.
Nicolas Zea 2012/07/20 21:35:39 this comment too
rlarocque 2012/07/20 23:20:05 Done.
@@ -317,13 +317,18 @@ 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.
Nicolas Zea 2012/07/20 21:35:39 and this
rlarocque 2012/07/23 20:50:30 Done.
- InitializeBackend(enabled_types_);
- EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Empty());
- EXPECT_TRUE(Intersection(fake_manager_->GetAndResetCleanedTypes(),
- enabled_types_).Empty());
- EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Empty());
+ 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 +346,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 +382,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 +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(),
@@ -466,10 +471,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));
@@ -506,13 +511,15 @@ TEST_F(SyncBackendHostTest, NewlySupportedTypesWithPartialTypes) {
enabled_types_.PutAll(new_types);
// Purge the partial types.
rlarocque 2012/07/23 20:50:30 Fixed this comment, too.
- 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));
+ 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).

Powered by Google App Engine
This is Rietveld 408576698