Chromium Code Reviews| Index: components/sync/model_impl/shared_model_type_processor_unittest.cc |
| diff --git a/components/sync/model_impl/shared_model_type_processor_unittest.cc b/components/sync/model_impl/shared_model_type_processor_unittest.cc |
| index 7551170746d252e606a38473f7d1ab9acb6e1386..9d7967564ab5a8d28653bbe1e504cf433d838a47 100644 |
| --- a/components/sync/model_impl/shared_model_type_processor_unittest.cc |
| +++ b/components/sync/model_impl/shared_model_type_processor_unittest.cc |
| @@ -49,10 +49,6 @@ const std::string kHash5(FakeModelTypeSyncBridge::TagHashFromKey(kKey5)); |
| // worker/processor will not have been initialized and thus empty. |
| const EntitySpecifics kEmptySpecifics; |
| -SyncError CreateSyncError(SyncError::ErrorType error_type) { |
| - return SyncError(FROM_HERE, error_type, "TestError", PREFERENCES); |
| -} |
| - |
| EntitySpecifics GenerateSpecifics(const std::string& key, |
| const std::string& value) { |
| return FakeModelTypeSyncBridge::GenerateSpecifics(key, value); |
| @@ -97,8 +93,8 @@ class TestModelTypeSyncBridge : public FakeModelTypeSyncBridge { |
| // FakeModelTypeSyncBridge overrides. |
| - SyncError MergeSyncData(std::unique_ptr<MetadataChangeList> mcl, |
| - EntityDataMap entity_data_map) override { |
| + ModelError MergeSyncData(std::unique_ptr<MetadataChangeList> mcl, |
| + EntityDataMap entity_data_map) override { |
| merge_call_count_++; |
| return FakeModelTypeSyncBridge::MergeSyncData(std::move(mcl), |
| entity_data_map); |
| @@ -117,9 +113,8 @@ class TestModelTypeSyncBridge : public FakeModelTypeSyncBridge { |
| private: |
| void CaptureDataCallback(DataCallback callback, |
| - SyncError error, |
| std::unique_ptr<DataBatch> data) { |
| - data_callback_ = base::Bind(callback, error, base::Passed(std::move(data))); |
| + data_callback_ = base::Bind(callback, base::Passed(std::move(data))); |
| } |
| // The number of times MergeSyncData has been called. |
| @@ -166,7 +161,7 @@ class SharedModelTypeProcessorTest : public ::testing::Test { |
| } |
| void OnMetadataLoaded() { |
| - type_processor()->OnMetadataLoaded(SyncError(), db().CreateMetadataBatch()); |
| + type_processor()->OnMetadataLoaded(db().CreateMetadataBatch()); |
| } |
| void OnPendingCommitDataLoaded() { bridge()->OnPendingCommitDataLoaded(); } |
| @@ -237,9 +232,9 @@ class SharedModelTypeProcessorTest : public ::testing::Test { |
| // Sets the error type that OnReadyToConnect (our StartCallback) expects to |
| // receive. |
| - void ExpectStartError(SyncError::ErrorType error_type) { |
| - DCHECK(expected_start_error_ == SyncError::UNSET); |
| - expected_start_error_ = error_type; |
| + void ExpectStartError() { |
| + EXPECT_FALSE(expect_start_error_); |
| + expect_start_error_ = true; |
| } |
| TestModelTypeSyncBridge* bridge() const { return bridge_.get(); } |
| @@ -258,17 +253,14 @@ class SharedModelTypeProcessorTest : public ::testing::Test { |
| } |
| private: |
| - void CheckPostConditions() { |
| - DCHECK_EQ(SyncError::UNSET, expected_start_error_); |
| - } |
| + void CheckPostConditions() { EXPECT_FALSE(expect_start_error_); } |
| void OnReadyToConnect(SyncError error, |
| std::unique_ptr<ActivationContext> context) { |
| - if (expected_start_error_ != SyncError::UNSET) { |
| + if (expect_start_error_) { |
| EXPECT_TRUE(error.IsSet()); |
| - EXPECT_EQ(expected_start_error_, error.error_type()); |
| EXPECT_EQ(nullptr, context); |
| - expected_start_error_ = SyncError::UNSET; |
| + expect_start_error_ = false; |
| return; |
| } |
| @@ -294,8 +286,8 @@ class SharedModelTypeProcessorTest : public ::testing::Test { |
| // The processor's error handler. |
| DataTypeErrorHandlerMock* error_handler_; |
| - // The error to expect in OnReadyToConnect(). |
| - SyncError::ErrorType expected_start_error_ = SyncError::UNSET; |
| + // Whether to expect an error in OnReadyToConnect(). |
| + bool expect_start_error_ = false; |
| }; |
| // Test that an initial sync handles local and remote items properly. |
| @@ -350,31 +342,28 @@ TEST_F(SharedModelTypeProcessorTest, InitialSyncError) { |
| OnMetadataLoaded(); |
| OnSyncStarting(); |
| - bridge()->ErrorOnNextCall(SyncError::DATATYPE_ERROR); |
| + bridge()->ErrorOnNextCall(); |
| error_handler()->ExpectError(SyncError::DATATYPE_ERROR); |
| worker()->UpdateFromServer(); |
| } |
| // Test that errors before it's called are passed to |start_callback| correctly. |
| TEST_F(SharedModelTypeProcessorTest, StartErrors) { |
| - type_processor()->OnMetadataLoaded(CreateSyncError(SyncError::DATATYPE_ERROR), |
| - nullptr); |
| - ExpectStartError(SyncError::DATATYPE_ERROR); |
| + type_processor()->ReportError(FROM_HERE, "boom"); |
| + ExpectStartError(); |
| OnSyncStarting(); |
| // Test OnSyncStarting happening first. |
| ResetState(false); |
| OnSyncStarting(); |
| - ExpectStartError(SyncError::DATATYPE_ERROR); |
| - type_processor()->OnMetadataLoaded(CreateSyncError(SyncError::DATATYPE_ERROR), |
| - nullptr); |
| + ExpectStartError(); |
| + type_processor()->ReportError(FROM_HERE, "boom"); |
| // Test an error loading pending data. |
| ResetStateWriteItem(kKey1, kValue1); |
| - bridge()->ErrorOnNextCall(SyncError::DATATYPE_ERROR); |
| + bridge()->ErrorOnNextCall(); |
| InitializeToMetadataLoaded(); |
| - OnPendingCommitDataLoaded(); |
| - ExpectStartError(SyncError::DATATYPE_ERROR); |
| + ExpectStartError(); |
| OnSyncStarting(); |
| } |
| @@ -639,7 +628,7 @@ TEST_F(SharedModelTypeProcessorTest, LocalCreateItem) { |
| TEST_F(SharedModelTypeProcessorTest, ErrorApplyingAck) { |
| InitializeToReadyState(); |
| bridge()->WriteItem(kKey1, kValue1); |
| - bridge()->ErrorOnNextCall(SyncError::DATATYPE_ERROR); |
| + bridge()->ErrorOnNextCall(); |
| error_handler()->ExpectError(SyncError::DATATYPE_ERROR); |
| worker()->AckOnePendingCommit(); |
| } |
| @@ -804,7 +793,7 @@ TEST_F(SharedModelTypeProcessorTest, ServerCreateItem) { |
| // propagated to the error handler. |
| TEST_F(SharedModelTypeProcessorTest, ErrorApplyingUpdate) { |
| InitializeToReadyState(); |
| - bridge()->ErrorOnNextCall(SyncError::DATATYPE_ERROR); |
| + bridge()->ErrorOnNextCall(); |
| error_handler()->ExpectError(SyncError::DATATYPE_ERROR); |
| worker()->UpdateFromServer(kHash1, GenerateSpecifics(kKey1, kValue1)); |
| } |
| @@ -928,6 +917,7 @@ TEST_F(SharedModelTypeProcessorTest, ServerDeleteItem) { |
| EXPECT_EQ(1U, db().metadata_count()); |
| EXPECT_EQ(1U, db().data_count()); |
| EXPECT_EQ(0U, worker()->GetNumPendingCommits()); |
| + // Helper function to turn a ModelError into a SyncError. |
|
skym
2017/01/09 18:20:28
Was this mistakenly pasted in here?
maxbogue
2017/01/09 21:29:33
Sure looks like it O_O
|
| worker()->TombstoneFromServer(kHash1); |
| // Delete from server should clear the data and all the metadata. |
| @@ -1161,10 +1151,9 @@ TEST_F(SharedModelTypeProcessorTest, ReEncryptCommitsWithNewKey) { |
| TEST_F(SharedModelTypeProcessorTest, ReEncryptErrorLoadingData) { |
| InitializeToReadyState(); |
| WriteItemAndAck(kKey1, kValue1); |
| - bridge()->ErrorOnNextCall(SyncError::DATATYPE_ERROR); |
| - worker()->UpdateWithEncryptionKey("k1"); |
| + bridge()->ErrorOnNextCall(); |
| error_handler()->ExpectError(SyncError::DATATYPE_ERROR); |
| - OnPendingCommitDataLoaded(); |
| + worker()->UpdateWithEncryptionKey("k1"); |
| } |
| // Test receipt of updates with new and old keys. |