| Index: components/sync/test/engine/mock_connection_manager.cc
|
| diff --git a/sync/test/engine/mock_connection_manager.cc b/components/sync/test/engine/mock_connection_manager.cc
|
| similarity index 90%
|
| copy from sync/test/engine/mock_connection_manager.cc
|
| copy to components/sync/test/engine/mock_connection_manager.cc
|
| index 5a7ecd943418bc6c8829f06f083d3a6ad3dbb81c..80bc7e10fedb560f4ff322b88bfb55da39dc294c 100644
|
| --- a/sync/test/engine/mock_connection_manager.cc
|
| +++ b/components/sync/test/engine/mock_connection_manager.cc
|
| @@ -4,7 +4,7 @@
|
| //
|
| // Mock ServerConnectionManager class for use in client regression tests.
|
|
|
| -#include "sync/test/engine/mock_connection_manager.h"
|
| +#include "components/sync/test/engine/mock_connection_manager.h"
|
|
|
| #include <stdint.h>
|
|
|
| @@ -12,11 +12,11 @@
|
|
|
| #include "base/location.h"
|
| #include "base/strings/stringprintf.h"
|
| -#include "sync/engine/syncer_proto_util.h"
|
| -#include "sync/protocol/bookmark_specifics.pb.h"
|
| -#include "sync/syncable/directory.h"
|
| -#include "sync/syncable/syncable_write_transaction.h"
|
| -#include "sync/test/engine/test_id_factory.h"
|
| +#include "components/sync/engine_impl/syncer_proto_util.h"
|
| +#include "components/sync/protocol/bookmark_specifics.pb.h"
|
| +#include "components/sync/syncable/directory.h"
|
| +#include "components/sync/syncable/syncable_write_transaction.h"
|
| +#include "components/sync/test/engine/test_id_factory.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| using std::find;
|
| @@ -73,7 +73,7 @@ void MockConnectionManager::SetMidCommitCallback(
|
|
|
| void MockConnectionManager::SetMidCommitObserver(
|
| MockConnectionManager::MidCommitObserver* observer) {
|
| - mid_commit_observer_ = observer;
|
| + mid_commit_observer_ = observer;
|
| }
|
|
|
| bool MockConnectionManager::PostBufferToPath(PostBufferParams* params,
|
| @@ -126,8 +126,8 @@ bool MockConnectionManager::PostBufferToPath(PostBufferParams* params,
|
| response.set_error_code(SyncEnums::SUCCESS);
|
| const string current_store_birthday = store_birthday();
|
| response.set_store_birthday(current_store_birthday);
|
| - if (post.has_store_birthday() && post.store_birthday() !=
|
| - current_store_birthday) {
|
| + if (post.has_store_birthday() &&
|
| + post.store_birthday() != current_store_birthday) {
|
| response.set_error_code(SyncEnums::NOT_MY_BIRTHDAY);
|
| response.set_error_message("Merry Unbirthday!");
|
| response.SerializeToString(¶ms->buffer_out);
|
| @@ -206,8 +206,8 @@ void MockConnectionManager::AddDefaultBookmarkData(sync_pb::SyncEntity* entity,
|
| entity->set_folder(is_folder);
|
| entity->mutable_specifics()->mutable_bookmark();
|
| if (!is_folder) {
|
| - entity->mutable_specifics()->mutable_bookmark()->
|
| - set_url("http://google.com");
|
| + entity->mutable_specifics()->mutable_bookmark()->set_url(
|
| + "http://google.com");
|
| }
|
| }
|
| }
|
| @@ -220,13 +220,9 @@ sync_pb::SyncEntity* MockConnectionManager::AddUpdateDirectory(
|
| int64_t sync_ts,
|
| const std::string& originator_cache_guid,
|
| const std::string& originator_client_item_id) {
|
| - return AddUpdateDirectory(TestIdFactory::FromNumber(id),
|
| - TestIdFactory::FromNumber(parent_id),
|
| - name,
|
| - version,
|
| - sync_ts,
|
| - originator_cache_guid,
|
| - originator_client_item_id);
|
| + return AddUpdateDirectory(
|
| + TestIdFactory::FromNumber(id), TestIdFactory::FromNumber(parent_id), name,
|
| + version, sync_ts, originator_cache_guid, originator_client_item_id);
|
| }
|
|
|
| void MockConnectionManager::SetGUClientCommand(
|
| @@ -251,13 +247,9 @@ sync_pb::SyncEntity* MockConnectionManager::AddUpdateBookmark(
|
| int64_t sync_ts,
|
| const string& originator_client_item_id,
|
| const string& originator_cache_guid) {
|
| - return AddUpdateBookmark(TestIdFactory::FromNumber(id),
|
| - TestIdFactory::FromNumber(parent_id),
|
| - name,
|
| - version,
|
| - sync_ts,
|
| - originator_client_item_id,
|
| - originator_cache_guid);
|
| + return AddUpdateBookmark(
|
| + TestIdFactory::FromNumber(id), TestIdFactory::FromNumber(parent_id), name,
|
| + version, sync_ts, originator_client_item_id, originator_cache_guid);
|
| }
|
|
|
| sync_pb::SyncEntity* MockConnectionManager::AddUpdateSpecifics(
|
| @@ -269,10 +261,10 @@ sync_pb::SyncEntity* MockConnectionManager::AddUpdateSpecifics(
|
| bool is_dir,
|
| int64_t position,
|
| const sync_pb::EntitySpecifics& specifics) {
|
| - sync_pb::SyncEntity* ent = AddUpdateMeta(
|
| - TestIdFactory::FromNumber(id).GetServerId(),
|
| - TestIdFactory::FromNumber(parent_id).GetServerId(),
|
| - name, version, sync_ts);
|
| + sync_pb::SyncEntity* ent =
|
| + AddUpdateMeta(TestIdFactory::FromNumber(id).GetServerId(),
|
| + TestIdFactory::FromNumber(parent_id).GetServerId(), name,
|
| + version, sync_ts);
|
| ent->set_position_in_parent(position);
|
| ent->mutable_specifics()->CopyFrom(specifics);
|
| ent->set_folder(is_dir);
|
| @@ -415,12 +407,13 @@ sync_pb::SyncEntity* MockConnectionManager::AddUpdateFromLastCommit() {
|
| EXPECT_EQ(1, last_sent_commit().entries_size());
|
| EXPECT_EQ(1, last_commit_response().entryresponse_size());
|
| EXPECT_EQ(CommitResponse::SUCCESS,
|
| - last_commit_response().entryresponse(0).response_type());
|
| + last_commit_response().entryresponse(0).response_type());
|
|
|
| if (last_sent_commit().entries(0).deleted()) {
|
| ModelType type = GetModelType(last_sent_commit().entries(0));
|
| AddUpdateTombstone(syncable::Id::CreateFromServerId(
|
| - last_sent_commit().entries(0).id_string()), type);
|
| + last_sent_commit().entries(0).id_string()),
|
| + type);
|
| } else {
|
| sync_pb::SyncEntity* ent = GetUpdateResponse()->add_entries();
|
| ent->CopyFrom(last_sent_commit().entries(0));
|
| @@ -428,10 +421,8 @@ sync_pb::SyncEntity* MockConnectionManager::AddUpdateFromLastCommit() {
|
| ent->clear_old_parent_id();
|
| ent->set_position_in_parent(
|
| last_commit_response().entryresponse(0).position_in_parent());
|
| - ent->set_version(
|
| - last_commit_response().entryresponse(0).version());
|
| - ent->set_id_string(
|
| - last_commit_response().entryresponse(0).id_string());
|
| + ent->set_version(last_commit_response().entryresponse(0).version());
|
| + ent->set_id_string(last_commit_response().entryresponse(0).id_string());
|
|
|
| // This is the same hack as in AddUpdateMeta. See the comment in that
|
| // function for more information.
|
| @@ -450,9 +441,8 @@ sync_pb::SyncEntity* MockConnectionManager::AddUpdateFromLastCommit() {
|
| return GetMutableLastUpdate();
|
| }
|
|
|
| -void MockConnectionManager::AddUpdateTombstone(
|
| - const syncable::Id& id,
|
| - ModelType type) {
|
| +void MockConnectionManager::AddUpdateTombstone(const syncable::Id& id,
|
| + ModelType type) {
|
| // Tombstones have only the ID set and dummy values for the required fields.
|
| sync_pb::SyncEntity* ent = GetUpdateResponse()->add_entries();
|
| ent->set_id_string(id.GetServerId());
|
| @@ -589,8 +579,8 @@ bool MockConnectionManager::ShouldConflictThisCommit() {
|
| }
|
|
|
| bool MockConnectionManager::ShouldTransientErrorThisId(syncable::Id id) {
|
| - return find(transient_error_ids_.begin(), transient_error_ids_.end(), id)
|
| - != transient_error_ids_.end();
|
| + return find(transient_error_ids_.begin(), transient_error_ids_.end(), id) !=
|
| + transient_error_ids_.end();
|
| }
|
|
|
| void MockConnectionManager::ProcessCommit(
|
| @@ -598,18 +588,19 @@ void MockConnectionManager::ProcessCommit(
|
| sync_pb::ClientToServerResponse* response_buffer) {
|
| CHECK(csm->has_commit());
|
| ASSERT_EQ(csm->message_contents(), ClientToServerMessage::COMMIT);
|
| - map <string, string> changed_ids;
|
| + map<string, string> changed_ids;
|
| const CommitMessage& commit_message = csm->commit();
|
| CommitResponse* commit_response = response_buffer->mutable_commit();
|
| commit_messages_.push_back(new CommitMessage);
|
| commit_messages_.back()->CopyFrom(commit_message);
|
| map<string, sync_pb::CommitResponse_EntryResponse*> response_map;
|
| - for (int i = 0; i < commit_message.entries_size() ; i++) {
|
| + for (int i = 0; i < commit_message.entries_size(); i++) {
|
| const sync_pb::SyncEntity& entry = commit_message.entries(i);
|
| CHECK(entry.has_id_string());
|
| string id_string = entry.id_string();
|
| - ASSERT_LT(entry.name().length(), 256ul) << " name probably too long. True "
|
| - "server name checking not implemented";
|
| + ASSERT_LT(entry.name().length(), 256ul)
|
| + << " name probably too long. True "
|
| + "server name checking not implemented";
|
| syncable::Id id;
|
| if (entry.version() == 0) {
|
| // Relies on our new item string id format. (string representation of a
|
| @@ -675,8 +666,8 @@ sync_pb::SyncEntity* MockConnectionManager::AddUpdateDirectory(
|
| int64_t sync_ts,
|
| const string& originator_cache_guid,
|
| const string& originator_client_item_id) {
|
| - return AddUpdateDirectory(id.GetServerId(), parent_id.GetServerId(),
|
| - name, version, sync_ts, originator_cache_guid,
|
| + return AddUpdateDirectory(id.GetServerId(), parent_id.GetServerId(), name,
|
| + version, sync_ts, originator_cache_guid,
|
| originator_client_item_id);
|
| }
|
|
|
| @@ -688,8 +679,8 @@ sync_pb::SyncEntity* MockConnectionManager::AddUpdateBookmark(
|
| int64_t sync_ts,
|
| const string& originator_cache_guid,
|
| const string& originator_client_item_id) {
|
| - return AddUpdateBookmark(id.GetServerId(), parent_id.GetServerId(),
|
| - name, version, sync_ts, originator_cache_guid,
|
| + return AddUpdateBookmark(id.GetServerId(), parent_id.GetServerId(), name,
|
| + version, sync_ts, originator_cache_guid,
|
| originator_client_item_id);
|
| }
|
|
|
| @@ -715,20 +706,20 @@ const CommitResponse& MockConnectionManager::last_commit_response() const {
|
| return *commit_responses_.back();
|
| }
|
|
|
| -const sync_pb::ClientToServerMessage&
|
| - MockConnectionManager::last_request() const {
|
| +const sync_pb::ClientToServerMessage& MockConnectionManager::last_request()
|
| + const {
|
| EXPECT_TRUE(!requests_.empty());
|
| return requests_.back();
|
| }
|
|
|
| const std::vector<sync_pb::ClientToServerMessage>&
|
| - MockConnectionManager::requests() const {
|
| +MockConnectionManager::requests() const {
|
| return requests_;
|
| }
|
|
|
| bool MockConnectionManager::IsModelTypePresentInSpecifics(
|
| - const google::protobuf::RepeatedPtrField<
|
| - sync_pb::DataTypeProgressMarker>& filter,
|
| + const google::protobuf::RepeatedPtrField<sync_pb::DataTypeProgressMarker>&
|
| + filter,
|
| ModelType value) {
|
| int data_type_id = GetSpecificsFieldNumberFromModelType(value);
|
| for (int i = 0; i < filter.size(); ++i) {
|
| @@ -740,10 +731,10 @@ bool MockConnectionManager::IsModelTypePresentInSpecifics(
|
| }
|
|
|
| sync_pb::DataTypeProgressMarker const*
|
| - MockConnectionManager::GetProgressMarkerForType(
|
| - const google::protobuf::RepeatedPtrField<
|
| - sync_pb::DataTypeProgressMarker>& filter,
|
| - ModelType value) {
|
| +MockConnectionManager::GetProgressMarkerForType(
|
| + const google::protobuf::RepeatedPtrField<sync_pb::DataTypeProgressMarker>&
|
| + filter,
|
| + ModelType value) {
|
| int data_type_id = GetSpecificsFieldNumberFromModelType(value);
|
| for (int i = 0; i < filter.size(); ++i) {
|
| if (filter.Get(i).data_type_id() == data_type_id) {
|
|
|