summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sync/test/fake_server/bookmark_entity.cc34
-rw-r--r--sync/test/fake_server/bookmark_entity.h1
-rw-r--r--sync/test/fake_server/bookmark_entity_builder.cc2
3 files changed, 17 insertions, 20 deletions
diff --git a/sync/test/fake_server/bookmark_entity.cc b/sync/test/fake_server/bookmark_entity.cc
index a0f33d6..ae7a3b5 100644
--- a/sync/test/fake_server/bookmark_entity.cc
+++ b/sync/test/fake_server/bookmark_entity.cc
@@ -14,10 +14,17 @@
using std::string;
-using syncer::ModelType;
-
namespace fake_server {
+namespace {
+
+// Returns true if and only if |client_entity| is a bookmark.
+bool IsBookmark(const sync_pb::SyncEntity& client_entity) {
+ return syncer::GetModelType(client_entity) == syncer::BOOKMARKS;
+}
+
+} // namespace
+
BookmarkEntity::~BookmarkEntity() { }
// static
@@ -25,18 +32,15 @@ FakeServerEntity* BookmarkEntity::CreateNew(
const sync_pb::SyncEntity& client_entity,
const string& parent_id,
const string& client_guid) {
- if (client_entity.version() != 0) {
- return NULL;
- }
+ CHECK(client_entity.version() == 0) << "New entities must have version = 0.";
+ CHECK(IsBookmark(client_entity)) << "The given entity must be a bookmark.";
- ModelType model_type =
- syncer::GetModelTypeFromSpecifics(client_entity.specifics());
- string id = FakeServerEntity::CreateId(model_type, base::GenerateGUID());
+ string id = FakeServerEntity::CreateId(syncer::BOOKMARKS,
+ base::GenerateGUID());
string originator_cache_guid = client_guid;
string originator_client_item_id = client_entity.id_string();
return new BookmarkEntity(id,
- model_type,
client_entity.version(),
client_entity.name(),
originator_cache_guid,
@@ -54,9 +58,9 @@ FakeServerEntity* BookmarkEntity::CreateUpdatedVersion(
const sync_pb::SyncEntity& client_entity,
FakeServerEntity* current_server_entity,
const string& parent_id) {
- if (client_entity.version() == 0 || current_server_entity == NULL) {
- return NULL;
- }
+ CHECK(client_entity.version() != 0) << "Existing entities must not have a "
+ << "version = 0.";
+ CHECK(IsBookmark(client_entity)) << "The given entity must be a bookmark.";
BookmarkEntity* current_bookmark_entity =
static_cast<BookmarkEntity*>(current_server_entity);
@@ -64,11 +68,8 @@ FakeServerEntity* BookmarkEntity::CreateUpdatedVersion(
current_bookmark_entity->originator_cache_guid_;
string originator_client_item_id =
current_bookmark_entity->originator_client_item_id_;
- ModelType model_type =
- syncer::GetModelTypeFromSpecifics(client_entity.specifics());
return new BookmarkEntity(client_entity.id_string(),
- model_type,
client_entity.version(),
client_entity.name(),
originator_cache_guid,
@@ -83,7 +84,6 @@ FakeServerEntity* BookmarkEntity::CreateUpdatedVersion(
BookmarkEntity::BookmarkEntity(
const string& id,
- const ModelType& model_type,
int64 version,
const string& name,
const string& originator_cache_guid,
@@ -94,7 +94,7 @@ BookmarkEntity::BookmarkEntity(
const string& parent_id,
int64 creation_time,
int64 last_modified_time)
- : FakeServerEntity(id, model_type, version, name),
+ : FakeServerEntity(id, syncer::BOOKMARKS, version, name),
originator_cache_guid_(originator_cache_guid),
originator_client_item_id_(originator_client_item_id),
unique_position_(unique_position),
diff --git a/sync/test/fake_server/bookmark_entity.h b/sync/test/fake_server/bookmark_entity.h
index 3f108ba..388dba8 100644
--- a/sync/test/fake_server/bookmark_entity.h
+++ b/sync/test/fake_server/bookmark_entity.h
@@ -37,7 +37,6 @@ class BookmarkEntity : public FakeServerEntity {
const std::string& parent_id);
BookmarkEntity(const std::string& id,
- const syncer::ModelType& model_type,
int64 version,
const std::string& name,
const std::string& originator_cache_guid,
diff --git a/sync/test/fake_server/bookmark_entity_builder.cc b/sync/test/fake_server/bookmark_entity_builder.cc
index 04e7e97..5abad58 100644
--- a/sync/test/fake_server/bookmark_entity_builder.cc
+++ b/sync/test/fake_server/bookmark_entity_builder.cc
@@ -20,7 +20,6 @@
using std::string;
-using syncer::ModelType;
using syncer::syncable::GenerateSyncableBookmarkHash;
// A version must be passed when creating a FakeServerEntity, but this value
@@ -65,7 +64,6 @@ scoped_ptr<FakeServerEntity> BookmarkEntityBuilder::Build() {
return make_scoped_ptr<FakeServerEntity>(
new BookmarkEntity(id_,
- model_type_,
kUnusedVersion,
name_,
originator_cache_guid_,