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

Side by Side Diff: components/sync/test/fake_server/fake_server_entity.cc

Issue 2328393002: [Sync] Add a sanity integration test for USS. (Closed)
Patch Set: Rebase. Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "components/sync/test/fake_server/fake_server_entity.h" 5 #include "components/sync/test/fake_server/fake_server_entity.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <memory> 10 #include <memory>
(...skipping 21 matching lines...) Expand all
32 // 32 //
33 // We chose the underscore character because it doesn't conflict with the 33 // We chose the underscore character because it doesn't conflict with the
34 // special characters used by base/base64.h's encoding, which is also used in 34 // special characters used by base/base64.h's encoding, which is also used in
35 // the construction of some IDs. 35 // the construction of some IDs.
36 const char kIdSeparator[] = "_"; 36 const char kIdSeparator[] = "_";
37 37
38 namespace fake_server { 38 namespace fake_server {
39 39
40 FakeServerEntity::~FakeServerEntity() {} 40 FakeServerEntity::~FakeServerEntity() {}
41 41
42 const std::string& FakeServerEntity::GetId() const {
43 return id_;
44 }
45
46 ModelType FakeServerEntity::GetModelType() const {
47 return model_type_;
48 }
49
50 int64_t FakeServerEntity::GetVersion() const { 42 int64_t FakeServerEntity::GetVersion() const {
51 return version_; 43 return version_;
52 } 44 }
53 45
54 void FakeServerEntity::SetVersion(int64_t version) { 46 void FakeServerEntity::SetVersion(int64_t version) {
55 version_ = version; 47 version_ = version;
56 } 48 }
57 49
58 const std::string& FakeServerEntity::GetName() const { 50 const std::string& FakeServerEntity::GetName() const {
59 return name_; 51 return name_;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 93
102 int field_number; 94 int field_number;
103 if (tokens.size() != 2 || !base::StringToInt(tokens[0], &field_number)) { 95 if (tokens.size() != 2 || !base::StringToInt(tokens[0], &field_number)) {
104 return syncer::UNSPECIFIED; 96 return syncer::UNSPECIFIED;
105 } 97 }
106 98
107 return syncer::GetModelTypeFromSpecificsFieldNumber(field_number); 99 return syncer::GetModelTypeFromSpecificsFieldNumber(field_number);
108 } 100 }
109 101
110 FakeServerEntity::FakeServerEntity(const string& id, 102 FakeServerEntity::FakeServerEntity(const string& id,
103 const string& client_defined_unique_tag,
111 const ModelType& model_type, 104 const ModelType& model_type,
112 int64_t version, 105 int64_t version,
113 const string& name) 106 const string& name)
114 : id_(id), model_type_(model_type), version_(version), name_(name) {} 107 : id_(id),
108 client_defined_unique_tag_(client_defined_unique_tag),
109 model_type_(model_type),
110 version_(version),
111 name_(name) {
112 // There shouldn't be a unique_tag if the type is bookmarks.
113 DCHECK(model_type != syncer::BOOKMARKS || client_defined_unique_tag.empty());
114 }
115 115
116 void FakeServerEntity::SerializeBaseProtoFields( 116 void FakeServerEntity::SerializeBaseProtoFields(
117 sync_pb::SyncEntity* sync_entity) const { 117 sync_pb::SyncEntity* sync_entity) const {
118 sync_pb::EntitySpecifics* specifics = sync_entity->mutable_specifics(); 118 sync_pb::EntitySpecifics* specifics = sync_entity->mutable_specifics();
119 specifics->CopyFrom(specifics_); 119 specifics->CopyFrom(specifics_);
120 120
121 // FakeServerEntity fields 121 // FakeServerEntity fields
122 sync_entity->set_id_string(id_); 122 sync_entity->set_id_string(id_);
123 if (!client_defined_unique_tag_.empty())
124 sync_entity->set_client_defined_unique_tag(client_defined_unique_tag_);
123 sync_entity->set_version(version_); 125 sync_entity->set_version(version_);
124 sync_entity->set_name(name_); 126 sync_entity->set_name(name_);
125 127
126 // Data via accessors 128 // Data via accessors
127 sync_entity->set_deleted(IsDeleted()); 129 sync_entity->set_deleted(IsDeleted());
128 sync_entity->set_folder(IsFolder()); 130 sync_entity->set_folder(IsFolder());
129 131
130 if (RequiresParentId()) 132 if (RequiresParentId())
131 sync_entity->set_parent_id_string(GetParentId()); 133 sync_entity->set_parent_id_string(GetParentId());
132 } 134 }
133 135
134 } // namespace fake_server 136 } // namespace fake_server
OLDNEW
« no previous file with comments | « components/sync/test/fake_server/fake_server_entity.h ('k') | components/sync/test/fake_server/permanent_entity.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698