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

Unified Diff: sync/test/fake_server/permanent_entity.cc

Issue 327593003: Sync FakeServer cleanup: CHECKs and logging info (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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 | « sync/test/fake_server/permanent_entity.h ('k') | sync/test/fake_server/unique_client_entity.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/test/fake_server/permanent_entity.cc
diff --git a/sync/test/fake_server/permanent_entity.cc b/sync/test/fake_server/permanent_entity.cc
index 480e380024c9ddbedd1fdc89f96c293e03a4d777..3ceb5c8384b22f9189c708f5dfaec6be892e1507 100644
--- a/sync/test/fake_server/permanent_entity.cc
+++ b/sync/test/fake_server/permanent_entity.cc
@@ -29,13 +29,14 @@ FakeServerEntity* PermanentEntity::Create(const ModelType& model_type,
const string& server_tag,
const string& name,
const string& parent_server_tag) {
- DCHECK(model_type != syncer::UNSPECIFIED);
- DCHECK(!server_tag.empty());
- DCHECK(!name.empty());
- DCHECK(!parent_server_tag.empty());
- if (parent_server_tag == kRootParentTag) {
- return NULL;
- }
+ CHECK(model_type != syncer::UNSPECIFIED) << "The entity's ModelType is "
+ << "invalid.";
+ CHECK(!server_tag.empty()) << "A PermanentEntity must have a server tag.";
+ CHECK(!name.empty()) << "The entity must have a non-empty name.";
+ CHECK(!parent_server_tag.empty()) << "A PermanentEntity must have a parent "
+ << "server tag.";
+ CHECK(parent_server_tag != kRootParentTag) << "Top-level entities should not "
+ << "be created with this factory.";
string id = FakeServerEntity::CreateId(model_type, server_tag);
string parent_id = FakeServerEntity::CreateId(model_type, parent_server_tag);
@@ -50,8 +51,9 @@ FakeServerEntity* PermanentEntity::Create(const ModelType& model_type,
}
// static
-FakeServerEntity* PermanentEntity::CreateTopLevel(
- const ModelType& model_type) {
+FakeServerEntity* PermanentEntity::CreateTopLevel(const ModelType& model_type) {
+ CHECK(model_type != syncer::UNSPECIFIED) << "The entity's ModelType is "
+ << "invalid.";
string server_tag = syncer::ModelTypeToRootTag(model_type);
string name = syncer::ModelTypeToString(model_type);
string id = FakeServerEntity::CreateId(model_type, server_tag);
@@ -70,9 +72,8 @@ FakeServerEntity* PermanentEntity::CreateUpdatedNigoriEntity(
const sync_pb::SyncEntity& client_entity,
FakeServerEntity* current_server_entity) {
ModelType model_type = current_server_entity->GetModelType();
- if (model_type != syncer::NIGORI) {
- return NULL;
- }
+ CHECK(model_type == syncer::NIGORI) << "This factory only supports NIGORI "
+ << "entities.";
return new PermanentEntity(current_server_entity->GetId(),
model_type,
« no previous file with comments | « sync/test/fake_server/permanent_entity.h ('k') | sync/test/fake_server/unique_client_entity.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698