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

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

Issue 2360283003: [Sync] When a data type is not initialized, also should not be registered with backend. (Closed)
Patch Set: Back to member variable, since as Pavel pointed out, the status map can change. Created 4 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
« 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 186f2f9cf38fbcc997778ecfd104d33dd86aad07..ce74a49acf020294a14fda28ca94ce1e98f67787 100644
--- a/components/sync/driver/data_type_manager_impl_unittest.cc
+++ b/components/sync/driver/data_type_manager_impl_unittest.cc
@@ -314,6 +314,18 @@ class SyncDataTypeManagerImplTest : public testing::Test {
base::MakeUnique<FakeDataTypeController>(model_type);
}
+ // Convenience method to create a controller and set some parameters.
+ void AddController(ModelType model_type,
+ bool should_load_model_before_configure,
+ bool should_delay_model_load) {
+ AddController(model_type);
+ GetController(model_type)
+ ->SetShouldLoadModelBeforeConfigure(should_load_model_before_configure);
+ if (should_delay_model_load) {
+ GetController(model_type)->SetDelayModelLoad();
+ }
+ }
+
// Gets the fake controller for the given type, which should have
// been previously added via AddController().
FakeDataTypeController* GetController(ModelType model_type) const {
@@ -1629,11 +1641,9 @@ TEST_F(SyncDataTypeManagerImplTest, CatchUpMultipleConfigureCalls) {
}
// Test that DataTypeManagerImpl delays configuration until all datatypes for
-// which ShouldLoadModelBeforeConfigure() returns true loaded their models.
+// which ShouldLoadModelBeforeConfigure() returns true loaded their models.
TEST_F(SyncDataTypeManagerImplTest, DelayConfigureForUSSTypes) {
- AddController(BOOKMARKS);
- GetController(BOOKMARKS)->SetShouldLoadModelBeforeConfigure(true);
- GetController(BOOKMARKS)->SetDelayModelLoad();
+ AddController(BOOKMARKS, true, true);
SetConfigureStartExpectation();
SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
@@ -1659,4 +1669,25 @@ TEST_F(SyncDataTypeManagerImplTest, DelayConfigureForUSSTypes) {
EXPECT_EQ(1U, configurer_.activated_types().Size());
}
+// Test that when encryption fails for a given type, the corresponding
+// controller is not told to register with its backend.
+TEST_F(SyncDataTypeManagerImplTest, RegisterWithBackendOnEncryptionError) {
+ AddController(BOOKMARKS, true, true);
+ AddController(PASSWORDS, true, true);
+ SetConfigureStartExpectation();
+
+ FailEncryptionFor(ModelTypeSet(BOOKMARKS));
+ Configure(dtm_.get(), ModelTypeSet(BOOKMARKS, PASSWORDS));
+ EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
+ EXPECT_EQ(DataTypeController::NOT_RUNNING, GetController(BOOKMARKS)->state());
+ EXPECT_EQ(DataTypeController::MODEL_STARTING,
+ GetController(PASSWORDS)->state());
+ EXPECT_EQ(0, GetController(BOOKMARKS)->register_with_backend_call_count());
+ EXPECT_EQ(0, GetController(PASSWORDS)->register_with_backend_call_count());
+
+ dtm_->OnAllDataTypesReadyForConfigure();
+ EXPECT_EQ(0, GetController(BOOKMARKS)->register_with_backend_call_count());
+ EXPECT_EQ(1, GetController(PASSWORDS)->register_with_backend_call_count());
+}
+
} // namespace sync_driver
« 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