Index: sync/test/engine/mock_connection_manager.cc |
diff --git a/sync/test/engine/mock_connection_manager.cc b/sync/test/engine/mock_connection_manager.cc |
index cc4b09cf2d4c2ebb01964341ad4db5364e57365c..1aec3448c3914ac3db321709dcf7b409e98b19db 100644 |
--- a/sync/test/engine/mock_connection_manager.cc |
+++ b/sync/test/engine/mock_connection_manager.cc |
@@ -32,6 +32,8 @@ using syncable::WriteTransaction; |
static char kValidAuthToken[] = "AuthToken"; |
+static char kCacheGuid[] = "tuiWdG8hV+8y4RT9N5Aikg=="; |
+ |
MockConnectionManager::MockConnectionManager(syncable::Directory* directory) |
: ServerConnectionManager("unused", 0, false), |
server_reachable_(true), |
@@ -52,7 +54,8 @@ MockConnectionManager::MockConnectionManager(syncable::Directory* directory) |
commit_client_command_(NULL), |
next_position_in_parent_(2), |
use_legacy_bookmarks_protocol_(false), |
- num_get_updates_requests_(0) { |
+ num_get_updates_requests_(0), |
+ originator_item_id_(-100000) { |
SetNewTimestamp(0); |
set_auth_token(kValidAuthToken); |
} |
@@ -244,6 +247,42 @@ sync_pb::SyncEntity* MockConnectionManager::AddUpdateSpecifics( |
return ent; |
} |
+sync_pb::SyncEntity* MockConnectionManager::AddBookmarkUpdateSpecifics( |
+ int id, int parent_id, string name, int64 version, int64 sync_ts, |
+ bool is_dir, int64 position, const sync_pb::EntitySpecifics& specifics) { |
+ sync_pb::SyncEntity* ent = AddUpdateSpecifics( |
+ id, parent_id, name, version, sync_ts, is_dir, position, specifics); |
+ ent->set_originator_cache_guid(kCacheGuid); |
+ // Not entirely right, but it sure looks like a client ID. |
+ syncable::Id client_id = |
+ syncable::Id::CreateFromClientString(base::IntToString(id * -1)); |
+ ent->set_originator_client_item_id(client_id.value()); |
+ return ent; |
+} |
+ |
+sync_pb::SyncEntity* MockConnectionManager::AddBookmarkUpdateSpecifics( |
+ int id, int parent_id, string name, int64 version, int64 sync_ts, |
+ bool is_dir, const syncer::UniquePosition& position, |
+ const sync_pb::EntitySpecifics& specifics) { |
+ sync_pb::SyncEntity* ent = AddUpdateMeta( |
+ TestIdFactory::FromNumber(id).GetServerId(), |
+ TestIdFactory::FromNumber(parent_id).GetServerId(), |
+ name, version, sync_ts); |
+ ent->set_position_in_parent(position.ToInt64()); |
+ ent->set_unique_position(position.ToInternalValue()); |
+ ent->mutable_specifics()->CopyFrom(specifics); |
+ ent->set_folder(is_dir); |
+ |
+ ent->set_originator_cache_guid(kCacheGuid); |
+ // Not entirely right, but it sure looks like a client ID. |
+ syncable::Id client_id = |
+ syncable::Id::CreateFromClientString( |
+ base::Int64ToString(id * -1)); |
+ ent->set_originator_client_item_id(client_id.value()); |
+ |
+ return ent; |
+} |
+ |
sync_pb::SyncEntity* MockConnectionManager::SetNigori( |
int id, int64 version,int64 sync_ts, |
const sync_pb::EntitySpecifics& specifics) { |
@@ -270,6 +309,7 @@ sync_pb::SyncEntity* MockConnectionManager::AddUpdateFull( |
sync_pb::SyncEntity* ent = |
AddUpdateMeta(id, parent_id, name, version, sync_ts); |
AddDefaultBookmarkData(ent, is_dir); |
+ SetUpdateOriginatorFields(ent); |
return ent; |
} |
@@ -327,9 +367,10 @@ sync_pb::SyncEntity* MockConnectionManager::AddUpdateFromLastCommit() { |
last_commit_response().entryresponse(0).version()); |
ent->set_id_string( |
last_commit_response().entryresponse(0).id_string()); |
+ SetUpdateOriginatorFields(ent); |
+ |
// Tests don't currently care about the following: |
- // originator_cache_guid, originator_client_item_id, parent_id_string, |
- // name, non_unique_name. |
+ // parent_id_string, name, non_unique_name. |
} |
return GetMutableLastUpdate(); |
} |
@@ -618,4 +659,16 @@ void MockConnectionManager::UpdateConnectionStatus() { |
} |
} |
+void MockConnectionManager::SetUpdateOriginatorFields( |
+ sync_pb::SyncEntity* entity) { |
+ if (GetModelType(*entity) == BOOKMARKS) { |
+ entity->set_originator_cache_guid(kCacheGuid); |
+ syncable::Id client_id = |
+ syncable::Id::CreateFromClientString( |
+ base::Int64ToString(originator_item_id_--)); |
+ entity->set_originator_client_item_id(client_id.value()); |
+ } |
+} |
+ |
+ |
} // namespace syncer |