| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // Mock ServerConnectionManager class for use in client regression tests. | 5 // Mock ServerConnectionManager class for use in client regression tests. |
| 6 | 6 |
| 7 #include "chrome/test/sync/engine/mock_connection_manager.h" | 7 #include "chrome/test/sync/engine/mock_connection_manager.h" |
| 8 | 8 |
| 9 #include "chrome/browser/sync/engine/syncer_proto_util.h" | 9 #include "chrome/browser/sync/engine/syncer_proto_util.h" |
| 10 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" | 10 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 name, version, sync_ts); | 415 name, version, sync_ts); |
| 416 } | 416 } |
| 417 | 417 |
| 418 SyncEntity* MockConnectionManager::AddUpdateBookmark( | 418 SyncEntity* MockConnectionManager::AddUpdateBookmark( |
| 419 syncable::Id id, syncable::Id parent_id, string name, int64 version, | 419 syncable::Id id, syncable::Id parent_id, string name, int64 version, |
| 420 int64 sync_ts) { | 420 int64 sync_ts) { |
| 421 return AddUpdateBookmark(id.GetServerId(), parent_id.GetServerId(), | 421 return AddUpdateBookmark(id.GetServerId(), parent_id.GetServerId(), |
| 422 name, version, sync_ts); | 422 name, version, sync_ts); |
| 423 } | 423 } |
| 424 | 424 |
| 425 void MockConnectionManager::AddUpdateExtendedAttributes(SyncEntity* ent, | |
| 426 string* xattr_key, syncable::Blob* xattr_value, int xattr_count) { | |
| 427 sync_pb::ExtendedAttributes* mutable_extended_attributes = | |
| 428 ent->mutable_extended_attributes(); | |
| 429 for (int i = 0; i < xattr_count; i++) { | |
| 430 sync_pb::ExtendedAttributes_ExtendedAttribute* extended_attribute = | |
| 431 mutable_extended_attributes->add_extendedattribute(); | |
| 432 extended_attribute->set_key(xattr_key[i]); | |
| 433 SyncerProtoUtil::CopyBlobIntoProtoBytes(xattr_value[i], | |
| 434 extended_attribute->mutable_value()); | |
| 435 } | |
| 436 } | |
| 437 | |
| 438 SyncEntity* MockConnectionManager::GetMutableLastUpdate() { | 425 SyncEntity* MockConnectionManager::GetMutableLastUpdate() { |
| 439 DCHECK(updates_.entries_size() > 0); | 426 DCHECK(updates_.entries_size() > 0); |
| 440 return updates_.mutable_entries()->Mutable(updates_.entries_size() - 1); | 427 return updates_.mutable_entries()->Mutable(updates_.entries_size() - 1); |
| 441 } | 428 } |
| 442 | 429 |
| 443 const CommitMessage& MockConnectionManager::last_sent_commit() const { | 430 const CommitMessage& MockConnectionManager::last_sent_commit() const { |
| 444 DCHECK(!commit_messages_.empty()); | 431 DCHECK(!commit_messages_.empty()); |
| 445 return *commit_messages_.back(); | 432 return *commit_messages_.back(); |
| 446 } | 433 } |
| 447 | 434 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 472 bool MockConnectionManager::IsModelTypePresentInSpecifics( | 459 bool MockConnectionManager::IsModelTypePresentInSpecifics( |
| 473 const sync_pb::EntitySpecifics& filter, syncable::ModelType value) { | 460 const sync_pb::EntitySpecifics& filter, syncable::ModelType value) { |
| 474 // This implementation is a little contorted; it's done this way | 461 // This implementation is a little contorted; it's done this way |
| 475 // to avoid having to switch on the ModelType. We're basically doing | 462 // to avoid having to switch on the ModelType. We're basically doing |
| 476 // the protobuf equivalent of ((value & filter) == filter). | 463 // the protobuf equivalent of ((value & filter) == filter). |
| 477 sync_pb::EntitySpecifics value_filter; | 464 sync_pb::EntitySpecifics value_filter; |
| 478 syncable::AddDefaultExtensionValue(value, &value_filter); | 465 syncable::AddDefaultExtensionValue(value, &value_filter); |
| 479 value_filter.MergeFrom(filter); | 466 value_filter.MergeFrom(filter); |
| 480 return value_filter.SerializeAsString() == filter.SerializeAsString(); | 467 return value_filter.SerializeAsString() == filter.SerializeAsString(); |
| 481 } | 468 } |
| OLD | NEW |