| 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 c4d2ec2542f779006445bbce2368b3f79c3d69ea..054e2677954bf77d5ca3fec8317d5e55670dc78c 100644
|
| --- a/components/sync_driver/data_type_manager_impl_unittest.cc
|
| +++ b/components/sync_driver/data_type_manager_impl_unittest.cc
|
| @@ -14,11 +14,11 @@
|
| #include "components/sync_driver/fake_data_type_controller.h"
|
| #include "sync/internal_api/public/base/model_type.h"
|
| #include "sync/internal_api/public/configure_reason.h"
|
| +#include "testing/gmock/include/gmock/gmock.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| namespace sync_driver {
|
|
|
| -using syncer::SyncError;
|
| using syncer::ModelType;
|
| using syncer::ModelTypeSet;
|
| using syncer::ModelTypeToString;
|
| @@ -27,48 +27,25 @@ using syncer::APPS;
|
| using syncer::PASSWORDS;
|
| using syncer::PREFERENCES;
|
| using syncer::NIGORI;
|
| +using testing::_;
|
| +using testing::Mock;
|
| +using testing::ResultOf;
|
|
|
| namespace {
|
|
|
| +// Used by SetConfigureDoneExpectation.
|
| +DataTypeManager::ConfigureStatus GetStatus(
|
| + const DataTypeManager::ConfigureResult& result) {
|
| + return result.status;
|
| +}
|
| +
|
| // Helper for unioning with priority types.
|
| -ModelTypeSet AddHighPriorityTypesTo(ModelTypeSet types) {
|
| - ModelTypeSet result = syncer::ControlTypes();
|
| +syncer::ModelTypeSet AddHighPriorityTypesTo(syncer::ModelTypeSet types) {
|
| + syncer::ModelTypeSet result = syncer::ControlTypes();
|
| result.PutAll(types);
|
| return result;
|
| }
|
|
|
| -DataTypeStatusTable BuildStatusTable(ModelTypeSet crypto_errors,
|
| - ModelTypeSet association_errors,
|
| - ModelTypeSet unready_errors,
|
| - ModelTypeSet unrecoverable_errors) {
|
| - DataTypeStatusTable::TypeErrorMap error_map;
|
| - for (ModelTypeSet::Iterator iter = crypto_errors.First(); iter.Good();
|
| - iter.Inc()) {
|
| - error_map[iter.Get()] = SyncError(
|
| - FROM_HERE, SyncError::CRYPTO_ERROR, "crypto error", iter.Get());
|
| - }
|
| - for (ModelTypeSet::Iterator iter = association_errors.First(); iter.Good();
|
| - iter.Inc()) {
|
| - error_map[iter.Get()] = SyncError(
|
| - FROM_HERE, SyncError::DATATYPE_ERROR, "association error", iter.Get());
|
| - }
|
| - for (ModelTypeSet::Iterator iter = unready_errors.First(); iter.Good();
|
| - iter.Inc()) {
|
| - error_map[iter.Get()] = SyncError(
|
| - FROM_HERE, SyncError::UNREADY_ERROR, "unready errors", iter.Get());
|
| - }
|
| - for (ModelTypeSet::Iterator iter = unrecoverable_errors.First(); iter.Good();
|
| - iter.Inc()) {
|
| - error_map[iter.Get()] = SyncError(FROM_HERE,
|
| - SyncError::UNRECOVERABLE_ERROR,
|
| - "unrecoverable errors",
|
| - iter.Get());
|
| - }
|
| - DataTypeStatusTable status_table;
|
| - status_table.UpdateFailedDataTypes(error_map);
|
| - return status_table;
|
| -}
|
| -
|
| // Fake BackendDataTypeConfigurer implementation that simply stores away the
|
| // callback passed into ConfigureDataTypes.
|
| class FakeBackendDataTypeConfigurer : public BackendDataTypeConfigurer {
|
| @@ -88,9 +65,9 @@ class FakeBackendDataTypeConfigurer : public BackendDataTypeConfigurer {
|
| EXPECT_TRUE(
|
| expected_configure_types_.Equals(
|
| GetDataTypesInState(CONFIGURE_ACTIVE, config_state_map)))
|
| - << ModelTypeSetToString(expected_configure_types_)
|
| + << syncer::ModelTypeSetToString(expected_configure_types_)
|
| << " v.s. "
|
| - << ModelTypeSetToString(
|
| + << syncer::ModelTypeSetToString(
|
| GetDataTypesInState(CONFIGURE_ACTIVE, config_state_map));
|
| }
|
| }
|
| @@ -108,72 +85,28 @@ class FakeBackendDataTypeConfigurer : public BackendDataTypeConfigurer {
|
| return last_ready_task_;
|
| }
|
|
|
| - void set_expected_configure_types(ModelTypeSet types) {
|
| + void set_expected_configure_types(syncer::ModelTypeSet types) {
|
| expected_configure_types_ = types;
|
| }
|
|
|
| - const ModelTypeSet activated_types() { return activated_types_; }
|
| + const syncer::ModelTypeSet activated_types() { return activated_types_; }
|
|
|
| private:
|
| base::Callback<void(ModelTypeSet, ModelTypeSet)> last_ready_task_;
|
| - ModelTypeSet expected_configure_types_;
|
| - ModelTypeSet activated_types_;
|
| + syncer::ModelTypeSet expected_configure_types_;
|
| + syncer::ModelTypeSet activated_types_;
|
| };
|
|
|
| -// DataTypeManagerObserver implementation.
|
| -class FakeDataTypeManagerObserver : public DataTypeManagerObserver {
|
| +// Mock DataTypeManagerObserver implementation.
|
| +class DataTypeManagerObserverMock : public DataTypeManagerObserver {
|
| public:
|
| - FakeDataTypeManagerObserver() { ResetExpectations(); }
|
| - virtual ~FakeDataTypeManagerObserver() {
|
| - EXPECT_FALSE(start_expected_);
|
| - DataTypeManager::ConfigureResult default_result;
|
| - EXPECT_EQ(done_expectation_.status, default_result.status);
|
| - EXPECT_TRUE(
|
| - done_expectation_.data_type_status_table.GetFailedTypes().Empty());
|
| - }
|
| -
|
| - void ExpectStart() {
|
| - start_expected_ = true;
|
| - }
|
| - void ExpectDone(const DataTypeManager::ConfigureResult& result) {
|
| - done_expectation_ = result;
|
| - }
|
| - void ResetExpectations() {
|
| - start_expected_ = false;
|
| - done_expectation_ = DataTypeManager::ConfigureResult();
|
| - }
|
| -
|
| - virtual void OnConfigureDone(
|
| - const DataTypeManager::ConfigureResult& result) OVERRIDE {
|
| - EXPECT_EQ(done_expectation_.status, result.status);
|
| - DataTypeStatusTable::TypeErrorMap errors =
|
| - result.data_type_status_table.GetAllErrors();
|
| - DataTypeStatusTable::TypeErrorMap expected_errors =
|
| - done_expectation_.data_type_status_table.GetAllErrors();
|
| - ASSERT_EQ(expected_errors.size(), errors.size());
|
| - for (DataTypeStatusTable::TypeErrorMap::const_iterator iter =
|
| - expected_errors.begin();
|
| - iter != expected_errors.end();
|
| - ++iter) {
|
| - ASSERT_TRUE(errors.find(iter->first) != errors.end());
|
| - ASSERT_EQ(iter->second.error_type(),
|
| - errors.find(iter->first)->second.error_type());
|
| - }
|
| - done_expectation_ = DataTypeManager::ConfigureResult();
|
| - }
|
| -
|
| - virtual void OnConfigureRetry() OVERRIDE{
|
| - // Not verified.
|
| - }
|
| -
|
| - virtual void OnConfigureStart() OVERRIDE {
|
| - EXPECT_TRUE(start_expected_);
|
| - start_expected_ = false;
|
| - }
|
| + DataTypeManagerObserverMock() {}
|
| + virtual ~DataTypeManagerObserverMock() {}
|
|
|
| - private:
|
| - bool start_expected_ = true;
|
| - DataTypeManager::ConfigureResult done_expectation_;
|
| + MOCK_METHOD1(OnConfigureDone,
|
| + void(const DataTypeManager::ConfigureResult&));
|
| + MOCK_METHOD0(OnConfigureRetry, void());
|
| + MOCK_METHOD0(OnConfigureStart, void());
|
| };
|
|
|
| class FakeDataTypeEncryptionHandler : public DataTypeEncryptionHandler {
|
| @@ -182,17 +115,17 @@ class FakeDataTypeEncryptionHandler : public DataTypeEncryptionHandler {
|
| virtual ~FakeDataTypeEncryptionHandler();
|
|
|
| virtual bool IsPassphraseRequired() const OVERRIDE;
|
| - virtual ModelTypeSet GetEncryptedDataTypes() const OVERRIDE;
|
| + virtual syncer::ModelTypeSet GetEncryptedDataTypes() const OVERRIDE;
|
|
|
| void set_passphrase_required(bool passphrase_required) {
|
| passphrase_required_ = passphrase_required;
|
| }
|
| - void set_encrypted_types(ModelTypeSet encrypted_types) {
|
| + void set_encrypted_types(syncer::ModelTypeSet encrypted_types) {
|
| encrypted_types_ = encrypted_types;
|
| }
|
| private:
|
| bool passphrase_required_;
|
| - ModelTypeSet encrypted_types_;
|
| + syncer::ModelTypeSet encrypted_types_;
|
| };
|
|
|
| FakeDataTypeEncryptionHandler::FakeDataTypeEncryptionHandler()
|
| @@ -203,7 +136,7 @@ bool FakeDataTypeEncryptionHandler::IsPassphraseRequired() const {
|
| return passphrase_required_;
|
| }
|
|
|
| -ModelTypeSet
|
| +syncer::ModelTypeSet
|
| FakeDataTypeEncryptionHandler::GetEncryptedDataTypes() const {
|
| return encrypted_types_;
|
| }
|
| @@ -218,16 +151,18 @@ class TestDataTypeManager : public DataTypeManagerImpl {
|
| BackendDataTypeConfigurer* configurer,
|
| const DataTypeController::TypeMap* controllers,
|
| const DataTypeEncryptionHandler* encryption_handler,
|
| - DataTypeManagerObserver* observer)
|
| + DataTypeManagerObserver* observer,
|
| + DataTypeStatusTable* data_type_status_table)
|
| : DataTypeManagerImpl(base::Closure(),
|
| debug_info_listener,
|
| controllers,
|
| encryption_handler,
|
| configurer,
|
| - observer),
|
| + observer,
|
| + data_type_status_table),
|
| custom_priority_types_(syncer::ControlTypes()) {}
|
|
|
| - void set_priority_types(const ModelTypeSet& priority_types) {
|
| + void set_priority_types(const syncer::ModelTypeSet& priority_types) {
|
| custom_priority_types_ = priority_types;
|
| }
|
|
|
| @@ -242,11 +177,11 @@ class TestDataTypeManager : public DataTypeManagerImpl {
|
| }
|
|
|
| private:
|
| - virtual ModelTypeSet GetPriorityTypes() const OVERRIDE {
|
| + virtual syncer::ModelTypeSet GetPriorityTypes() const OVERRIDE {
|
| return custom_priority_types_;
|
| }
|
|
|
| - ModelTypeSet custom_priority_types_;
|
| + syncer::ModelTypeSet custom_priority_types_;
|
| DataTypeManager::ConfigureResult configure_result_;
|
| };
|
|
|
| @@ -267,24 +202,21 @@ class SyncDataTypeManagerImplTest : public testing::Test {
|
| &configurer_,
|
| &controllers_,
|
| &encryption_handler_,
|
| - &observer_));
|
| + &observer_,
|
| + &data_type_status_table_));
|
| }
|
|
|
| void SetConfigureStartExpectation() {
|
| - observer_.ExpectStart();
|
| + EXPECT_CALL(observer_, OnConfigureStart());
|
| }
|
|
|
| - void SetConfigureDoneExpectation(DataTypeManager::ConfigureStatus status,
|
| - const DataTypeStatusTable& status_table) {
|
| - DataTypeManager::ConfigureResult result;
|
| - result.status = status;
|
| - result.data_type_status_table = status_table;
|
| - observer_.ExpectDone(result);
|
| + void SetConfigureDoneExpectation(DataTypeManager::ConfigureStatus status) {
|
| + EXPECT_CALL(observer_, OnConfigureDone(ResultOf(&GetStatus, status)));
|
| }
|
|
|
| // Configure the given DTM with the given desired types.
|
| void Configure(DataTypeManagerImpl* dtm,
|
| - const ModelTypeSet& desired_types) {
|
| + const syncer::ModelTypeSet& desired_types) {
|
| dtm->Configure(desired_types, syncer::CONFIGURE_REASON_RECONFIGURATION);
|
| }
|
|
|
| @@ -320,7 +252,7 @@ class SyncDataTypeManagerImplTest : public testing::Test {
|
| static_cast<FakeDataTypeController*>(it->second.get()));
|
| }
|
|
|
| - void FailEncryptionFor(ModelTypeSet encrypted_types) {
|
| + void FailEncryptionFor(syncer::ModelTypeSet encrypted_types) {
|
| encryption_handler_.set_passphrase_required(true);
|
| encryption_handler_.set_encrypted_types(encrypted_types);
|
| }
|
| @@ -328,8 +260,9 @@ class SyncDataTypeManagerImplTest : public testing::Test {
|
| base::MessageLoopForUI ui_loop_;
|
| DataTypeController::TypeMap controllers_;
|
| FakeBackendDataTypeConfigurer configurer_;
|
| - FakeDataTypeManagerObserver observer_;
|
| + DataTypeManagerObserverMock observer_;
|
| scoped_ptr<TestDataTypeManager> dtm_;
|
| + DataTypeStatusTable data_type_status_table_;
|
| FakeDataTypeEncryptionHandler encryption_handler_;
|
| };
|
|
|
| @@ -337,7 +270,7 @@ class SyncDataTypeManagerImplTest : public testing::Test {
|
| // and then stop it.
|
| TEST_F(SyncDataTypeManagerImplTest, NoControllers) {
|
| SetConfigureStartExpectation();
|
| - SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
|
| + SetConfigureDoneExpectation(DataTypeManager::OK);
|
|
|
| Configure(dtm_.get(), ModelTypeSet());
|
| EXPECT_EQ(DataTypeManager::DOWNLOAD_PENDING, dtm_->state());
|
| @@ -355,7 +288,7 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureOne) {
|
| AddController(BOOKMARKS);
|
|
|
| SetConfigureStartExpectation();
|
| - SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
|
| + SetConfigureDoneExpectation(DataTypeManager::OK);
|
|
|
| Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
|
| EXPECT_EQ(DataTypeManager::DOWNLOAD_PENDING, dtm_->state());
|
| @@ -381,8 +314,7 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureOneStopWhileDownloadPending) {
|
|
|
| {
|
| SetConfigureStartExpectation();
|
| - SetConfigureDoneExpectation(DataTypeManager::ABORTED,
|
| - DataTypeStatusTable());
|
| + SetConfigureDoneExpectation(DataTypeManager::ABORTED);
|
|
|
| Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
|
| EXPECT_EQ(DataTypeManager::DOWNLOAD_PENDING, dtm_->state());
|
| @@ -404,8 +336,7 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureOneStopWhileStartingModel) {
|
|
|
| {
|
| SetConfigureStartExpectation();
|
| - SetConfigureDoneExpectation(DataTypeManager::ABORTED,
|
| - DataTypeStatusTable());
|
| + SetConfigureDoneExpectation(DataTypeManager::ABORTED);
|
|
|
| Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
|
| EXPECT_EQ(DataTypeManager::DOWNLOAD_PENDING, dtm_->state());
|
| @@ -433,8 +364,7 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureOneStopWhileAssociating) {
|
|
|
| {
|
| SetConfigureStartExpectation();
|
| - SetConfigureDoneExpectation(DataTypeManager::ABORTED,
|
| - DataTypeStatusTable());
|
| + SetConfigureDoneExpectation(DataTypeManager::ABORTED);
|
|
|
| Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
|
| EXPECT_EQ(DataTypeManager::DOWNLOAD_PENDING, dtm_->state());
|
| @@ -464,11 +394,7 @@ TEST_F(SyncDataTypeManagerImplTest, OneWaitingForCrypto) {
|
| AddController(PASSWORDS);
|
|
|
| SetConfigureStartExpectation();
|
| - SetConfigureDoneExpectation(DataTypeManager::OK,
|
| - BuildStatusTable(ModelTypeSet(PASSWORDS),
|
| - ModelTypeSet(),
|
| - ModelTypeSet(),
|
| - ModelTypeSet()));
|
| + SetConfigureDoneExpectation(DataTypeManager::OK);
|
|
|
| const ModelTypeSet types(PASSWORDS);
|
| dtm_->set_priority_types(AddHighPriorityTypesTo(types));
|
| @@ -509,7 +435,7 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureOneThenBoth) {
|
| AddController(PREFERENCES);
|
|
|
| SetConfigureStartExpectation();
|
| - SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
|
| + SetConfigureDoneExpectation(DataTypeManager::OK);
|
|
|
| // Step 1.
|
| Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
|
| @@ -524,9 +450,9 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureOneThenBoth) {
|
| GetController(BOOKMARKS)->FinishStart(DataTypeController::OK);
|
| EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
|
|
|
| - observer_.ResetExpectations();
|
| + Mock::VerifyAndClearExpectations(&observer_);
|
| SetConfigureStartExpectation();
|
| - SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
|
| + SetConfigureDoneExpectation(DataTypeManager::OK);
|
|
|
| // Step 4.
|
| Configure(dtm_.get(), ModelTypeSet(BOOKMARKS, PREFERENCES));
|
| @@ -562,7 +488,7 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureOneThenSwitch) {
|
| AddController(PREFERENCES);
|
|
|
| SetConfigureStartExpectation();
|
| - SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
|
| + SetConfigureDoneExpectation(DataTypeManager::OK);
|
|
|
| // Step 1.
|
| Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
|
| @@ -577,9 +503,9 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureOneThenSwitch) {
|
| GetController(BOOKMARKS)->FinishStart(DataTypeController::OK);
|
| EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
|
|
|
| - observer_.ResetExpectations();
|
| + Mock::VerifyAndClearExpectations(&observer_);
|
| SetConfigureStartExpectation();
|
| - SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
|
| + SetConfigureDoneExpectation(DataTypeManager::OK);
|
|
|
| // Step 4.
|
| Configure(dtm_.get(), ModelTypeSet(PREFERENCES));
|
| @@ -615,7 +541,7 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureWhileOneInFlight) {
|
| AddController(PREFERENCES);
|
|
|
| SetConfigureStartExpectation();
|
| - SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
|
| + SetConfigureDoneExpectation(DataTypeManager::OK);
|
|
|
| // Step 1.
|
| Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
|
| @@ -657,11 +583,7 @@ TEST_F(SyncDataTypeManagerImplTest, OneFailingController) {
|
| AddController(BOOKMARKS);
|
|
|
| SetConfigureStartExpectation();
|
| - SetConfigureDoneExpectation(DataTypeManager::UNRECOVERABLE_ERROR,
|
| - BuildStatusTable(ModelTypeSet(),
|
| - ModelTypeSet(),
|
| - ModelTypeSet(),
|
| - ModelTypeSet(BOOKMARKS)));
|
| + SetConfigureDoneExpectation(DataTypeManager::UNRECOVERABLE_ERROR);
|
|
|
| Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
|
| EXPECT_EQ(DataTypeManager::DOWNLOAD_PENDING, dtm_->state());
|
| @@ -690,11 +612,7 @@ TEST_F(SyncDataTypeManagerImplTest, SecondControllerFails) {
|
| AddController(PREFERENCES);
|
|
|
| SetConfigureStartExpectation();
|
| - SetConfigureDoneExpectation(DataTypeManager::UNRECOVERABLE_ERROR,
|
| - BuildStatusTable(ModelTypeSet(),
|
| - ModelTypeSet(),
|
| - ModelTypeSet(),
|
| - ModelTypeSet(PREFERENCES)));
|
| + SetConfigureDoneExpectation(DataTypeManager::UNRECOVERABLE_ERROR);
|
|
|
| // Step 1.
|
| Configure(dtm_.get(), ModelTypeSet(BOOKMARKS, PREFERENCES));
|
| @@ -733,11 +651,7 @@ TEST_F(SyncDataTypeManagerImplTest, OneControllerFailsAssociation) {
|
| AddController(PREFERENCES);
|
|
|
| SetConfigureStartExpectation();
|
| - SetConfigureDoneExpectation(DataTypeManager::OK,
|
| - BuildStatusTable(ModelTypeSet(),
|
| - ModelTypeSet(PREFERENCES),
|
| - ModelTypeSet(),
|
| - ModelTypeSet()));
|
| + SetConfigureDoneExpectation(DataTypeManager::OK);
|
|
|
| // Step 1.
|
| Configure(dtm_.get(), ModelTypeSet(BOOKMARKS, PREFERENCES));
|
| @@ -782,7 +696,7 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureWhileDownloadPending) {
|
| AddController(PREFERENCES);
|
|
|
| SetConfigureStartExpectation();
|
| - SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
|
| + SetConfigureDoneExpectation(DataTypeManager::OK);
|
|
|
| // Step 1.
|
| Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
|
| @@ -828,7 +742,7 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureWhileDownloadPendingWithFailure) {
|
| AddController(PREFERENCES);
|
|
|
| SetConfigureStartExpectation();
|
| - SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
|
| + SetConfigureDoneExpectation(DataTypeManager::OK);
|
|
|
| // Step 1.
|
| Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
|
| @@ -866,7 +780,7 @@ TEST_F(SyncDataTypeManagerImplTest, MigrateAll) {
|
| dtm_->set_priority_types(AddHighPriorityTypesTo(ModelTypeSet(BOOKMARKS)));
|
|
|
| SetConfigureStartExpectation();
|
| - SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
|
| + SetConfigureDoneExpectation(DataTypeManager::OK);
|
|
|
| // Initial setup.
|
| Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
|
| @@ -875,7 +789,7 @@ TEST_F(SyncDataTypeManagerImplTest, MigrateAll) {
|
|
|
| // We've now configured bookmarks and (implicitly) the control types.
|
| EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
|
| - observer_.ResetExpectations();
|
| + Mock::VerifyAndClearExpectations(&observer_);
|
|
|
| // Pretend we were told to migrate all types.
|
| ModelTypeSet to_migrate;
|
| @@ -883,7 +797,7 @@ TEST_F(SyncDataTypeManagerImplTest, MigrateAll) {
|
| to_migrate.PutAll(syncer::ControlTypes());
|
|
|
| SetConfigureStartExpectation();
|
| - SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
|
| + SetConfigureDoneExpectation(DataTypeManager::OK);
|
| dtm_->PurgeForMigration(to_migrate,
|
| syncer::CONFIGURE_REASON_MIGRATION);
|
| EXPECT_EQ(DataTypeManager::DOWNLOAD_PENDING, dtm_->state());
|
| @@ -891,11 +805,11 @@ TEST_F(SyncDataTypeManagerImplTest, MigrateAll) {
|
| // The DTM will call ConfigureDataTypes(), even though it is unnecessary.
|
| FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
|
| EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
|
| - observer_.ResetExpectations();
|
| + Mock::VerifyAndClearExpectations(&observer_);
|
|
|
| // Re-enable the migrated types.
|
| SetConfigureStartExpectation();
|
| - SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
|
| + SetConfigureDoneExpectation(DataTypeManager::OK);
|
| Configure(dtm_.get(), to_migrate);
|
| FinishDownload(*dtm_, to_migrate, ModelTypeSet());
|
| GetController(BOOKMARKS)->FinishStart(DataTypeController::OK);
|
| @@ -909,20 +823,20 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureDuringPurge) {
|
|
|
| // Initial configure.
|
| SetConfigureStartExpectation();
|
| - SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
|
| + SetConfigureDoneExpectation(DataTypeManager::OK);
|
| Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
|
| FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
|
| FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
|
| GetController(BOOKMARKS)->FinishStart(DataTypeController::OK);
|
| EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
|
| - observer_.ResetExpectations();
|
| + Mock::VerifyAndClearExpectations(&observer_);
|
|
|
| // Purge the Nigori type.
|
| SetConfigureStartExpectation();
|
| dtm_->PurgeForMigration(ModelTypeSet(NIGORI),
|
| syncer::CONFIGURE_REASON_MIGRATION);
|
| EXPECT_EQ(DataTypeManager::DOWNLOAD_PENDING, dtm_->state());
|
| - observer_.ResetExpectations();
|
| + Mock::VerifyAndClearExpectations(&observer_);
|
|
|
| // Before the backend configuration completes, ask for a different
|
| // set of types. This request asks for
|
| @@ -935,9 +849,9 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureDuringPurge) {
|
|
|
| // Invoke the callback we've been waiting for since we asked to purge NIGORI.
|
| FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
|
| - observer_.ResetExpectations();
|
| + Mock::VerifyAndClearExpectations(&observer_);
|
|
|
| - SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
|
| + SetConfigureDoneExpectation(DataTypeManager::OK);
|
| EXPECT_EQ(DataTypeManager::DOWNLOAD_PENDING, dtm_->state());
|
|
|
| // Now invoke the callback for the second configure request.
|
| @@ -957,11 +871,11 @@ TEST_F(SyncDataTypeManagerImplTest, PrioritizedConfiguration) {
|
| AddController(PREFERENCES);
|
|
|
| dtm_->set_priority_types(
|
| - AddHighPriorityTypesTo(ModelTypeSet(PREFERENCES)));
|
| + AddHighPriorityTypesTo(syncer::ModelTypeSet(PREFERENCES)));
|
|
|
| // Initial configure.
|
| SetConfigureStartExpectation();
|
| - SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
|
| + SetConfigureDoneExpectation(DataTypeManager::OK);
|
|
|
| // Initially only PREFERENCES is configured.
|
| configurer_.set_expected_configure_types(
|
| @@ -988,11 +902,11 @@ TEST_F(SyncDataTypeManagerImplTest, PrioritizedConfigurationReconfigure) {
|
| AddController(APPS);
|
|
|
| dtm_->set_priority_types(
|
| - AddHighPriorityTypesTo(ModelTypeSet(PREFERENCES)));
|
| + AddHighPriorityTypesTo(syncer::ModelTypeSet(PREFERENCES)));
|
|
|
| // Initial configure.
|
| SetConfigureStartExpectation();
|
| - SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
|
| + SetConfigureDoneExpectation(DataTypeManager::OK);
|
|
|
| // Reconfigure while associating PREFERENCES and downloading BOOKMARKS.
|
| configurer_.set_expected_configure_types(
|
| @@ -1035,11 +949,11 @@ TEST_F(SyncDataTypeManagerImplTest, PrioritizedConfigurationStop) {
|
| AddController(PREFERENCES);
|
|
|
| dtm_->set_priority_types(
|
| - AddHighPriorityTypesTo(ModelTypeSet(PREFERENCES)));
|
| + AddHighPriorityTypesTo(syncer::ModelTypeSet(PREFERENCES)));
|
|
|
| // Initial configure.
|
| SetConfigureStartExpectation();
|
| - SetConfigureDoneExpectation(DataTypeManager::ABORTED, DataTypeStatusTable());
|
| + SetConfigureDoneExpectation(DataTypeManager::ABORTED);
|
|
|
| // Initially only PREFERENCES is configured.
|
| configurer_.set_expected_configure_types(
|
| @@ -1070,15 +984,11 @@ TEST_F(SyncDataTypeManagerImplTest, PrioritizedConfigurationDownloadError) {
|
| AddController(PREFERENCES);
|
|
|
| dtm_->set_priority_types(
|
| - AddHighPriorityTypesTo(ModelTypeSet(PREFERENCES)));
|
| + AddHighPriorityTypesTo(syncer::ModelTypeSet(PREFERENCES)));
|
|
|
| // Initial configure.
|
| SetConfigureStartExpectation();
|
| - SetConfigureDoneExpectation(DataTypeManager::UNRECOVERABLE_ERROR,
|
| - BuildStatusTable(ModelTypeSet(),
|
| - ModelTypeSet(),
|
| - ModelTypeSet(),
|
| - ModelTypeSet(BOOKMARKS)));
|
| + SetConfigureDoneExpectation(DataTypeManager::UNRECOVERABLE_ERROR);
|
|
|
| // Initially only PREFERENCES is configured.
|
| configurer_.set_expected_configure_types(
|
| @@ -1110,15 +1020,11 @@ TEST_F(SyncDataTypeManagerImplTest, HighPriorityAssociationFailure) {
|
| AddController(BOOKMARKS); // Will succeed.
|
|
|
| dtm_->set_priority_types(
|
| - AddHighPriorityTypesTo(ModelTypeSet(PREFERENCES)));
|
| + AddHighPriorityTypesTo(syncer::ModelTypeSet(PREFERENCES)));
|
|
|
| // Initial configure.
|
| SetConfigureStartExpectation();
|
| - SetConfigureDoneExpectation(DataTypeManager::OK,
|
| - BuildStatusTable(ModelTypeSet(),
|
| - ModelTypeSet(PREFERENCES),
|
| - ModelTypeSet(),
|
| - ModelTypeSet()));
|
| + SetConfigureDoneExpectation(DataTypeManager::OK);
|
|
|
| // Initially only PREFERENCES is configured.
|
| configurer_.set_expected_configure_types(
|
| @@ -1166,15 +1072,11 @@ TEST_F(SyncDataTypeManagerImplTest, LowPriorityAssociationFailure) {
|
| AddController(BOOKMARKS); // Will fail.
|
|
|
| dtm_->set_priority_types(
|
| - AddHighPriorityTypesTo(ModelTypeSet(PREFERENCES)));
|
| + AddHighPriorityTypesTo(syncer::ModelTypeSet(PREFERENCES)));
|
|
|
| // Initial configure.
|
| SetConfigureStartExpectation();
|
| - SetConfigureDoneExpectation(DataTypeManager::OK,
|
| - BuildStatusTable(ModelTypeSet(),
|
| - ModelTypeSet(BOOKMARKS),
|
| - ModelTypeSet(),
|
| - ModelTypeSet()));
|
| + SetConfigureDoneExpectation(DataTypeManager::OK);
|
|
|
| // Initially only PREFERENCES is configured.
|
| configurer_.set_expected_configure_types(
|
| @@ -1223,9 +1125,9 @@ TEST_F(SyncDataTypeManagerImplTest, FilterDesiredTypes) {
|
| dtm_->set_priority_types(AddHighPriorityTypesTo(types));
|
|
|
| SetConfigureStartExpectation();
|
| - SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
|
| + SetConfigureDoneExpectation(DataTypeManager::OK);
|
|
|
| - ModelTypeSet expected_types = syncer::ControlTypes();
|
| + syncer::ModelTypeSet expected_types = syncer::ControlTypes();
|
| expected_types.Put(BOOKMARKS);
|
| // APPS is filtered out because there's no controller for it.
|
| configurer_.set_expected_configure_types(expected_types);
|
| @@ -1242,6 +1144,7 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureForBackupRollback) {
|
|
|
| SetConfigureStartExpectation();
|
|
|
| +
|
| ModelTypeSet expected_types = syncer::ControlTypes();
|
| expected_types.Put(BOOKMARKS);
|
| configurer_.set_expected_configure_types(expected_types);
|
| @@ -1252,32 +1155,32 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureForBackupRollback) {
|
| }
|
|
|
| TEST_F(SyncDataTypeManagerImplTest, ReenableAfterDataTypeError) {
|
| + syncer::SyncError error(FROM_HERE,
|
| + syncer::SyncError::DATATYPE_ERROR,
|
| + "Datatype disabled",
|
| + syncer::BOOKMARKS);
|
| + std::map<syncer::ModelType, syncer::SyncError> errors;
|
| + errors[syncer::BOOKMARKS] = error;
|
| + data_type_status_table_.UpdateFailedDataTypes(errors);
|
| +
|
| AddController(PREFERENCES); // Will succeed.
|
| AddController(BOOKMARKS); // Will be disabled due to datatype error.
|
|
|
| SetConfigureStartExpectation();
|
| - SetConfigureDoneExpectation(DataTypeManager::OK,
|
| - BuildStatusTable(ModelTypeSet(),
|
| - ModelTypeSet(BOOKMARKS),
|
| - ModelTypeSet(),
|
| - ModelTypeSet()));
|
| + SetConfigureDoneExpectation(DataTypeManager::OK);
|
|
|
| Configure(dtm_.get(), ModelTypeSet(BOOKMARKS, PREFERENCES));
|
| FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
|
| - FinishDownload(*dtm_, ModelTypeSet(PREFERENCES, BOOKMARKS), ModelTypeSet());
|
| + FinishDownload(*dtm_, ModelTypeSet(PREFERENCES), 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.
|
| EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
|
| EXPECT_EQ(DataTypeController::RUNNING, GetController(PREFERENCES)->state());
|
| EXPECT_EQ(DataTypeController::NOT_RUNNING, GetController(BOOKMARKS)->state());
|
|
|
| - observer_.ResetExpectations();
|
| + Mock::VerifyAndClearExpectations(&observer_);
|
|
|
| // Re-enable bookmarks.
|
| - SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
|
| + SetConfigureDoneExpectation(DataTypeManager::OK);
|
| dtm_->ReenableType(syncer::BOOKMARKS);
|
|
|
| EXPECT_EQ(DataTypeManager::DOWNLOAD_PENDING, dtm_->state());
|
| @@ -1299,21 +1202,17 @@ TEST_F(SyncDataTypeManagerImplTest, UnreadyType) {
|
|
|
| // Bookmarks is never started due to being unready.
|
| SetConfigureStartExpectation();
|
| - SetConfigureDoneExpectation(DataTypeManager::OK,
|
| - BuildStatusTable(ModelTypeSet(),
|
| - ModelTypeSet(),
|
| - ModelTypeSet(BOOKMARKS),
|
| - ModelTypeSet()));
|
| + SetConfigureDoneExpectation(DataTypeManager::OK);
|
| Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
|
| FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
|
| EXPECT_EQ(DataTypeController::NOT_RUNNING, GetController(BOOKMARKS)->state());
|
| EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
|
| EXPECT_EQ(0U, configurer_.activated_types().Size());
|
| - observer_.ResetExpectations();
|
| + Mock::VerifyAndClearExpectations(&observer_);
|
|
|
| // Bookmarks should start normally now.
|
| GetController(BOOKMARKS)->SetReadyForStart(true);
|
| - SetConfigureDoneExpectation(DataTypeManager::OK, DataTypeStatusTable());
|
| + SetConfigureDoneExpectation(DataTypeManager::OK);
|
| dtm_->ReenableType(BOOKMARKS);
|
| EXPECT_EQ(DataTypeManager::DOWNLOAD_PENDING, dtm_->state());
|
|
|
| @@ -1326,7 +1225,7 @@ TEST_F(SyncDataTypeManagerImplTest, UnreadyType) {
|
| EXPECT_EQ(1U, configurer_.activated_types().Size());
|
|
|
| // Should do nothing.
|
| - observer_.ResetExpectations();
|
| + Mock::VerifyAndClearExpectations(&observer_);
|
| dtm_->ReenableType(BOOKMARKS);
|
|
|
| dtm_->Stop();
|
|
|