| Index: trunk/src/components/sync_driver/model_association_manager_unittest.cc
|
| ===================================================================
|
| --- trunk/src/components/sync_driver/model_association_manager_unittest.cc (revision 289352)
|
| +++ trunk/src/components/sync_driver/model_association_manager_unittest.cc (working copy)
|
| @@ -21,7 +21,8 @@
|
| MOCK_METHOD2(OnSingleDataTypeAssociationDone,
|
| void(syncer::ModelType type,
|
| const syncer::DataTypeAssociationStats& association_stats));
|
| - MOCK_METHOD1(OnSingleDataTypeWillStop, void(syncer::ModelType));
|
| + MOCK_METHOD2(OnSingleDataTypeWillStop,
|
| + void(syncer::ModelType, const syncer::SyncError& error));
|
| MOCK_METHOD1(OnModelAssociationDone, void(
|
| const DataTypeManager::ConfigureResult& result));
|
| };
|
| @@ -40,22 +41,6 @@
|
| ACTION_P(VerifyResult, expected_result) {
|
| EXPECT_EQ(arg0.status, expected_result.status);
|
| EXPECT_TRUE(arg0.requested_types.Equals(expected_result.requested_types));
|
| - EXPECT_EQ(arg0.failed_data_types.size(),
|
| - expected_result.failed_data_types.size());
|
| -
|
| - if (arg0.failed_data_types.size() ==
|
| - expected_result.failed_data_types.size()) {
|
| - std::map<syncer::ModelType, syncer::SyncError>::const_iterator it1, it2;
|
| - for (it1 = arg0.failed_data_types.begin(),
|
| - it2 = expected_result.failed_data_types.begin();
|
| - it1 != arg0.failed_data_types.end();
|
| - ++it1, ++it2) {
|
| - EXPECT_EQ((*it1).first, (*it2).first);
|
| - }
|
| - }
|
| -
|
| - EXPECT_TRUE(arg0.unfinished_data_types.Equals(
|
| - expected_result.unfinished_data_types));
|
| }
|
|
|
| class SyncModelAssociationManagerTest : public testing::Test {
|
| @@ -79,12 +64,7 @@
|
| ModelAssociationManager model_association_manager(&controllers_,
|
| &delegate_);
|
| syncer::ModelTypeSet types(syncer::BOOKMARKS, syncer::APPS);
|
| - DataTypeManager::ConfigureResult expected_result(
|
| - DataTypeManager::OK,
|
| - types,
|
| - std::map<syncer::ModelType, syncer::SyncError>(),
|
| - syncer::ModelTypeSet(),
|
| - syncer::ModelTypeSet());
|
| + DataTypeManager::ConfigureResult expected_result(DataTypeManager::OK, types);
|
| EXPECT_CALL(delegate_, OnModelAssociationDone(_)).
|
| WillOnce(VerifyResult(expected_result));
|
|
|
| @@ -124,24 +104,13 @@
|
| syncer::ModelTypeSet types;
|
| types.Put(syncer::BOOKMARKS);
|
|
|
| - std::map<syncer::ModelType, syncer::SyncError> errors;
|
| - syncer::SyncError error(FROM_HERE,
|
| - syncer::SyncError::DATATYPE_ERROR,
|
| - "Failed",
|
| - syncer::BOOKMARKS);
|
| - errors[syncer::BOOKMARKS] = error;
|
| + DataTypeManager::ConfigureResult expected_result(DataTypeManager::ABORTED,
|
| + types);
|
|
|
| - DataTypeManager::ConfigureResult expected_result(
|
| - DataTypeManager::ABORTED,
|
| - types,
|
| - errors,
|
| - syncer::ModelTypeSet(syncer::BOOKMARKS),
|
| - syncer::ModelTypeSet());
|
| -
|
| EXPECT_CALL(delegate_, OnModelAssociationDone(_)).
|
| WillOnce(VerifyResult(expected_result));
|
| EXPECT_CALL(delegate_,
|
| - OnSingleDataTypeWillStop(syncer::BOOKMARKS));
|
| + OnSingleDataTypeWillStop(syncer::BOOKMARKS, _));
|
|
|
| model_association_manager.Initialize(types);
|
| model_association_manager.StartAssociationAsync(types);
|
| @@ -162,16 +131,11 @@
|
| &delegate_);
|
| syncer::ModelTypeSet types;
|
| types.Put(syncer::BOOKMARKS);
|
| - DataTypeManager::ConfigureResult expected_result(
|
| - DataTypeManager::OK,
|
| - types,
|
| - std::map<syncer::ModelType, syncer::SyncError>(),
|
| - syncer::ModelTypeSet(),
|
| - syncer::ModelTypeSet());
|
| + DataTypeManager::ConfigureResult expected_result(DataTypeManager::OK, types);
|
| EXPECT_CALL(delegate_, OnModelAssociationDone(_)).
|
| WillOnce(VerifyResult(expected_result));
|
| EXPECT_CALL(delegate_,
|
| - OnSingleDataTypeWillStop(syncer::BOOKMARKS));
|
| + OnSingleDataTypeWillStop(syncer::BOOKMARKS, _));
|
|
|
| model_association_manager.Initialize(types);
|
| model_association_manager.StartAssociationAsync(types);
|
| @@ -195,18 +159,9 @@
|
| &delegate_);
|
| syncer::ModelTypeSet types;
|
| types.Put(syncer::BOOKMARKS);
|
| - std::map<syncer::ModelType, syncer::SyncError> errors;
|
| - syncer::SyncError error(FROM_HERE,
|
| - syncer::SyncError::DATATYPE_ERROR,
|
| - "Failed",
|
| - syncer::BOOKMARKS);
|
| - errors[syncer::BOOKMARKS] = error;
|
| - DataTypeManager::ConfigureResult expected_result(
|
| - DataTypeManager::PARTIAL_SUCCESS,
|
| - types,
|
| - errors,
|
| - syncer::ModelTypeSet(),
|
| - syncer::ModelTypeSet());
|
| + DataTypeManager::ConfigureResult expected_result(DataTypeManager::OK, types);
|
| + EXPECT_CALL(delegate_,
|
| + OnSingleDataTypeWillStop(syncer::BOOKMARKS, _));
|
| EXPECT_CALL(delegate_, OnModelAssociationDone(_)).
|
| WillOnce(VerifyResult(expected_result));
|
|
|
| @@ -230,18 +185,10 @@
|
| &delegate_);
|
| syncer::ModelTypeSet types;
|
| types.Put(syncer::BOOKMARKS);
|
| - std::map<syncer::ModelType, syncer::SyncError> errors;
|
| - syncer::SyncError error(FROM_HERE,
|
| - syncer::SyncError::DATATYPE_ERROR,
|
| - "Failed",
|
| - syncer::BOOKMARKS);
|
| - errors[syncer::BOOKMARKS] = error;
|
| DataTypeManager::ConfigureResult expected_result(
|
| - DataTypeManager::UNRECOVERABLE_ERROR,
|
| - types,
|
| - errors,
|
| - syncer::ModelTypeSet(),
|
| - syncer::ModelTypeSet());
|
| + DataTypeManager::UNRECOVERABLE_ERROR, types);
|
| + EXPECT_CALL(delegate_,
|
| + OnSingleDataTypeWillStop(syncer::BOOKMARKS, _));
|
| EXPECT_CALL(delegate_, OnModelAssociationDone(_)).
|
| WillOnce(VerifyResult(expected_result));
|
|
|
| @@ -267,21 +214,10 @@
|
| types.Put(syncer::BOOKMARKS);
|
| types.Put(syncer::APPS);
|
|
|
| - std::map<syncer::ModelType, syncer::SyncError> errors;
|
| - syncer::SyncError error(FROM_HERE,
|
| - syncer::SyncError::DATATYPE_ERROR,
|
| - "Association timed out.",
|
| - syncer::BOOKMARKS);
|
| - errors[syncer::BOOKMARKS] = error;
|
| -
|
| syncer::ModelTypeSet expected_types_unfinished;
|
| expected_types_unfinished.Put(syncer::BOOKMARKS);
|
| DataTypeManager::ConfigureResult expected_result_partially_done(
|
| - DataTypeManager::PARTIAL_SUCCESS,
|
| - types,
|
| - errors,
|
| - expected_types_unfinished,
|
| - syncer::ModelTypeSet());
|
| + DataTypeManager::OK, types);
|
|
|
| EXPECT_CALL(delegate_, OnModelAssociationDone(_)).
|
| WillOnce(VerifyResult(expected_result_partially_done));
|
| @@ -291,6 +227,8 @@
|
| GetController(controllers_, syncer::APPS)->FinishStart(
|
| DataTypeController::OK);
|
|
|
| + EXPECT_CALL(delegate_,
|
| + OnSingleDataTypeWillStop(syncer::BOOKMARKS, _));
|
| model_association_manager.GetTimerForTesting()->user_task().Run();
|
|
|
| EXPECT_EQ(DataTypeController::NOT_RUNNING,
|
| @@ -310,16 +248,10 @@
|
|
|
| DataTypeManager::ConfigureResult result_1st(
|
| DataTypeManager::OK,
|
| - syncer::ModelTypeSet(syncer::BOOKMARKS),
|
| - std::map<syncer::ModelType, syncer::SyncError>(),
|
| - syncer::ModelTypeSet(),
|
| - syncer::ModelTypeSet());
|
| + syncer::ModelTypeSet(syncer::BOOKMARKS));
|
| DataTypeManager::ConfigureResult result_2nd(
|
| DataTypeManager::OK,
|
| - syncer::ModelTypeSet(syncer::APPS),
|
| - std::map<syncer::ModelType, syncer::SyncError>(),
|
| - syncer::ModelTypeSet(),
|
| - syncer::ModelTypeSet());
|
| + syncer::ModelTypeSet(syncer::APPS));
|
| EXPECT_CALL(delegate_, OnModelAssociationDone(_)).
|
| Times(2).
|
| WillOnce(VerifyResult(result_1st)).
|
| @@ -367,27 +299,48 @@
|
| &delegate_);
|
| syncer::ModelTypeSet types;
|
| types.Put(syncer::BOOKMARKS);
|
| - std::map<syncer::ModelType, syncer::SyncError> errors;
|
| - syncer::SyncError error(FROM_HERE,
|
| - syncer::SyncError::DATATYPE_ERROR,
|
| - "Failed",
|
| - syncer::BOOKMARKS);
|
| - errors[syncer::BOOKMARKS] = error;
|
| - DataTypeManager::ConfigureResult expected_result(
|
| - DataTypeManager::PARTIAL_SUCCESS,
|
| - types,
|
| - errors,
|
| - syncer::ModelTypeSet(),
|
| - syncer::ModelTypeSet());
|
| + DataTypeManager::ConfigureResult expected_result(DataTypeManager::OK, types);
|
| + EXPECT_CALL(delegate_,
|
| + OnSingleDataTypeWillStop(syncer::BOOKMARKS, _));
|
| EXPECT_CALL(delegate_, OnModelAssociationDone(_)).
|
| WillOnce(VerifyResult(expected_result));
|
|
|
| model_association_manager.Initialize(types);
|
| - EXPECT_EQ(DataTypeController::DISABLED,
|
| + EXPECT_EQ(DataTypeController::NOT_RUNNING,
|
| GetController(controllers_, syncer::BOOKMARKS)->state());
|
| model_association_manager.StartAssociationAsync(types);
|
| EXPECT_EQ(DataTypeController::NOT_RUNNING,
|
| GetController(controllers_, syncer::BOOKMARKS)->state());
|
| }
|
|
|
| +// Test that a runtime error is handled by stopping the type.
|
| +TEST_F(SyncModelAssociationManagerTest, StopAfterConfiguration) {
|
| + controllers_[syncer::BOOKMARKS] =
|
| + new FakeDataTypeController(syncer::BOOKMARKS);
|
| + ModelAssociationManager model_association_manager(
|
| + &controllers_,
|
| + &delegate_);
|
| + syncer::ModelTypeSet types;
|
| + types.Put(syncer::BOOKMARKS);
|
| + DataTypeManager::ConfigureResult expected_result(DataTypeManager::OK, types);
|
| + EXPECT_CALL(delegate_, OnModelAssociationDone(_)).
|
| + WillOnce(VerifyResult(expected_result));
|
| +
|
| + model_association_manager.Initialize(types);
|
| + model_association_manager.StartAssociationAsync(types);
|
| +
|
| + EXPECT_EQ(GetController(controllers_, syncer::BOOKMARKS)->state(),
|
| + DataTypeController::ASSOCIATING);
|
| + GetController(controllers_, syncer::BOOKMARKS)->FinishStart(
|
| + DataTypeController::OK);
|
| + EXPECT_EQ(GetController(controllers_, syncer::BOOKMARKS)->state(),
|
| + DataTypeController::RUNNING);
|
| +
|
| + testing::Mock::VerifyAndClearExpectations(&delegate_);
|
| + EXPECT_CALL(delegate_,
|
| + OnSingleDataTypeWillStop(syncer::BOOKMARKS, _));
|
| + GetController(controllers_, syncer::BOOKMARKS)
|
| + ->OnSingleDatatypeUnrecoverableError(FROM_HERE, "runtime error");
|
| +}
|
| +
|
| } // namespace sync_driver
|
|
|