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

Unified Diff: components/sync/model_impl/shared_model_type_processor_unittest.cc

Issue 2618483003: [Sync] Introduce ModelError for USS error handling. (Closed)
Patch Set: Address comments. 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
« no previous file with comments | « components/sync/model_impl/shared_model_type_processor.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..97f7e86a73ffb5d9db24afb6bfc971a5f678ac2b 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));
}
@@ -1161,10 +1150,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.
« no previous file with comments | « components/sync/model_impl/shared_model_type_processor.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698