| Index: components/sync/driver/model_association_manager_unittest.cc
|
| diff --git a/components/sync/driver/model_association_manager_unittest.cc b/components/sync/driver/model_association_manager_unittest.cc
|
| index 023a633a571423e350459daa8518a187984cc5bb..5d774391af0b89aaed409f3fdd6540f5d975177f 100644
|
| --- a/components/sync/driver/model_association_manager_unittest.cc
|
| +++ b/components/sync/driver/model_association_manager_unittest.cc
|
| @@ -14,7 +14,7 @@
|
|
|
| using ::testing::_;
|
|
|
| -namespace syncer {
|
| +namespace sync_driver {
|
|
|
| class MockModelAssociationManagerDelegate
|
| : public ModelAssociationManagerDelegate {
|
| @@ -23,17 +23,17 @@ class MockModelAssociationManagerDelegate
|
| ~MockModelAssociationManagerDelegate() {}
|
| MOCK_METHOD0(OnAllDataTypesReadyForConfigure, void());
|
| MOCK_METHOD2(OnSingleDataTypeAssociationDone,
|
| - void(ModelType type,
|
| - const DataTypeAssociationStats& association_stats));
|
| + void(syncer::ModelType type,
|
| + const syncer::DataTypeAssociationStats& association_stats));
|
| MOCK_METHOD2(OnSingleDataTypeWillStop,
|
| - void(ModelType, const SyncError& error));
|
| + void(syncer::ModelType, const syncer::SyncError& error));
|
| MOCK_METHOD1(OnModelAssociationDone,
|
| void(const DataTypeManager::ConfigureResult& result));
|
| };
|
|
|
| FakeDataTypeController* GetController(
|
| const DataTypeController::TypeMap& controllers,
|
| - ModelType model_type) {
|
| + syncer::ModelType model_type) {
|
| DataTypeController::TypeMap::const_iterator it = controllers.find(model_type);
|
| if (it == controllers.end()) {
|
| return NULL;
|
| @@ -59,117 +59,126 @@ class SyncModelAssociationManagerTest : public testing::Test {
|
| // Start a type and make sure ModelAssociationManager callst the |Start|
|
| // method and calls the callback when it is done.
|
| TEST_F(SyncModelAssociationManagerTest, SimpleModelStart) {
|
| - controllers_[BOOKMARKS] = base::MakeUnique<FakeDataTypeController>(BOOKMARKS);
|
| - controllers_[APPS] = base::MakeUnique<FakeDataTypeController>(APPS);
|
| + controllers_[syncer::BOOKMARKS] =
|
| + base::MakeUnique<FakeDataTypeController>(syncer::BOOKMARKS);
|
| + controllers_[syncer::APPS] =
|
| + base::MakeUnique<FakeDataTypeController>(syncer::APPS);
|
| ModelAssociationManager model_association_manager(&controllers_, &delegate_);
|
| - ModelTypeSet types(BOOKMARKS, APPS);
|
| + syncer::ModelTypeSet types(syncer::BOOKMARKS, syncer::APPS);
|
| DataTypeManager::ConfigureResult expected_result(DataTypeManager::OK, types);
|
| EXPECT_CALL(delegate_, OnAllDataTypesReadyForConfigure());
|
| EXPECT_CALL(delegate_, OnModelAssociationDone(_))
|
| .WillOnce(VerifyResult(expected_result));
|
|
|
| - EXPECT_EQ(GetController(controllers_, BOOKMARKS)->state(),
|
| + EXPECT_EQ(GetController(controllers_, syncer::BOOKMARKS)->state(),
|
| DataTypeController::NOT_RUNNING);
|
| - EXPECT_EQ(GetController(controllers_, APPS)->state(),
|
| + EXPECT_EQ(GetController(controllers_, syncer::APPS)->state(),
|
| DataTypeController::NOT_RUNNING);
|
|
|
| // Initialize() kicks off model loading.
|
| model_association_manager.Initialize(types);
|
|
|
| - EXPECT_EQ(GetController(controllers_, BOOKMARKS)->state(),
|
| + EXPECT_EQ(GetController(controllers_, syncer::BOOKMARKS)->state(),
|
| DataTypeController::MODEL_LOADED);
|
| - EXPECT_EQ(GetController(controllers_, APPS)->state(),
|
| + EXPECT_EQ(GetController(controllers_, syncer::APPS)->state(),
|
| DataTypeController::MODEL_LOADED);
|
|
|
| model_association_manager.StartAssociationAsync(types);
|
|
|
| - EXPECT_EQ(GetController(controllers_, BOOKMARKS)->state(),
|
| + EXPECT_EQ(GetController(controllers_, syncer::BOOKMARKS)->state(),
|
| DataTypeController::ASSOCIATING);
|
| - EXPECT_EQ(GetController(controllers_, APPS)->state(),
|
| + EXPECT_EQ(GetController(controllers_, syncer::APPS)->state(),
|
| DataTypeController::ASSOCIATING);
|
| - GetController(controllers_, BOOKMARKS)->FinishStart(DataTypeController::OK);
|
| - GetController(controllers_, APPS)->FinishStart(DataTypeController::OK);
|
| + GetController(controllers_, syncer::BOOKMARKS)
|
| + ->FinishStart(DataTypeController::OK);
|
| + GetController(controllers_, syncer::APPS)
|
| + ->FinishStart(DataTypeController::OK);
|
| }
|
|
|
| // Start a type and call stop before it finishes associating.
|
| TEST_F(SyncModelAssociationManagerTest, StopModelBeforeFinish) {
|
| - controllers_[BOOKMARKS] = base::MakeUnique<FakeDataTypeController>(BOOKMARKS);
|
| + controllers_[syncer::BOOKMARKS] =
|
| + base::MakeUnique<FakeDataTypeController>(syncer::BOOKMARKS);
|
| ModelAssociationManager model_association_manager(&controllers_, &delegate_);
|
|
|
| - ModelTypeSet types;
|
| - types.Put(BOOKMARKS);
|
| + syncer::ModelTypeSet types;
|
| + types.Put(syncer::BOOKMARKS);
|
|
|
| DataTypeManager::ConfigureResult expected_result(DataTypeManager::ABORTED,
|
| types);
|
|
|
| EXPECT_CALL(delegate_, OnModelAssociationDone(_))
|
| .WillOnce(VerifyResult(expected_result));
|
| - EXPECT_CALL(delegate_, OnSingleDataTypeWillStop(BOOKMARKS, _));
|
| + EXPECT_CALL(delegate_, OnSingleDataTypeWillStop(syncer::BOOKMARKS, _));
|
|
|
| model_association_manager.Initialize(types);
|
| model_association_manager.StartAssociationAsync(types);
|
|
|
| - EXPECT_EQ(GetController(controllers_, BOOKMARKS)->state(),
|
| + EXPECT_EQ(GetController(controllers_, syncer::BOOKMARKS)->state(),
|
| DataTypeController::ASSOCIATING);
|
| model_association_manager.Stop();
|
| - EXPECT_EQ(GetController(controllers_, BOOKMARKS)->state(),
|
| + EXPECT_EQ(GetController(controllers_, syncer::BOOKMARKS)->state(),
|
| DataTypeController::NOT_RUNNING);
|
| }
|
|
|
| // Start a type, let it finish and then call stop.
|
| TEST_F(SyncModelAssociationManagerTest, StopAfterFinish) {
|
| - controllers_[BOOKMARKS] = base::MakeUnique<FakeDataTypeController>(BOOKMARKS);
|
| + controllers_[syncer::BOOKMARKS] =
|
| + base::MakeUnique<FakeDataTypeController>(syncer::BOOKMARKS);
|
| ModelAssociationManager model_association_manager(&controllers_, &delegate_);
|
| - ModelTypeSet types;
|
| - types.Put(BOOKMARKS);
|
| + syncer::ModelTypeSet types;
|
| + types.Put(syncer::BOOKMARKS);
|
| DataTypeManager::ConfigureResult expected_result(DataTypeManager::OK, types);
|
| EXPECT_CALL(delegate_, OnModelAssociationDone(_))
|
| .WillOnce(VerifyResult(expected_result));
|
| - EXPECT_CALL(delegate_, OnSingleDataTypeWillStop(BOOKMARKS, _));
|
| + EXPECT_CALL(delegate_, OnSingleDataTypeWillStop(syncer::BOOKMARKS, _));
|
|
|
| model_association_manager.Initialize(types);
|
| model_association_manager.StartAssociationAsync(types);
|
|
|
| - EXPECT_EQ(GetController(controllers_, BOOKMARKS)->state(),
|
| + EXPECT_EQ(GetController(controllers_, syncer::BOOKMARKS)->state(),
|
| DataTypeController::ASSOCIATING);
|
| - GetController(controllers_, BOOKMARKS)->FinishStart(DataTypeController::OK);
|
| + GetController(controllers_, syncer::BOOKMARKS)
|
| + ->FinishStart(DataTypeController::OK);
|
|
|
| model_association_manager.Stop();
|
| - EXPECT_EQ(GetController(controllers_, BOOKMARKS)->state(),
|
| + EXPECT_EQ(GetController(controllers_, syncer::BOOKMARKS)->state(),
|
| DataTypeController::NOT_RUNNING);
|
| }
|
|
|
| // Make a type fail model association and verify correctness.
|
| TEST_F(SyncModelAssociationManagerTest, TypeFailModelAssociation) {
|
| - controllers_[BOOKMARKS] = base::MakeUnique<FakeDataTypeController>(BOOKMARKS);
|
| + controllers_[syncer::BOOKMARKS] =
|
| + base::MakeUnique<FakeDataTypeController>(syncer::BOOKMARKS);
|
| ModelAssociationManager model_association_manager(&controllers_, &delegate_);
|
| - ModelTypeSet types;
|
| - types.Put(BOOKMARKS);
|
| + syncer::ModelTypeSet types;
|
| + types.Put(syncer::BOOKMARKS);
|
| DataTypeManager::ConfigureResult expected_result(DataTypeManager::OK, types);
|
| - EXPECT_CALL(delegate_, OnSingleDataTypeWillStop(BOOKMARKS, _));
|
| + EXPECT_CALL(delegate_, OnSingleDataTypeWillStop(syncer::BOOKMARKS, _));
|
| EXPECT_CALL(delegate_, OnModelAssociationDone(_))
|
| .WillOnce(VerifyResult(expected_result));
|
|
|
| model_association_manager.Initialize(types);
|
| model_association_manager.StartAssociationAsync(types);
|
|
|
| - EXPECT_EQ(GetController(controllers_, BOOKMARKS)->state(),
|
| + EXPECT_EQ(GetController(controllers_, syncer::BOOKMARKS)->state(),
|
| DataTypeController::ASSOCIATING);
|
| - GetController(controllers_, BOOKMARKS)
|
| + GetController(controllers_, syncer::BOOKMARKS)
|
| ->FinishStart(DataTypeController::ASSOCIATION_FAILED);
|
| - EXPECT_EQ(GetController(controllers_, BOOKMARKS)->state(),
|
| + EXPECT_EQ(GetController(controllers_, syncer::BOOKMARKS)->state(),
|
| DataTypeController::NOT_RUNNING);
|
| }
|
|
|
| // Ensure configuring stops when a type returns a unrecoverable error.
|
| TEST_F(SyncModelAssociationManagerTest, TypeReturnUnrecoverableError) {
|
| - controllers_[BOOKMARKS] = base::MakeUnique<FakeDataTypeController>(BOOKMARKS);
|
| + controllers_[syncer::BOOKMARKS] =
|
| + base::MakeUnique<FakeDataTypeController>(syncer::BOOKMARKS);
|
| ModelAssociationManager model_association_manager(&controllers_, &delegate_);
|
| - ModelTypeSet types;
|
| - types.Put(BOOKMARKS);
|
| + syncer::ModelTypeSet types;
|
| + types.Put(syncer::BOOKMARKS);
|
| DataTypeManager::ConfigureResult expected_result(
|
| DataTypeManager::UNRECOVERABLE_ERROR, types);
|
| - EXPECT_CALL(delegate_, OnSingleDataTypeWillStop(BOOKMARKS, _));
|
| + EXPECT_CALL(delegate_, OnSingleDataTypeWillStop(syncer::BOOKMARKS, _));
|
| EXPECT_CALL(delegate_, OnModelAssociationDone(_))
|
| .WillOnce(VerifyResult(expected_result));
|
|
|
| @@ -177,20 +186,22 @@ TEST_F(SyncModelAssociationManagerTest, TypeReturnUnrecoverableError) {
|
|
|
| model_association_manager.StartAssociationAsync(types);
|
|
|
| - EXPECT_EQ(GetController(controllers_, BOOKMARKS)->state(),
|
| + EXPECT_EQ(GetController(controllers_, syncer::BOOKMARKS)->state(),
|
| DataTypeController::ASSOCIATING);
|
| - GetController(controllers_, BOOKMARKS)
|
| + GetController(controllers_, syncer::BOOKMARKS)
|
| ->FinishStart(DataTypeController::UNRECOVERABLE_ERROR);
|
| }
|
|
|
| TEST_F(SyncModelAssociationManagerTest, SlowTypeAsFailedType) {
|
| - controllers_[BOOKMARKS] = base::MakeUnique<FakeDataTypeController>(BOOKMARKS);
|
| - controllers_[APPS] = base::MakeUnique<FakeDataTypeController>(APPS);
|
| - GetController(controllers_, BOOKMARKS)->SetDelayModelLoad();
|
| + controllers_[syncer::BOOKMARKS] =
|
| + base::MakeUnique<FakeDataTypeController>(syncer::BOOKMARKS);
|
| + controllers_[syncer::APPS] =
|
| + base::MakeUnique<FakeDataTypeController>(syncer::APPS);
|
| + GetController(controllers_, syncer::BOOKMARKS)->SetDelayModelLoad();
|
| ModelAssociationManager model_association_manager(&controllers_, &delegate_);
|
| - ModelTypeSet types;
|
| - types.Put(BOOKMARKS);
|
| - types.Put(APPS);
|
| + syncer::ModelTypeSet types;
|
| + types.Put(syncer::BOOKMARKS);
|
| + types.Put(syncer::APPS);
|
|
|
| DataTypeManager::ConfigureResult expected_result_partially_done(
|
| DataTypeManager::OK, types);
|
| @@ -200,27 +211,30 @@ TEST_F(SyncModelAssociationManagerTest, SlowTypeAsFailedType) {
|
|
|
| model_association_manager.Initialize(types);
|
| model_association_manager.StartAssociationAsync(types);
|
| - GetController(controllers_, APPS)->FinishStart(DataTypeController::OK);
|
| + GetController(controllers_, syncer::APPS)
|
| + ->FinishStart(DataTypeController::OK);
|
|
|
| - EXPECT_CALL(delegate_, OnSingleDataTypeWillStop(BOOKMARKS, _));
|
| + EXPECT_CALL(delegate_, OnSingleDataTypeWillStop(syncer::BOOKMARKS, _));
|
| model_association_manager.GetTimerForTesting()->user_task().Run();
|
|
|
| EXPECT_EQ(DataTypeController::NOT_RUNNING,
|
| - GetController(controllers_, BOOKMARKS)->state());
|
| + GetController(controllers_, syncer::BOOKMARKS)->state());
|
| }
|
|
|
| TEST_F(SyncModelAssociationManagerTest, StartMultipleTimes) {
|
| - controllers_[BOOKMARKS] = base::MakeUnique<FakeDataTypeController>(BOOKMARKS);
|
| - controllers_[APPS] = base::MakeUnique<FakeDataTypeController>(APPS);
|
| + controllers_[syncer::BOOKMARKS] =
|
| + base::MakeUnique<FakeDataTypeController>(syncer::BOOKMARKS);
|
| + controllers_[syncer::APPS] =
|
| + base::MakeUnique<FakeDataTypeController>(syncer::APPS);
|
| ModelAssociationManager model_association_manager(&controllers_, &delegate_);
|
| - ModelTypeSet types;
|
| - types.Put(BOOKMARKS);
|
| - types.Put(APPS);
|
| -
|
| - DataTypeManager::ConfigureResult result_1st(DataTypeManager::OK,
|
| - ModelTypeSet(BOOKMARKS));
|
| - DataTypeManager::ConfigureResult result_2nd(DataTypeManager::OK,
|
| - ModelTypeSet(APPS));
|
| + syncer::ModelTypeSet types;
|
| + types.Put(syncer::BOOKMARKS);
|
| + types.Put(syncer::APPS);
|
| +
|
| + DataTypeManager::ConfigureResult result_1st(
|
| + DataTypeManager::OK, syncer::ModelTypeSet(syncer::BOOKMARKS));
|
| + DataTypeManager::ConfigureResult result_2nd(
|
| + DataTypeManager::OK, syncer::ModelTypeSet(syncer::APPS));
|
| EXPECT_CALL(delegate_, OnModelAssociationDone(_))
|
| .Times(2)
|
| .WillOnce(VerifyResult(result_1st))
|
| @@ -229,57 +243,63 @@ TEST_F(SyncModelAssociationManagerTest, StartMultipleTimes) {
|
| model_association_manager.Initialize(types);
|
|
|
| // Start BOOKMARKS first.
|
| - model_association_manager.StartAssociationAsync(ModelTypeSet(BOOKMARKS));
|
| - EXPECT_EQ(GetController(controllers_, BOOKMARKS)->state(),
|
| + model_association_manager.StartAssociationAsync(
|
| + syncer::ModelTypeSet(syncer::BOOKMARKS));
|
| + EXPECT_EQ(GetController(controllers_, syncer::BOOKMARKS)->state(),
|
| DataTypeController::ASSOCIATING);
|
| - EXPECT_EQ(GetController(controllers_, APPS)->state(),
|
| + EXPECT_EQ(GetController(controllers_, syncer::APPS)->state(),
|
| DataTypeController::MODEL_LOADED);
|
|
|
| // Finish BOOKMARKS association.
|
| - GetController(controllers_, BOOKMARKS)->FinishStart(DataTypeController::OK);
|
| - EXPECT_EQ(GetController(controllers_, BOOKMARKS)->state(),
|
| + GetController(controllers_, syncer::BOOKMARKS)
|
| + ->FinishStart(DataTypeController::OK);
|
| + EXPECT_EQ(GetController(controllers_, syncer::BOOKMARKS)->state(),
|
| DataTypeController::RUNNING);
|
| - EXPECT_EQ(GetController(controllers_, APPS)->state(),
|
| + EXPECT_EQ(GetController(controllers_, syncer::APPS)->state(),
|
| DataTypeController::MODEL_LOADED);
|
|
|
| // Start APPS next.
|
| - model_association_manager.StartAssociationAsync(ModelTypeSet(APPS));
|
| - EXPECT_EQ(GetController(controllers_, APPS)->state(),
|
| + model_association_manager.StartAssociationAsync(
|
| + syncer::ModelTypeSet(syncer::APPS));
|
| + EXPECT_EQ(GetController(controllers_, syncer::APPS)->state(),
|
| DataTypeController::ASSOCIATING);
|
| - GetController(controllers_, APPS)->FinishStart(DataTypeController::OK);
|
| - EXPECT_EQ(GetController(controllers_, APPS)->state(),
|
| + GetController(controllers_, syncer::APPS)
|
| + ->FinishStart(DataTypeController::OK);
|
| + EXPECT_EQ(GetController(controllers_, syncer::APPS)->state(),
|
| DataTypeController::RUNNING);
|
| }
|
|
|
| // Test that model that failed to load between initialization and association
|
| // is reported and stopped properly.
|
| TEST_F(SyncModelAssociationManagerTest, ModelLoadFailBeforeAssociationStart) {
|
| - controllers_[BOOKMARKS] = base::MakeUnique<FakeDataTypeController>(BOOKMARKS);
|
| - GetController(controllers_, BOOKMARKS)
|
| - ->SetModelLoadError(
|
| - SyncError(FROM_HERE, SyncError::DATATYPE_ERROR, "", BOOKMARKS));
|
| + controllers_[syncer::BOOKMARKS] =
|
| + base::MakeUnique<FakeDataTypeController>(syncer::BOOKMARKS);
|
| + GetController(controllers_, syncer::BOOKMARKS)
|
| + ->SetModelLoadError(syncer::SyncError(
|
| + FROM_HERE, syncer::SyncError::DATATYPE_ERROR, "", syncer::BOOKMARKS));
|
| ModelAssociationManager model_association_manager(&controllers_, &delegate_);
|
| - ModelTypeSet types;
|
| - types.Put(BOOKMARKS);
|
| + syncer::ModelTypeSet types;
|
| + types.Put(syncer::BOOKMARKS);
|
| DataTypeManager::ConfigureResult expected_result(DataTypeManager::OK, types);
|
| - EXPECT_CALL(delegate_, OnSingleDataTypeWillStop(BOOKMARKS, _));
|
| + EXPECT_CALL(delegate_, OnSingleDataTypeWillStop(syncer::BOOKMARKS, _));
|
| EXPECT_CALL(delegate_, OnModelAssociationDone(_))
|
| .WillOnce(VerifyResult(expected_result));
|
|
|
| model_association_manager.Initialize(types);
|
| EXPECT_EQ(DataTypeController::NOT_RUNNING,
|
| - GetController(controllers_, BOOKMARKS)->state());
|
| + GetController(controllers_, syncer::BOOKMARKS)->state());
|
| model_association_manager.StartAssociationAsync(types);
|
| EXPECT_EQ(DataTypeController::NOT_RUNNING,
|
| - GetController(controllers_, BOOKMARKS)->state());
|
| + GetController(controllers_, syncer::BOOKMARKS)->state());
|
| }
|
|
|
| // Test that a runtime error is handled by stopping the type.
|
| TEST_F(SyncModelAssociationManagerTest, StopAfterConfiguration) {
|
| - controllers_[BOOKMARKS] = base::MakeUnique<FakeDataTypeController>(BOOKMARKS);
|
| + controllers_[syncer::BOOKMARKS] =
|
| + base::MakeUnique<FakeDataTypeController>(syncer::BOOKMARKS);
|
| ModelAssociationManager model_association_manager(&controllers_, &delegate_);
|
| - ModelTypeSet types;
|
| - types.Put(BOOKMARKS);
|
| + syncer::ModelTypeSet types;
|
| + types.Put(syncer::BOOKMARKS);
|
| DataTypeManager::ConfigureResult expected_result(DataTypeManager::OK, types);
|
| EXPECT_CALL(delegate_, OnModelAssociationDone(_))
|
| .WillOnce(VerifyResult(expected_result));
|
| @@ -287,31 +307,35 @@ TEST_F(SyncModelAssociationManagerTest, StopAfterConfiguration) {
|
| model_association_manager.Initialize(types);
|
| model_association_manager.StartAssociationAsync(types);
|
|
|
| - EXPECT_EQ(GetController(controllers_, BOOKMARKS)->state(),
|
| + EXPECT_EQ(GetController(controllers_, syncer::BOOKMARKS)->state(),
|
| DataTypeController::ASSOCIATING);
|
| - GetController(controllers_, BOOKMARKS)->FinishStart(DataTypeController::OK);
|
| - EXPECT_EQ(GetController(controllers_, BOOKMARKS)->state(),
|
| + GetController(controllers_, syncer::BOOKMARKS)
|
| + ->FinishStart(DataTypeController::OK);
|
| + EXPECT_EQ(GetController(controllers_, syncer::BOOKMARKS)->state(),
|
| DataTypeController::RUNNING);
|
|
|
| testing::Mock::VerifyAndClearExpectations(&delegate_);
|
| - EXPECT_CALL(delegate_, OnSingleDataTypeWillStop(BOOKMARKS, _));
|
| - SyncError error(FROM_HERE, SyncError::DATATYPE_ERROR, "error", BOOKMARKS);
|
| - GetController(controllers_, BOOKMARKS)
|
| + EXPECT_CALL(delegate_, OnSingleDataTypeWillStop(syncer::BOOKMARKS, _));
|
| + syncer::SyncError error(FROM_HERE, syncer::SyncError::DATATYPE_ERROR, "error",
|
| + syncer::BOOKMARKS);
|
| + GetController(controllers_, syncer::BOOKMARKS)
|
| ->CreateErrorHandler()
|
| ->OnUnrecoverableError(error);
|
| base::RunLoop().RunUntilIdle();
|
| }
|
|
|
| TEST_F(SyncModelAssociationManagerTest, AbortDuringAssociation) {
|
| - controllers_[BOOKMARKS] = base::MakeUnique<FakeDataTypeController>(BOOKMARKS);
|
| - controllers_[APPS] = base::MakeUnique<FakeDataTypeController>(APPS);
|
| + controllers_[syncer::BOOKMARKS] =
|
| + base::MakeUnique<FakeDataTypeController>(syncer::BOOKMARKS);
|
| + controllers_[syncer::APPS] =
|
| + base::MakeUnique<FakeDataTypeController>(syncer::APPS);
|
| ModelAssociationManager model_association_manager(&controllers_, &delegate_);
|
| - ModelTypeSet types;
|
| - types.Put(BOOKMARKS);
|
| - types.Put(APPS);
|
| + syncer::ModelTypeSet types;
|
| + types.Put(syncer::BOOKMARKS);
|
| + types.Put(syncer::APPS);
|
|
|
| - ModelTypeSet expected_types_unfinished;
|
| - expected_types_unfinished.Put(BOOKMARKS);
|
| + syncer::ModelTypeSet expected_types_unfinished;
|
| + expected_types_unfinished.Put(syncer::BOOKMARKS);
|
| DataTypeManager::ConfigureResult expected_result_partially_done(
|
| DataTypeManager::OK, types);
|
|
|
| @@ -320,33 +344,37 @@ TEST_F(SyncModelAssociationManagerTest, AbortDuringAssociation) {
|
|
|
| model_association_manager.Initialize(types);
|
| model_association_manager.StartAssociationAsync(types);
|
| - GetController(controllers_, APPS)->FinishStart(DataTypeController::OK);
|
| - EXPECT_EQ(GetController(controllers_, APPS)->state(),
|
| + GetController(controllers_, syncer::APPS)
|
| + ->FinishStart(DataTypeController::OK);
|
| + EXPECT_EQ(GetController(controllers_, syncer::APPS)->state(),
|
| DataTypeController::RUNNING);
|
| - EXPECT_EQ(GetController(controllers_, BOOKMARKS)->state(),
|
| + EXPECT_EQ(GetController(controllers_, syncer::BOOKMARKS)->state(),
|
| DataTypeController::ASSOCIATING);
|
|
|
| - EXPECT_CALL(delegate_, OnSingleDataTypeWillStop(BOOKMARKS, _));
|
| + EXPECT_CALL(delegate_, OnSingleDataTypeWillStop(syncer::BOOKMARKS, _));
|
| model_association_manager.GetTimerForTesting()->user_task().Run();
|
|
|
| EXPECT_EQ(DataTypeController::NOT_RUNNING,
|
| - GetController(controllers_, BOOKMARKS)->state());
|
| + GetController(controllers_, syncer::BOOKMARKS)->state());
|
| }
|
|
|
| // Test that OnAllDataTypesReadyForConfigure is called when all datatypes that
|
| // require LoadModels before configuration are loaded.
|
| TEST_F(SyncModelAssociationManagerTest, OnAllDataTypesReadyForConfigure) {
|
| // Create two controllers with delayed model load.
|
| - controllers_[BOOKMARKS] = base::MakeUnique<FakeDataTypeController>(BOOKMARKS);
|
| - controllers_[APPS] = base::MakeUnique<FakeDataTypeController>(APPS);
|
| - GetController(controllers_, BOOKMARKS)->SetDelayModelLoad();
|
| - GetController(controllers_, APPS)->SetDelayModelLoad();
|
| + controllers_[syncer::BOOKMARKS] =
|
| + base::MakeUnique<FakeDataTypeController>(syncer::BOOKMARKS);
|
| + controllers_[syncer::APPS] =
|
| + base::MakeUnique<FakeDataTypeController>(syncer::APPS);
|
| + GetController(controllers_, syncer::BOOKMARKS)->SetDelayModelLoad();
|
| + GetController(controllers_, syncer::APPS)->SetDelayModelLoad();
|
|
|
| // APPS controller requires LoadModels complete before configure.
|
| - GetController(controllers_, APPS)->SetShouldLoadModelBeforeConfigure(true);
|
| + GetController(controllers_, syncer::APPS)
|
| + ->SetShouldLoadModelBeforeConfigure(true);
|
|
|
| ModelAssociationManager model_association_manager(&controllers_, &delegate_);
|
| - ModelTypeSet types(BOOKMARKS, APPS);
|
| + syncer::ModelTypeSet types(syncer::BOOKMARKS, syncer::APPS);
|
| DataTypeManager::ConfigureResult expected_result(DataTypeManager::OK, types);
|
| // OnAllDataTypesReadyForConfigure shouldn't be called, APPS data type is not
|
| // loaded yet.
|
| @@ -354,9 +382,9 @@ TEST_F(SyncModelAssociationManagerTest, OnAllDataTypesReadyForConfigure) {
|
|
|
| model_association_manager.Initialize(types);
|
|
|
| - EXPECT_EQ(GetController(controllers_, BOOKMARKS)->state(),
|
| + EXPECT_EQ(GetController(controllers_, syncer::BOOKMARKS)->state(),
|
| DataTypeController::MODEL_STARTING);
|
| - EXPECT_EQ(GetController(controllers_, APPS)->state(),
|
| + EXPECT_EQ(GetController(controllers_, syncer::APPS)->state(),
|
| DataTypeController::MODEL_STARTING);
|
|
|
| testing::Mock::VerifyAndClearExpectations(&delegate_);
|
| @@ -364,10 +392,10 @@ TEST_F(SyncModelAssociationManagerTest, OnAllDataTypesReadyForConfigure) {
|
| EXPECT_CALL(delegate_, OnAllDataTypesReadyForConfigure());
|
| // Finish loading APPS. This should trigger OnAllDataTypesReadyForConfigure
|
| // even though BOOKMARKS is not loaded yet.
|
| - GetController(controllers_, APPS)->SimulateModelLoadFinishing();
|
| - EXPECT_EQ(GetController(controllers_, BOOKMARKS)->state(),
|
| + GetController(controllers_, syncer::APPS)->SimulateModelLoadFinishing();
|
| + EXPECT_EQ(GetController(controllers_, syncer::BOOKMARKS)->state(),
|
| DataTypeController::MODEL_STARTING);
|
| - EXPECT_EQ(GetController(controllers_, APPS)->state(),
|
| + EXPECT_EQ(GetController(controllers_, syncer::APPS)->state(),
|
| DataTypeController::MODEL_LOADED);
|
|
|
| // Call ModelAssociationManager::Initialize with reduced set of datatypes.
|
| @@ -376,7 +404,7 @@ TEST_F(SyncModelAssociationManagerTest, OnAllDataTypesReadyForConfigure) {
|
| testing::Mock::VerifyAndClearExpectations(&delegate_);
|
|
|
| EXPECT_CALL(delegate_, OnAllDataTypesReadyForConfigure());
|
| - ModelTypeSet reduced_types(APPS);
|
| + syncer::ModelTypeSet reduced_types(syncer::APPS);
|
| model_association_manager.Initialize(reduced_types);
|
| }
|
|
|
| @@ -384,14 +412,16 @@ TEST_F(SyncModelAssociationManagerTest, OnAllDataTypesReadyForConfigure) {
|
| // LoadModels fails for one of datatypes.
|
| TEST_F(SyncModelAssociationManagerTest,
|
| OnAllDataTypesReadyForConfigure_FailedLoadModels) {
|
| - controllers_[APPS] = base::MakeUnique<FakeDataTypeController>(APPS);
|
| - GetController(controllers_, APPS)->SetDelayModelLoad();
|
| + controllers_[syncer::APPS] =
|
| + base::MakeUnique<FakeDataTypeController>(syncer::APPS);
|
| + GetController(controllers_, syncer::APPS)->SetDelayModelLoad();
|
|
|
| // APPS controller requires LoadModels complete before configure.
|
| - GetController(controllers_, APPS)->SetShouldLoadModelBeforeConfigure(true);
|
| + GetController(controllers_, syncer::APPS)
|
| + ->SetShouldLoadModelBeforeConfigure(true);
|
|
|
| ModelAssociationManager model_association_manager(&controllers_, &delegate_);
|
| - ModelTypeSet types(APPS);
|
| + syncer::ModelTypeSet types(syncer::APPS);
|
| DataTypeManager::ConfigureResult expected_result(DataTypeManager::OK, types);
|
| // OnAllDataTypesReadyForConfigure shouldn't be called, APPS data type is not
|
| // loaded yet.
|
| @@ -399,7 +429,7 @@ TEST_F(SyncModelAssociationManagerTest,
|
|
|
| model_association_manager.Initialize(types);
|
|
|
| - EXPECT_EQ(GetController(controllers_, APPS)->state(),
|
| + EXPECT_EQ(GetController(controllers_, syncer::APPS)->state(),
|
| DataTypeController::MODEL_STARTING);
|
|
|
| testing::Mock::VerifyAndClearExpectations(&delegate_);
|
| @@ -407,11 +437,11 @@ TEST_F(SyncModelAssociationManagerTest,
|
| EXPECT_CALL(delegate_, OnAllDataTypesReadyForConfigure());
|
| // Simulate model load error for APPS and finish loading it. This should
|
| // trigger OnAllDataTypesReadyForConfigure.
|
| - GetController(controllers_, APPS)
|
| - ->SetModelLoadError(
|
| - SyncError(FROM_HERE, SyncError::DATATYPE_ERROR, "", APPS));
|
| - GetController(controllers_, APPS)->SimulateModelLoadFinishing();
|
| - EXPECT_EQ(GetController(controllers_, APPS)->state(),
|
| + GetController(controllers_, syncer::APPS)
|
| + ->SetModelLoadError(syncer::SyncError(
|
| + FROM_HERE, syncer::SyncError::DATATYPE_ERROR, "", syncer::APPS));
|
| + GetController(controllers_, syncer::APPS)->SimulateModelLoadFinishing();
|
| + EXPECT_EQ(GetController(controllers_, syncer::APPS)->state(),
|
| DataTypeController::NOT_RUNNING);
|
| }
|
|
|
| @@ -421,17 +451,20 @@ TEST_F(SyncModelAssociationManagerTest,
|
| OnAllDataTypesReadyForConfigure_TypeFailedAfterLoadModels) {
|
| // Create two controllers with delayed model load. Both should block
|
| // configuration.
|
| - controllers_[BOOKMARKS] = base::MakeUnique<FakeDataTypeController>(BOOKMARKS);
|
| - controllers_[APPS] = base::MakeUnique<FakeDataTypeController>(APPS);
|
| - GetController(controllers_, BOOKMARKS)->SetDelayModelLoad();
|
| - GetController(controllers_, APPS)->SetDelayModelLoad();
|
| -
|
| - GetController(controllers_, BOOKMARKS)
|
| + controllers_[syncer::BOOKMARKS] =
|
| + base::MakeUnique<FakeDataTypeController>(syncer::BOOKMARKS);
|
| + controllers_[syncer::APPS] =
|
| + base::MakeUnique<FakeDataTypeController>(syncer::APPS);
|
| + GetController(controllers_, syncer::BOOKMARKS)->SetDelayModelLoad();
|
| + GetController(controllers_, syncer::APPS)->SetDelayModelLoad();
|
| +
|
| + GetController(controllers_, syncer::BOOKMARKS)
|
| + ->SetShouldLoadModelBeforeConfigure(true);
|
| + GetController(controllers_, syncer::APPS)
|
| ->SetShouldLoadModelBeforeConfigure(true);
|
| - GetController(controllers_, APPS)->SetShouldLoadModelBeforeConfigure(true);
|
|
|
| ModelAssociationManager model_association_manager(&controllers_, &delegate_);
|
| - ModelTypeSet types(BOOKMARKS, APPS);
|
| + syncer::ModelTypeSet types(syncer::BOOKMARKS, syncer::APPS);
|
| DataTypeManager::ConfigureResult expected_result(DataTypeManager::OK, types);
|
|
|
| // Apps will finish loading but bookmarks won't.
|
| @@ -440,21 +473,22 @@ TEST_F(SyncModelAssociationManagerTest,
|
|
|
| model_association_manager.Initialize(types);
|
|
|
| - GetController(controllers_, APPS)->SimulateModelLoadFinishing();
|
| + GetController(controllers_, syncer::APPS)->SimulateModelLoadFinishing();
|
|
|
| - EXPECT_EQ(GetController(controllers_, BOOKMARKS)->state(),
|
| + EXPECT_EQ(GetController(controllers_, syncer::BOOKMARKS)->state(),
|
| DataTypeController::MODEL_STARTING);
|
| - EXPECT_EQ(GetController(controllers_, APPS)->state(),
|
| + EXPECT_EQ(GetController(controllers_, syncer::APPS)->state(),
|
| DataTypeController::MODEL_LOADED);
|
|
|
| testing::Mock::VerifyAndClearExpectations(&delegate_);
|
|
|
| EXPECT_CALL(delegate_, OnAllDataTypesReadyForConfigure()).Times(0);
|
|
|
| - EXPECT_CALL(delegate_, OnSingleDataTypeWillStop(APPS, _));
|
| + EXPECT_CALL(delegate_, OnSingleDataTypeWillStop(syncer::APPS, _));
|
| // Apps datatype reports failure.
|
| - SyncError error(FROM_HERE, SyncError::DATATYPE_ERROR, "error", APPS);
|
| - GetController(controllers_, APPS)
|
| + syncer::SyncError error(FROM_HERE, syncer::SyncError::DATATYPE_ERROR, "error",
|
| + syncer::APPS);
|
| + GetController(controllers_, syncer::APPS)
|
| ->CreateErrorHandler()
|
| ->OnUnrecoverableError(error);
|
| base::RunLoop().RunUntilIdle();
|
| @@ -464,9 +498,9 @@ TEST_F(SyncModelAssociationManagerTest,
|
| EXPECT_CALL(delegate_, OnAllDataTypesReadyForConfigure());
|
| // Finish loading BOOKMARKS. This should trigger
|
| // OnAllDataTypesReadyForConfigure().
|
| - GetController(controllers_, BOOKMARKS)->SimulateModelLoadFinishing();
|
| - EXPECT_EQ(GetController(controllers_, BOOKMARKS)->state(),
|
| + GetController(controllers_, syncer::BOOKMARKS)->SimulateModelLoadFinishing();
|
| + EXPECT_EQ(GetController(controllers_, syncer::BOOKMARKS)->state(),
|
| DataTypeController::MODEL_LOADED);
|
| }
|
|
|
| -} // namespace syncer
|
| +} // namespace sync_driver
|
|
|