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

Unified Diff: components/sync_driver/data_type_manager_impl_unittest.cc

Issue 585643003: [Sync] Fix error handling during startup scenarios (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test Created 6 years, 3 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: components/sync_driver/data_type_manager_impl_unittest.cc
diff --git a/components/sync_driver/data_type_manager_impl_unittest.cc b/components/sync_driver/data_type_manager_impl_unittest.cc
index c4d2ec2542f779006445bbce2368b3f79c3d69ea..c2e32f792c09cf95f50fb70d483302a21e0c3b80 100644
--- a/components/sync_driver/data_type_manager_impl_unittest.cc
+++ b/components/sync_driver/data_type_manager_impl_unittest.cc
@@ -44,24 +44,30 @@ DataTypeStatusTable BuildStatusTable(ModelTypeSet crypto_errors,
DataTypeStatusTable::TypeErrorMap error_map;
for (ModelTypeSet::Iterator iter = crypto_errors.First(); iter.Good();
iter.Inc()) {
- error_map[iter.Get()] = SyncError(
- FROM_HERE, SyncError::CRYPTO_ERROR, "crypto error", iter.Get());
+ error_map[iter.Get()] = SyncError(FROM_HERE,
+ SyncError::CRYPTO_ERROR,
+ "crypto error expected",
+ iter.Get());
}
for (ModelTypeSet::Iterator iter = association_errors.First(); iter.Good();
iter.Inc()) {
- error_map[iter.Get()] = SyncError(
- FROM_HERE, SyncError::DATATYPE_ERROR, "association error", iter.Get());
+ error_map[iter.Get()] = SyncError(FROM_HERE,
+ SyncError::DATATYPE_ERROR,
+ "association error expected",
+ iter.Get());
}
for (ModelTypeSet::Iterator iter = unready_errors.First(); iter.Good();
iter.Inc()) {
- error_map[iter.Get()] = SyncError(
- FROM_HERE, SyncError::UNREADY_ERROR, "unready errors", iter.Get());
+ error_map[iter.Get()] = SyncError(FROM_HERE,
+ SyncError::UNREADY_ERROR,
+ "unready error expected",
+ iter.Get());
}
for (ModelTypeSet::Iterator iter = unrecoverable_errors.First(); iter.Good();
iter.Inc()) {
error_map[iter.Get()] = SyncError(FROM_HERE,
SyncError::UNRECOVERABLE_ERROR,
- "unrecoverable errors",
+ "unrecoverable error expected",
iter.Get());
}
DataTypeStatusTable status_table;
@@ -1334,4 +1340,52 @@ TEST_F(SyncDataTypeManagerImplTest, UnreadyType) {
EXPECT_TRUE(configurer_.activated_types().Empty());
}
+TEST_F(SyncDataTypeManagerImplTest, ModelLoadError) {
+ AddController(BOOKMARKS);
+ GetController(BOOKMARKS)->SetModelLoadError(syncer::SyncError(
+ FROM_HERE, SyncError::DATATYPE_ERROR, "load error", BOOKMARKS));
+
+ // Bookmarks is never started due to hitting a model load error.
+ SetConfigureStartExpectation();
+ SetConfigureDoneExpectation(DataTypeManager::OK,
+ BuildStatusTable(ModelTypeSet(),
+ ModelTypeSet(BOOKMARKS),
+ ModelTypeSet(),
+ ModelTypeSet()));
+ Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
+ FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
+ FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
+ EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
+ EXPECT_EQ(DataTypeController::NOT_RUNNING, GetController(BOOKMARKS)->state());
+
+ EXPECT_EQ(0U, configurer_.activated_types().Size());
+}
+
+
+TEST_F(SyncDataTypeManagerImplTest, ErrorBeforeAssociation) {
+ AddController(BOOKMARKS);
+
+ // Bookmarks is never started due to hitting a datatype error while the DTM
+ // is still downloading types.
+ SetConfigureStartExpectation();
+ SetConfigureDoneExpectation(DataTypeManager::OK,
+ BuildStatusTable(ModelTypeSet(),
+ ModelTypeSet(BOOKMARKS),
+ ModelTypeSet(),
+ ModelTypeSet()));
+ Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
+ FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
+ GetController(BOOKMARKS)->OnSingleDataTypeUnrecoverableError(
+ syncer::SyncError(FROM_HERE,
+ SyncError::DATATYPE_ERROR,
+ "bookmarks error",
+ BOOKMARKS));
+ FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
+ FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet()); // Reconfig for error.
+ EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
+ EXPECT_EQ(DataTypeController::NOT_RUNNING, GetController(BOOKMARKS)->state());
+
+ EXPECT_EQ(0U, configurer_.activated_types().Size());
+}
+
} // namespace sync_driver
« no previous file with comments | « components/sync_driver/data_type_manager_impl.cc ('k') | components/sync_driver/fake_data_type_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698