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

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

Issue 2563423005: [Sync] Move ConfigureDataTypes logic into DataTypeManagerImpl. (Closed)
Patch Set: Rebase on Pavel's change. Created 3 years, 11 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 039443fca303c882ad430db60442119debfb314f..46e16f7bb1b9ab63d16ba01d6d29de110e6ed2b6 100644
--- a/components/sync/driver/data_type_manager_impl_unittest.cc
+++ b/components/sync/driver/data_type_manager_impl_unittest.cc
@@ -22,7 +22,13 @@ namespace syncer {
namespace {
-// Helper for unioning with control types.
+// Helpers for unioning with control types.
+ModelTypeSet AddControlTypesTo(ModelType type) {
+ ModelTypeSet result = ControlTypes();
+ result.Put(type);
+ return result;
skym 2017/01/05 00:42:11 Could this just return Union(ControlTypes(), Model
maxbogue 2017/01/06 18:55:58 Done.
+}
+
ModelTypeSet AddControlTypesTo(ModelTypeSet types) {
skym 2017/01/05 00:42:11 While you're in here, this should use Union() as w
maxbogue 2017/01/06 18:55:58 Done.
ModelTypeSet result = ControlTypes();
result.PutAll(types);
@@ -64,29 +70,12 @@ DataTypeStatusTable BuildStatusTable(ModelTypeSet crypto_errors,
// callback passed into ConfigureDataTypes.
class FakeModelTypeConfigurer : public ModelTypeConfigurer {
public:
- FakeModelTypeConfigurer() : configure_call_count_(0) {}
+ FakeModelTypeConfigurer() {}
~FakeModelTypeConfigurer() override {}
- ModelTypeSet ConfigureDataTypes(
- ConfigureReason reason,
- const DataTypeConfigStateMap& config_state_map,
- const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task,
- const base::Callback<void()>& retry_callback) override {
+ void ConfigureDataTypes(ConfigureParams params) override {
configure_call_count_++;
- last_ready_task_ = ready_task;
-
- for (auto iter = expected_configure_types_.begin();
- iter != expected_configure_types_.end(); ++iter) {
- if (!iter->second.Empty()) {
- EXPECT_EQ(iter->second,
- GetDataTypesInState(iter->first, config_state_map))
- << "State " << iter->first << " : "
- << ModelTypeSetToString(iter->second) << " v.s. "
- << ModelTypeSetToString(
- GetDataTypesInState(iter->first, config_state_map));
- }
- }
- return ready_types_;
+ last_params_ = std::move(params);
}
void ActivateDirectoryDataType(ModelType type,
@@ -94,6 +83,7 @@ class FakeModelTypeConfigurer : public ModelTypeConfigurer {
ChangeProcessor* change_processor) override {
activated_types_.Put(type);
}
+
skym 2017/01/05 00:42:11 Fighting the good fight!
maxbogue 2017/01/06 18:55:58 \o/
void DeactivateDirectoryDataType(ModelType type) override {
activated_types_.Remove(type);
}
@@ -108,27 +98,16 @@ class FakeModelTypeConfigurer : public ModelTypeConfigurer {
// TODO(stanisc): crbug.com/515962: Add test coverage.
}
- base::Callback<void(ModelTypeSet, ModelTypeSet)> last_ready_task() const {
- return last_ready_task_;
- }
-
- void set_expected_configure_types(DataTypeConfigState config_state,
- ModelTypeSet types) {
- expected_configure_types_[config_state] = types;
- }
-
- void set_ready_types(ModelTypeSet types) { ready_types_ = types; }
-
const ModelTypeSet activated_types() { return activated_types_; }
int configure_call_count() const { return configure_call_count_; }
+ const ConfigureParams& last_params() const { return last_params_; }
+
private:
- base::Callback<void(ModelTypeSet, ModelTypeSet)> last_ready_task_;
- std::map<DataTypeConfigState, ModelTypeSet> expected_configure_types_;
ModelTypeSet activated_types_;
- ModelTypeSet ready_types_;
- int configure_call_count_;
+ int configure_call_count_ = 0;
+ ConfigureParams last_params_;
};
// DataTypeManagerObserver implementation.
@@ -217,13 +196,12 @@ ModelTypeSet FakeDataTypeEncryptionHandler::GetEncryptedDataTypes() const {
class TestDataTypeManager : public DataTypeManagerImpl {
public:
TestDataTypeManager(
- ModelTypeSet initial_types,
const WeakHandle<DataTypeDebugInfoListener>& debug_info_listener,
ModelTypeConfigurer* configurer,
const DataTypeController::TypeMap* controllers,
const DataTypeEncryptionHandler* encryption_handler,
DataTypeManagerObserver* observer)
- : DataTypeManagerImpl(initial_types,
+ : DataTypeManagerImpl(ModelTypeSet(),
debug_info_listener,
controllers,
encryption_handler,
@@ -245,11 +223,16 @@ class TestDataTypeManager : public DataTypeManagerImpl {
DataTypeManagerImpl::OnModelAssociationDone(result);
}
- private:
+ void set_engine_types(ModelTypeSet engine_types) {
+ engine_types_ = engine_types;
+ }
+
+ protected:
ModelTypeSet GetPriorityTypes() const override {
return custom_priority_types_;
}
+ private:
ModelTypeSet custom_priority_types_;
DataTypeManager::ConfigureResult configure_result_;
};
@@ -265,8 +248,8 @@ class SyncDataTypeManagerImplTest : public testing::Test {
protected:
void SetUp() override {
dtm_ = base::MakeUnique<TestDataTypeManager>(
- ModelTypeSet(), WeakHandle<DataTypeDebugInfoListener>(), &configurer_,
- &controllers_, &encryption_handler_, &observer_);
+ WeakHandle<DataTypeDebugInfoListener>(), &configurer_, &controllers_,
+ &encryption_handler_, &observer_);
}
void SetConfigureStartExpectation() { observer_.ExpectStart(); }
@@ -280,18 +263,17 @@ class SyncDataTypeManagerImplTest : public testing::Test {
}
// Configure the given DTM with the given desired types.
- void Configure(DataTypeManagerImpl* dtm, const ModelTypeSet& desired_types) {
- dtm->Configure(desired_types, CONFIGURE_REASON_RECONFIGURATION);
+ void Configure(ModelTypeSet desired_types) {
+ dtm_->Configure(desired_types, CONFIGURE_REASON_RECONFIGURATION);
}
// Finish downloading for the given DTM. Should be done only after
// a call to Configure().
- void FinishDownload(const DataTypeManager& dtm,
- ModelTypeSet types_to_configure,
+ void FinishDownload(ModelTypeSet types_to_configure,
ModelTypeSet failed_download_types) {
- EXPECT_EQ(DataTypeManager::CONFIGURING, dtm.state());
- ASSERT_FALSE(configurer_.last_ready_task().is_null());
- configurer_.last_ready_task().Run(
+ EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
+ ASSERT_FALSE(last_configure_params().ready_task.is_null());
+ last_configure_params().ready_task.Run(
Difference(types_to_configure, failed_download_types),
failed_download_types);
}
@@ -331,6 +313,10 @@ class SyncDataTypeManagerImplTest : public testing::Test {
encryption_handler_.set_encrypted_types(encrypted_types);
}
+ const ModelTypeConfigurer::ConfigureParams& last_configure_params() const {
+ return configurer_.last_params();
+ }
+
base::MessageLoopForUI ui_loop_;
DataTypeController::TypeMap controllers_;
FakeModelTypeConfigurer configurer_;
@@ -345,10 +331,10 @@ TEST_F(SyncDataTypeManagerImplTest, NoControllers) {
SetConfigureStartExpectation();
SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
- Configure(dtm_.get(), ModelTypeSet());
+ Configure(ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
dtm_->Stop();
@@ -363,11 +349,11 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureOne) {
SetConfigureStartExpectation();
SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
+ Configure(ModelTypeSet(BOOKMARKS));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
GetController(BOOKMARKS)->FinishStart(DataTypeController::OK);
@@ -390,14 +376,15 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureOneStopWhileDownloadPending) {
SetConfigureDoneExpectation(DataTypeManager::ABORTED,
DataTypeStatusTable());
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
+ Configure(ModelTypeSet(BOOKMARKS));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
dtm_->Stop();
EXPECT_EQ(DataTypeManager::STOPPED, dtm_->state());
}
- configurer_.last_ready_task().Run(ModelTypeSet(BOOKMARKS), ModelTypeSet());
+ last_configure_params().ready_task.Run(ModelTypeSet(BOOKMARKS),
+ ModelTypeSet());
EXPECT_TRUE(configurer_.activated_types().Empty());
}
@@ -413,11 +400,11 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureOneStopWhileStartingModel) {
SetConfigureDoneExpectation(DataTypeManager::ABORTED,
DataTypeStatusTable());
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
+ Configure(ModelTypeSet(BOOKMARKS));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
dtm_->Stop();
@@ -442,11 +429,11 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureOneStopWhileAssociating) {
SetConfigureDoneExpectation(DataTypeManager::ABORTED,
DataTypeStatusTable());
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
+ Configure(ModelTypeSet(BOOKMARKS));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
EXPECT_TRUE(configurer_.activated_types().Empty());
@@ -479,11 +466,11 @@ TEST_F(SyncDataTypeManagerImplTest, OneWaitingForCrypto) {
dtm_->set_priority_types(AddControlTypesTo(types));
// Step 1.
- Configure(dtm_.get(), types);
+ Configure(types);
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Step 2.
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Step 3.
@@ -492,7 +479,7 @@ TEST_F(SyncDataTypeManagerImplTest, OneWaitingForCrypto) {
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Step 4.
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
// Step 5.
@@ -517,12 +504,12 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureOneThenBoth) {
SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
// Step 1.
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
+ Configure(ModelTypeSet(BOOKMARKS));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Step 2.
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Step 3.
@@ -534,12 +521,12 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureOneThenBoth) {
SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
// Step 4.
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS, PREFERENCES));
+ Configure(ModelTypeSet(BOOKMARKS, PREFERENCES));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Step 5.
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS, PREFERENCES), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS, PREFERENCES), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Step 6.
@@ -570,12 +557,12 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureOneThenSwitch) {
SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
// Step 1.
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
+ Configure(ModelTypeSet(BOOKMARKS));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Step 2.
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Step 3.
@@ -587,12 +574,12 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureOneThenSwitch) {
SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
// Step 4.
- Configure(dtm_.get(), ModelTypeSet(PREFERENCES));
+ Configure(ModelTypeSet(PREFERENCES));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Step 5.
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
- FinishDownload(*dtm_, ModelTypeSet(PREFERENCES), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(PREFERENCES), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Step 6.
@@ -623,16 +610,16 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureWhileOneInFlight) {
SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
// Step 1.
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
+ Configure(ModelTypeSet(BOOKMARKS));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Step 2.
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Step 3.
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS, PREFERENCES));
+ Configure(ModelTypeSet(BOOKMARKS, PREFERENCES));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Step 4.
@@ -640,8 +627,8 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureWhileOneInFlight) {
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Step 5.
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS, PREFERENCES), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS, PREFERENCES), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Step 6.
@@ -667,11 +654,11 @@ TEST_F(SyncDataTypeManagerImplTest, OneFailingController) {
BuildStatusTable(ModelTypeSet(), ModelTypeSet(), ModelTypeSet(),
ModelTypeSet(BOOKMARKS)));
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
+ Configure(ModelTypeSet(BOOKMARKS));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
EXPECT_TRUE(configurer_.activated_types().Empty());
@@ -700,12 +687,12 @@ TEST_F(SyncDataTypeManagerImplTest, SecondControllerFails) {
ModelTypeSet(PREFERENCES)));
// Step 1.
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS, PREFERENCES));
+ Configure(ModelTypeSet(BOOKMARKS, PREFERENCES));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Step 2.
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS, PREFERENCES), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS, PREFERENCES), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Step 3.
@@ -742,12 +729,12 @@ TEST_F(SyncDataTypeManagerImplTest, OneControllerFailsAssociation) {
ModelTypeSet(), ModelTypeSet()));
// Step 1.
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS, PREFERENCES));
+ Configure(ModelTypeSet(BOOKMARKS, PREFERENCES));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Step 2.
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS, PREFERENCES), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS, PREFERENCES), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Step 3.
@@ -760,8 +747,8 @@ TEST_F(SyncDataTypeManagerImplTest, OneControllerFailsAssociation) {
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Step 5.
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
EXPECT_EQ(1U, configurer_.activated_types().Size());
@@ -787,20 +774,20 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureWhileDownloadPending) {
SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
// Step 1.
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
+ Configure(ModelTypeSet(BOOKMARKS));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Step 2.
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS, PREFERENCES));
+ Configure(ModelTypeSet(BOOKMARKS, PREFERENCES));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Step 3.
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Step 4.
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS, PREFERENCES), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS, PREFERENCES), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Step 5.
@@ -833,21 +820,21 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureWhileDownloadPendingWithFailure) {
SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
// Step 1.
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
+ Configure(ModelTypeSet(BOOKMARKS));
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Step 2.
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS, PREFERENCES));
+ Configure(ModelTypeSet(BOOKMARKS, PREFERENCES));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Step 3.
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Step 4.
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS, PREFERENCES), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS, PREFERENCES), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Step 5.
@@ -865,14 +852,14 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureWhileDownloadPendingWithFailure) {
// operations that would be invoked by the BackendMigrator.
TEST_F(SyncDataTypeManagerImplTest, MigrateAll) {
AddController(BOOKMARKS);
- dtm_->set_priority_types(AddControlTypesTo(ModelTypeSet(BOOKMARKS)));
+ dtm_->set_priority_types(AddControlTypesTo(BOOKMARKS));
SetConfigureStartExpectation();
SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
// Initial setup.
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
+ Configure(ModelTypeSet(BOOKMARKS));
+ FinishDownload(ModelTypeSet(BOOKMARKS), ModelTypeSet());
GetController(BOOKMARKS)->FinishStart(DataTypeController::OK);
// We've now configured bookmarks and (implicitly) the control types.
@@ -890,15 +877,15 @@ TEST_F(SyncDataTypeManagerImplTest, MigrateAll) {
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// The DTM will call ConfigureDataTypes(), even though it is unnecessary.
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
observer_.ResetExpectations();
// Re-enable the migrated types.
SetConfigureStartExpectation();
SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
- Configure(dtm_.get(), to_migrate);
- FinishDownload(*dtm_, to_migrate, ModelTypeSet());
+ Configure(to_migrate);
+ FinishDownload(to_migrate, ModelTypeSet());
GetController(BOOKMARKS)->FinishStart(DataTypeController::OK);
EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
}
@@ -911,9 +898,9 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureDuringPurge) {
// Initial configure.
SetConfigureStartExpectation();
SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
+ Configure(ModelTypeSet(BOOKMARKS));
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS), ModelTypeSet());
GetController(BOOKMARKS)->FinishStart(DataTypeController::OK);
EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
observer_.ResetExpectations();
@@ -930,19 +917,19 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureDuringPurge) {
// - PREFERENCES: which is new and will need to be downloaded, and
// - NIGORI: (added implicitly because it is a control type) which
// the DTM is part-way through purging.
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS, PREFERENCES));
+ Configure(ModelTypeSet(BOOKMARKS, PREFERENCES));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Invoke the callback we've been waiting for since we asked to purge NIGORI.
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
observer_.ResetExpectations();
SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Now invoke the callback for the second configure request.
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS, PREFERENCES), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS, PREFERENCES), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Start the preferences controller. We don't need to start controller for
@@ -956,26 +943,25 @@ TEST_F(SyncDataTypeManagerImplTest, PrioritizedConfiguration) {
AddController(BOOKMARKS);
AddController(PREFERENCES);
- dtm_->set_priority_types(AddControlTypesTo(ModelTypeSet(PREFERENCES)));
+ dtm_->set_priority_types(AddControlTypesTo(PREFERENCES));
// Initial configure.
SetConfigureStartExpectation();
SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
- // Initially only PREFERENCES is configured.
- configurer_.set_expected_configure_types(
- ModelTypeConfigurer::CONFIGURE_ACTIVE,
- AddControlTypesTo(ModelTypeSet(PREFERENCES)));
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS, PREFERENCES));
+ // Initially only PREFERENCES is downloaded.
+ Configure(ModelTypeSet(BOOKMARKS, PREFERENCES));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
+ EXPECT_EQ(AddControlTypesTo(PREFERENCES),
+ last_configure_params().to_download);
- // BOOKMARKS is configured after download of PREFERENCES finishes.
- configurer_.set_expected_configure_types(
- ModelTypeConfigurer::CONFIGURE_ACTIVE, ModelTypeSet(BOOKMARKS));
- FinishDownload(*dtm_, ModelTypeSet(PREFERENCES), ModelTypeSet());
+ // BOOKMARKS is downloaded after PREFERENCES finishes.
+ FinishDownload(ModelTypeSet(PREFERENCES), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
+ EXPECT_EQ(ModelTypeSet(BOOKMARKS, NIGORI),
+ last_configure_params().to_download);
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS), ModelTypeSet());
GetController(PREFERENCES)->FinishStart(DataTypeController::OK);
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
@@ -988,43 +974,39 @@ TEST_F(SyncDataTypeManagerImplTest, PrioritizedConfigurationReconfigure) {
AddController(PREFERENCES);
AddController(APPS);
- dtm_->set_priority_types(AddControlTypesTo(ModelTypeSet(PREFERENCES)));
+ dtm_->set_priority_types(AddControlTypesTo(PREFERENCES));
// Initial configure.
SetConfigureStartExpectation();
SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
// Reconfigure while associating PREFERENCES and downloading BOOKMARKS.
- configurer_.set_expected_configure_types(
- ModelTypeConfigurer::CONFIGURE_ACTIVE,
- AddControlTypesTo(ModelTypeSet(PREFERENCES)));
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS, PREFERENCES));
+ Configure(ModelTypeSet(BOOKMARKS, PREFERENCES));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
+ EXPECT_EQ(AddControlTypesTo(PREFERENCES),
+ last_configure_params().to_download);
- configurer_.set_expected_configure_types(
- ModelTypeConfigurer::CONFIGURE_ACTIVE, ModelTypeSet(BOOKMARKS));
- FinishDownload(*dtm_, ModelTypeSet(PREFERENCES), ModelTypeSet());
+ FinishDownload(ModelTypeSet(PREFERENCES), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
+ EXPECT_EQ(ModelTypeSet(BOOKMARKS, NIGORI),
+ last_configure_params().to_download);
// Enable syncing for APPS.
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS, PREFERENCES, APPS));
+ Configure(ModelTypeSet(BOOKMARKS, PREFERENCES, APPS));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Reconfiguration starts after downloading and association of previous
// types finish.
- configurer_.set_expected_configure_types(
- ModelTypeConfigurer::CONFIGURE_ACTIVE,
- AddControlTypesTo(ModelTypeSet(PREFERENCES)));
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS), ModelTypeSet());
GetController(PREFERENCES)->FinishStart(DataTypeController::OK);
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
+ EXPECT_EQ(ModelTypeSet(), last_configure_params().to_download);
- configurer_.set_expected_configure_types(
- ModelTypeConfigurer::CONFIGURE_ACTIVE, ModelTypeSet(BOOKMARKS, APPS));
- FinishDownload(*dtm_, ModelTypeSet(PREFERENCES), ModelTypeSet());
+ FinishDownload(ModelTypeSet(PREFERENCES), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
+ EXPECT_EQ(ModelTypeSet(APPS, NIGORI), last_configure_params().to_download);
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS, APPS), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS, APPS), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Skip calling FinishStart() for PREFENCES because it's already started in
@@ -1038,24 +1020,23 @@ TEST_F(SyncDataTypeManagerImplTest, PrioritizedConfigurationStop) {
AddController(BOOKMARKS);
AddController(PREFERENCES);
- dtm_->set_priority_types(AddControlTypesTo(ModelTypeSet(PREFERENCES)));
+ dtm_->set_priority_types(AddControlTypesTo(PREFERENCES));
// Initial configure.
SetConfigureStartExpectation();
SetConfigureDoneExpectation(DataTypeManager::ABORTED, DataTypeStatusTable());
// Initially only PREFERENCES is configured.
- configurer_.set_expected_configure_types(
- ModelTypeConfigurer::CONFIGURE_ACTIVE,
- AddControlTypesTo(ModelTypeSet(PREFERENCES)));
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS, PREFERENCES));
+ Configure(ModelTypeSet(BOOKMARKS, PREFERENCES));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
+ EXPECT_EQ(AddControlTypesTo(PREFERENCES),
+ last_configure_params().to_download);
// BOOKMARKS is configured after download of PREFERENCES finishes.
- configurer_.set_expected_configure_types(
- ModelTypeConfigurer::CONFIGURE_ACTIVE, ModelTypeSet(BOOKMARKS));
- FinishDownload(*dtm_, ModelTypeSet(PREFERENCES), ModelTypeSet());
+ FinishDownload(ModelTypeSet(PREFERENCES), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
+ EXPECT_EQ(ModelTypeSet(BOOKMARKS, NIGORI),
+ last_configure_params().to_download);
// PREFERENCES controller is associating while BOOKMARKS is downloading.
EXPECT_EQ(DataTypeController::ASSOCIATING,
@@ -1074,7 +1055,7 @@ TEST_F(SyncDataTypeManagerImplTest, PrioritizedConfigurationDownloadError) {
AddController(BOOKMARKS);
AddController(PREFERENCES);
- dtm_->set_priority_types(AddControlTypesTo(ModelTypeSet(PREFERENCES)));
+ dtm_->set_priority_types(AddControlTypesTo(PREFERENCES));
// Initial configure. Bookmarks will fail to associate due to the download
// failure.
@@ -1085,17 +1066,16 @@ TEST_F(SyncDataTypeManagerImplTest, PrioritizedConfigurationDownloadError) {
ModelTypeSet()));
// Initially only PREFERENCES is configured.
- configurer_.set_expected_configure_types(
- ModelTypeConfigurer::CONFIGURE_ACTIVE,
- AddControlTypesTo(ModelTypeSet(PREFERENCES)));
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS, PREFERENCES));
+ Configure(ModelTypeSet(BOOKMARKS, PREFERENCES));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
+ EXPECT_EQ(AddControlTypesTo(PREFERENCES),
+ last_configure_params().to_download);
// BOOKMARKS is configured after download of PREFERENCES finishes.
- configurer_.set_expected_configure_types(
- ModelTypeConfigurer::CONFIGURE_ACTIVE, ModelTypeSet(BOOKMARKS));
- FinishDownload(*dtm_, ModelTypeSet(PREFERENCES), ModelTypeSet());
+ FinishDownload(ModelTypeSet(PREFERENCES), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
+ EXPECT_EQ(ModelTypeSet(BOOKMARKS, NIGORI),
+ last_configure_params().to_download);
// PREFERENCES controller is associating while BOOKMARKS is downloading.
EXPECT_EQ(DataTypeController::ASSOCIATING,
@@ -1104,19 +1084,17 @@ TEST_F(SyncDataTypeManagerImplTest, PrioritizedConfigurationDownloadError) {
GetController(BOOKMARKS)->state());
// Make BOOKMARKS download fail. Preferences is still associating.
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet(BOOKMARKS));
+ FinishDownload(ModelTypeSet(), ModelTypeSet(BOOKMARKS));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
EXPECT_EQ(DataTypeController::ASSOCIATING,
GetController(PREFERENCES)->state());
// Finish association of PREFERENCES. This will trigger a reconfiguration to
// disable bookmarks.
- configurer_.set_expected_configure_types(
- ModelTypeConfigurer::CONFIGURE_ACTIVE,
- AddControlTypesTo(ModelTypeSet(PREFERENCES)));
GetController(PREFERENCES)->FinishStart(DataTypeController::OK);
- FinishDownload(*dtm_, ModelTypeSet(PREFERENCES), ModelTypeSet());
+ FinishDownload(ModelTypeSet(PREFERENCES), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
+ EXPECT_EQ(ModelTypeSet(), last_configure_params().to_download);
EXPECT_EQ(DataTypeController::RUNNING, GetController(PREFERENCES)->state());
EXPECT_EQ(DataTypeController::NOT_RUNNING, GetController(BOOKMARKS)->state());
}
@@ -1125,7 +1103,7 @@ TEST_F(SyncDataTypeManagerImplTest, HighPriorityAssociationFailure) {
AddController(PREFERENCES); // Will fail.
AddController(BOOKMARKS); // Will succeed.
- dtm_->set_priority_types(AddControlTypesTo(ModelTypeSet(PREFERENCES)));
+ dtm_->set_priority_types(AddControlTypesTo(PREFERENCES));
// Initial configure.
SetConfigureStartExpectation();
@@ -1135,17 +1113,16 @@ TEST_F(SyncDataTypeManagerImplTest, HighPriorityAssociationFailure) {
ModelTypeSet(), ModelTypeSet()));
// Initially only PREFERENCES is configured.
- configurer_.set_expected_configure_types(
- ModelTypeConfigurer::CONFIGURE_ACTIVE,
- AddControlTypesTo(ModelTypeSet(PREFERENCES)));
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS, PREFERENCES));
+ Configure(ModelTypeSet(BOOKMARKS, PREFERENCES));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
+ EXPECT_EQ(AddControlTypesTo(PREFERENCES),
+ last_configure_params().to_download);
// BOOKMARKS is configured after download of PREFERENCES finishes.
- configurer_.set_expected_configure_types(
- ModelTypeConfigurer::CONFIGURE_ACTIVE, ModelTypeSet(BOOKMARKS));
- FinishDownload(*dtm_, ModelTypeSet(PREFERENCES), ModelTypeSet());
+ FinishDownload(ModelTypeSet(PREFERENCES), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
+ EXPECT_EQ(ModelTypeSet(BOOKMARKS, NIGORI),
+ last_configure_params().to_download);
// PREFERENCES controller is associating while BOOKMARKS is downloading.
EXPECT_EQ(DataTypeController::ASSOCIATING,
@@ -1160,15 +1137,11 @@ TEST_F(SyncDataTypeManagerImplTest, HighPriorityAssociationFailure) {
// Reconfigure without PREFERENCES after the BOOKMARKS download completes,
// then reconfigure with BOOKMARKS.
- configurer_.set_expected_configure_types(
- ModelTypeConfigurer::CONFIGURE_ACTIVE, ControlTypes());
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
- configurer_.set_expected_configure_types(
- ModelTypeConfigurer::CONFIGURE_ACTIVE, ModelTypeSet(BOOKMARKS));
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
// Reconfigure with BOOKMARKS.
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS), ModelTypeSet());
EXPECT_EQ(DataTypeController::ASSOCIATING, GetController(BOOKMARKS)->state());
GetController(BOOKMARKS)->FinishStart(DataTypeController::OK);
@@ -1182,7 +1155,7 @@ TEST_F(SyncDataTypeManagerImplTest, LowPriorityAssociationFailure) {
AddController(PREFERENCES); // Will succeed.
AddController(BOOKMARKS); // Will fail.
- dtm_->set_priority_types(AddControlTypesTo(ModelTypeSet(PREFERENCES)));
+ dtm_->set_priority_types(AddControlTypesTo(PREFERENCES));
// Initial configure.
SetConfigureStartExpectation();
@@ -1192,17 +1165,16 @@ TEST_F(SyncDataTypeManagerImplTest, LowPriorityAssociationFailure) {
ModelTypeSet()));
// Initially only PREFERENCES is configured.
- configurer_.set_expected_configure_types(
- ModelTypeConfigurer::CONFIGURE_ACTIVE,
- AddControlTypesTo(ModelTypeSet(PREFERENCES)));
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS, PREFERENCES));
+ Configure(ModelTypeSet(BOOKMARKS, PREFERENCES));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
+ EXPECT_EQ(AddControlTypesTo(PREFERENCES),
+ last_configure_params().to_download);
// BOOKMARKS is configured after download of PREFERENCES finishes.
- configurer_.set_expected_configure_types(
- ModelTypeConfigurer::CONFIGURE_ACTIVE, ModelTypeSet(BOOKMARKS));
- FinishDownload(*dtm_, ModelTypeSet(PREFERENCES), ModelTypeSet());
+ FinishDownload(ModelTypeSet(PREFERENCES), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
+ EXPECT_EQ(ModelTypeSet(BOOKMARKS, NIGORI),
+ last_configure_params().to_download);
// PREFERENCES controller is associating while BOOKMARKS is downloading.
EXPECT_EQ(DataTypeController::ASSOCIATING,
@@ -1211,24 +1183,20 @@ TEST_F(SyncDataTypeManagerImplTest, LowPriorityAssociationFailure) {
GetController(BOOKMARKS)->state());
// BOOKMARKS finishes downloading and PREFERENCES finishes associating.
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS), ModelTypeSet());
GetController(PREFERENCES)->FinishStart(DataTypeController::OK);
EXPECT_EQ(DataTypeController::RUNNING, GetController(PREFERENCES)->state());
// Make BOOKMARKS association fail, which triggers reconfigure with only
// PREFERENCES.
- configurer_.set_expected_configure_types(
- ModelTypeConfigurer::CONFIGURE_ACTIVE,
- AddControlTypesTo(ModelTypeSet(PREFERENCES)));
GetController(BOOKMARKS)->FinishStart(DataTypeController::ASSOCIATION_FAILED);
EXPECT_EQ(DataTypeController::NOT_RUNNING, GetController(BOOKMARKS)->state());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Finish configuration with only PREFERENCES.
- configurer_.set_expected_configure_types(
- ModelTypeConfigurer::CONFIGURE_ACTIVE, ModelTypeSet());
- FinishDownload(*dtm_, ModelTypeSet(PREFERENCES), ModelTypeSet());
+ FinishDownload(ModelTypeSet(PREFERENCES), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
+ EXPECT_EQ(ModelTypeSet(), last_configure_params().to_download);
EXPECT_EQ(DataTypeController::RUNNING, GetController(PREFERENCES)->state());
EXPECT_EQ(DataTypeController::NOT_RUNNING, GetController(BOOKMARKS)->state());
}
@@ -1242,13 +1210,9 @@ TEST_F(SyncDataTypeManagerImplTest, FilterDesiredTypes) {
SetConfigureStartExpectation();
SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
- ModelTypeSet expected_types = ControlTypes();
- expected_types.Put(BOOKMARKS);
- // APPS is filtered out because there's no controller for it.
- configurer_.set_expected_configure_types(
- ModelTypeConfigurer::CONFIGURE_ACTIVE, expected_types);
- Configure(dtm_.get(), types);
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
+ Configure(types);
+ EXPECT_EQ(AddControlTypesTo(BOOKMARKS), last_configure_params().to_download);
+ FinishDownload(ModelTypeSet(BOOKMARKS), ModelTypeSet());
GetController(BOOKMARKS)->FinishStart(DataTypeController::OK);
dtm_->Stop();
@@ -1265,13 +1229,13 @@ TEST_F(SyncDataTypeManagerImplTest, ReenableAfterDataTypeError) {
BuildStatusTable(ModelTypeSet(), ModelTypeSet(BOOKMARKS), ModelTypeSet(),
ModelTypeSet()));
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS, PREFERENCES));
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
- FinishDownload(*dtm_, ModelTypeSet(PREFERENCES, BOOKMARKS), ModelTypeSet());
+ Configure(ModelTypeSet(BOOKMARKS, PREFERENCES));
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(PREFERENCES, BOOKMARKS), ModelTypeSet());
GetController(PREFERENCES)->FinishStart(DataTypeController::OK);
GetController(BOOKMARKS)->FinishStart(DataTypeController::ASSOCIATION_FAILED);
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet()); // Reconfig for error.
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet()); // Reconfig for error.
+ FinishDownload(ModelTypeSet(), ModelTypeSet()); // Reconfig for error.
+ FinishDownload(ModelTypeSet(), ModelTypeSet()); // Reconfig for error.
EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
EXPECT_EQ(DataTypeController::RUNNING, GetController(PREFERENCES)->state());
EXPECT_EQ(DataTypeController::NOT_RUNNING, GetController(BOOKMARKS)->state());
@@ -1283,8 +1247,8 @@ TEST_F(SyncDataTypeManagerImplTest, ReenableAfterDataTypeError) {
dtm_->ReenableType(BOOKMARKS);
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
GetController(BOOKMARKS)->FinishStart(DataTypeController::OK);
EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
@@ -1305,8 +1269,8 @@ TEST_F(SyncDataTypeManagerImplTest, UnreadyType) {
DataTypeManager::OK,
BuildStatusTable(ModelTypeSet(), ModelTypeSet(), ModelTypeSet(BOOKMARKS),
ModelTypeSet()));
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
+ Configure(ModelTypeSet(BOOKMARKS));
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
EXPECT_EQ(DataTypeController::NOT_RUNNING, GetController(BOOKMARKS)->state());
EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
EXPECT_EQ(0U, configurer_.activated_types().Size());
@@ -1318,8 +1282,8 @@ TEST_F(SyncDataTypeManagerImplTest, UnreadyType) {
dtm_->ReenableType(BOOKMARKS);
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
GetController(BOOKMARKS)->FinishStart(DataTypeController::OK);
@@ -1347,17 +1311,17 @@ TEST_F(SyncDataTypeManagerImplTest, UnreadyTypeResetReconfigure) {
DataTypeManager::OK,
BuildStatusTable(ModelTypeSet(), ModelTypeSet(), ModelTypeSet(BOOKMARKS),
ModelTypeSet()));
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
+ Configure(ModelTypeSet(BOOKMARKS));
// Second Configure sets a flag to perform reconfiguration after the first one
// is done.
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
+ Configure(ModelTypeSet(BOOKMARKS));
// Reset errors before triggering reconfiguration.
dtm_->ResetDataTypeErrors();
// Reconfiguration should update unready errors. Bookmarks shouldn't start.
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
EXPECT_EQ(DataTypeController::NOT_RUNNING, GetController(BOOKMARKS)->state());
EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
EXPECT_EQ(0U, configurer_.activated_types().Size());
@@ -1374,9 +1338,9 @@ TEST_F(SyncDataTypeManagerImplTest, ModelLoadError) {
DataTypeManager::OK,
BuildStatusTable(ModelTypeSet(), ModelTypeSet(BOOKMARKS), ModelTypeSet(),
ModelTypeSet()));
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
+ Configure(ModelTypeSet(BOOKMARKS));
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
EXPECT_EQ(DataTypeController::NOT_RUNNING, GetController(BOOKMARKS)->state());
@@ -1393,14 +1357,14 @@ TEST_F(SyncDataTypeManagerImplTest, ErrorBeforeAssociation) {
DataTypeManager::OK,
BuildStatusTable(ModelTypeSet(), ModelTypeSet(BOOKMARKS), ModelTypeSet(),
ModelTypeSet()));
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
+ Configure(ModelTypeSet(BOOKMARKS));
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
GetController(BOOKMARKS)->CreateErrorHandler()->OnUnrecoverableError(
SyncError(FROM_HERE, SyncError::DATATYPE_ERROR, "bookmarks error",
BOOKMARKS));
base::RunLoop().RunUntilIdle();
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet()); // Reconfig for error.
+ FinishDownload(ModelTypeSet(BOOKMARKS), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet()); // Reconfig for error.
EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
EXPECT_EQ(DataTypeController::NOT_RUNNING, GetController(BOOKMARKS)->state());
@@ -1416,11 +1380,11 @@ TEST_F(SyncDataTypeManagerImplTest, AssociationNeverCompletes) {
DataTypeManager::OK,
BuildStatusTable(ModelTypeSet(), ModelTypeSet(BOOKMARKS), ModelTypeSet(),
ModelTypeSet()));
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
+ Configure(ModelTypeSet(BOOKMARKS));
GetController(BOOKMARKS)->SetDelayModelLoad();
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
@@ -1432,7 +1396,7 @@ TEST_F(SyncDataTypeManagerImplTest, AssociationNeverCompletes) {
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
EXPECT_EQ(DataTypeController::NOT_RUNNING, GetController(BOOKMARKS)->state());
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
EXPECT_EQ(0U, configurer_.activated_types().Size());
@@ -1443,16 +1407,16 @@ TEST_F(SyncDataTypeManagerImplTest, AllLowPriorityTypesReady) {
AddController(PREFERENCES);
AddController(BOOKMARKS);
- dtm_->set_priority_types(AddControlTypesTo(ModelTypeSet(PREFERENCES)));
+ dtm_->set_priority_types(AddControlTypesTo(PREFERENCES));
SetConfigureStartExpectation();
SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
- Configure(dtm_.get(), ModelTypeSet(PREFERENCES, BOOKMARKS));
+ Configure(ModelTypeSet(PREFERENCES, BOOKMARKS));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
- configurer_.set_ready_types(ModelTypeSet(BOOKMARKS));
- FinishDownload(*dtm_, ModelTypeSet(PREFERENCES), ModelTypeSet());
+ dtm_->set_engine_types(ModelTypeSet(BOOKMARKS));
+ FinishDownload(ModelTypeSet(PREFERENCES), ModelTypeSet());
// Association of Bookmarks can't happen until higher priority types are
// finished.
@@ -1474,7 +1438,7 @@ TEST_F(SyncDataTypeManagerImplTest, AllLowPriorityTypesReady) {
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Finishing the download should complete the configuration.
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS), ModelTypeSet());
EXPECT_EQ(DataTypeController::RUNNING, GetController(BOOKMARKS)->state());
EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
EXPECT_EQ(2U, configurer_.activated_types().Size());
@@ -1489,13 +1453,13 @@ TEST_F(SyncDataTypeManagerImplTest, AllHighPriorityTypesReady) {
AddController(PREFERENCES);
AddController(BOOKMARKS);
- dtm_->set_priority_types(AddControlTypesTo(ModelTypeSet(PREFERENCES)));
+ dtm_->set_priority_types(AddControlTypesTo(PREFERENCES));
SetConfigureStartExpectation();
SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
- configurer_.set_ready_types(ModelTypeSet(PREFERENCES));
- Configure(dtm_.get(), ModelTypeSet(PREFERENCES, BOOKMARKS));
+ dtm_->set_engine_types(ModelTypeSet(PREFERENCES));
+ Configure(ModelTypeSet(PREFERENCES, BOOKMARKS));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Association of Bookmarks can't happen until higher priority types are
@@ -1513,11 +1477,11 @@ TEST_F(SyncDataTypeManagerImplTest, AllHighPriorityTypesReady) {
// Because Bookmarks aren't a ready type, they'll need to wait until the
// low priority download also finishes.
- FinishDownload(*dtm_, ModelTypeSet(PREFERENCES), ModelTypeSet());
+ FinishDownload(ModelTypeSet(PREFERENCES), ModelTypeSet());
EXPECT_EQ(DataTypeController::MODEL_LOADED,
GetController(BOOKMARKS)->state());
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS), ModelTypeSet());
EXPECT_EQ(DataTypeController::ASSOCIATING, GetController(BOOKMARKS)->state());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
@@ -1538,13 +1502,13 @@ TEST_F(SyncDataTypeManagerImplTest, AllTypesReady) {
AddController(PREFERENCES);
AddController(BOOKMARKS);
- dtm_->set_priority_types(AddControlTypesTo(ModelTypeSet(PREFERENCES)));
+ dtm_->set_priority_types(AddControlTypesTo(PREFERENCES));
SetConfigureStartExpectation();
SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
- configurer_.set_ready_types(ModelTypeSet(PREFERENCES));
- Configure(dtm_.get(), ModelTypeSet(PREFERENCES, BOOKMARKS));
+ dtm_->set_engine_types(ModelTypeSet(PREFERENCES));
+ Configure(ModelTypeSet(PREFERENCES, BOOKMARKS));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Association of Bookmarks can't happen until higher priority types are
@@ -1562,8 +1526,8 @@ TEST_F(SyncDataTypeManagerImplTest, AllTypesReady) {
// Because Bookmarks are a ready type, it can start associating immediately
// after the high priority types finish downloading.
- configurer_.set_ready_types(ModelTypeSet(BOOKMARKS));
- FinishDownload(*dtm_, ModelTypeSet(PREFERENCES), ModelTypeSet());
+ dtm_->set_engine_types(ModelTypeSet(BOOKMARKS));
+ FinishDownload(ModelTypeSet(PREFERENCES), ModelTypeSet());
EXPECT_EQ(DataTypeController::ASSOCIATING, GetController(BOOKMARKS)->state());
// Finishing the Bookmarks association leaves the DTM waiting for the low
@@ -1573,7 +1537,7 @@ TEST_F(SyncDataTypeManagerImplTest, AllTypesReady) {
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Finishing the low priority download ends the configuration.
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
EXPECT_EQ(2U, configurer_.activated_types().Size());
@@ -1588,18 +1552,18 @@ TEST_F(SyncDataTypeManagerImplTest, CatchUpTypeAddedToConfigureClean) {
AddController(BOOKMARKS);
AddController(PASSWORDS);
+ ModelTypeSet clean_types(BOOKMARKS, PASSWORDS);
+
SetConfigureStartExpectation();
SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
- configurer_.set_expected_configure_types(
- ModelTypeConfigurer::CONFIGURE_CLEAN,
- AddControlTypesTo(ModelTypeSet(BOOKMARKS, PASSWORDS)));
- dtm_->Configure(ModelTypeSet(BOOKMARKS, PASSWORDS),
- CONFIGURE_REASON_CATCH_UP);
+ dtm_->Configure(clean_types, CONFIGURE_REASON_CATCH_UP);
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
+ EXPECT_EQ(AddControlTypesTo(clean_types), last_configure_params().to_unapply);
+ EXPECT_TRUE(last_configure_params().to_purge.HasAll(clean_types));
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS, PASSWORDS), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
+ FinishDownload(clean_types, ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
GetController(BOOKMARKS)->FinishStart(DataTypeController::OK);
@@ -1625,25 +1589,22 @@ TEST_F(SyncDataTypeManagerImplTest, CatchUpMultipleConfigureCalls) {
SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
// Configure (catch up) with one type.
- configurer_.set_expected_configure_types(
- ModelTypeConfigurer::CONFIGURE_CLEAN,
- AddControlTypesTo(ModelTypeSet(BOOKMARKS)));
dtm_->Configure(ModelTypeSet(BOOKMARKS), CONFIGURE_REASON_CATCH_UP);
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
+ EXPECT_EQ(AddControlTypesTo(BOOKMARKS), last_configure_params().to_unapply);
// Configure with both types before the first one completes. Both types should
// end up in CONFIGURE_CLEAN.
- configurer_.set_expected_configure_types(
- ModelTypeConfigurer::CONFIGURE_CLEAN,
- AddControlTypesTo(ModelTypeSet(BOOKMARKS, PASSWORDS)));
dtm_->Configure(ModelTypeSet(BOOKMARKS, PASSWORDS),
CONFIGURE_REASON_RECONFIGURATION);
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
+ EXPECT_EQ(AddControlTypesTo(ModelTypeSet(BOOKMARKS)),
+ last_configure_params().to_unapply);
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS, PASSWORDS), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS, PASSWORDS), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
GetController(BOOKMARKS)->FinishStart(DataTypeController::OK);
@@ -1663,7 +1624,7 @@ TEST_F(SyncDataTypeManagerImplTest, DelayConfigureForUSSTypes) {
SetConfigureStartExpectation();
SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
+ Configure(ModelTypeSet(BOOKMARKS));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
// Bookmarks model isn't loaded yet and it is required to complete before
// call to configure. Ensure that configure wasn't called.
@@ -1675,8 +1636,8 @@ TEST_F(SyncDataTypeManagerImplTest, DelayConfigureForUSSTypes) {
EXPECT_EQ(1, configurer_.configure_call_count());
EXPECT_EQ(1, GetController(BOOKMARKS)->register_with_backend_call_count());
- FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
- FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
+ FinishDownload(ModelTypeSet(), ModelTypeSet());
+ FinishDownload(ModelTypeSet(BOOKMARKS), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
GetController(BOOKMARKS)->FinishStart(DataTypeController::OK);
@@ -1692,7 +1653,7 @@ TEST_F(SyncDataTypeManagerImplTest, RegisterWithBackendOnEncryptionError) {
SetConfigureStartExpectation();
FailEncryptionFor(ModelTypeSet(BOOKMARKS));
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS, PASSWORDS));
+ Configure(ModelTypeSet(BOOKMARKS, PASSWORDS));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
EXPECT_EQ(DataTypeController::NOT_RUNNING, GetController(BOOKMARKS)->state());
EXPECT_EQ(DataTypeController::MODEL_STARTING,
@@ -1712,7 +1673,7 @@ TEST_F(SyncDataTypeManagerImplTest, RegisterWithBackendAfterLoadModelsError) {
AddController(BOOKMARKS, true, true);
AddController(PASSWORDS, true, true);
SetConfigureStartExpectation();
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS, PASSWORDS));
+ Configure(ModelTypeSet(BOOKMARKS, PASSWORDS));
EXPECT_EQ(DataTypeController::MODEL_STARTING,
GetController(BOOKMARKS)->state());
EXPECT_EQ(DataTypeController::MODEL_STARTING,

Powered by Google App Engine
This is Rietveld 408576698