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

Unified Diff: components/sync/driver/data_type_manager_impl_unittest.cc

Issue 2448863004: [Sync] Ensure RegisterWithBackend is only called for correct types (Closed)
Patch Set: Address Sky's comments. Created 4 years, 2 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 | « components/sync/driver/data_type_manager_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b2e0c12c05679f1dd44d31ad4c4dac7742d4895f..2fd835eb2900ac247b715dcd4fd0d4adfa968c53 100644
--- a/components/sync/driver/data_type_manager_impl_unittest.cc
+++ b/components/sync/driver/data_type_manager_impl_unittest.cc
@@ -1671,7 +1671,31 @@ TEST_F(SyncDataTypeManagerImplTest, RegisterWithBackendOnEncryptionError) {
EXPECT_EQ(0, GetController(BOOKMARKS)->register_with_backend_call_count());
EXPECT_EQ(0, GetController(PASSWORDS)->register_with_backend_call_count());
- dtm_->OnAllDataTypesReadyForConfigure();
+ GetController(PASSWORDS)->SimulateModelLoadFinishing();
+ EXPECT_EQ(0, GetController(BOOKMARKS)->register_with_backend_call_count());
+ EXPECT_EQ(1, GetController(PASSWORDS)->register_with_backend_call_count());
+}
+
+// Test that RegisterWithBackend is not called for datatypes that failed
+// LoadModels().
+TEST_F(SyncDataTypeManagerImplTest, RegisterWithBackendAfterLoadModelsError) {
+ // Initiate configuration for two datatypes but block them at LoadModels.
+ AddController(BOOKMARKS, true, true);
+ AddController(PASSWORDS, true, true);
+ SetConfigureStartExpectation();
+ Configure(dtm_.get(), ModelTypeSet(BOOKMARKS, PASSWORDS));
+ EXPECT_EQ(DataTypeController::MODEL_STARTING,
+ GetController(BOOKMARKS)->state());
+ EXPECT_EQ(DataTypeController::MODEL_STARTING,
+ GetController(PASSWORDS)->state());
+
+ // Make bookmarks fail LoadModels. Passwords load normally.
+ GetController(BOOKMARKS)->SetModelLoadError(
+ SyncError(FROM_HERE, SyncError::DATATYPE_ERROR, "load error", BOOKMARKS));
+ GetController(BOOKMARKS)->SimulateModelLoadFinishing();
+ GetController(PASSWORDS)->SimulateModelLoadFinishing();
+
+ // RegisterWithBackend should be called for passwords, but not bookmarks.
EXPECT_EQ(0, GetController(BOOKMARKS)->register_with_backend_call_count());
EXPECT_EQ(1, GetController(PASSWORDS)->register_with_backend_call_count());
}
« no previous file with comments | « components/sync/driver/data_type_manager_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698