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

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

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 #ifndef COMPONENTS_SYNC_TEST_FAKE_SERVER_FAKE_SERVER_ENTITY_H_ 5 #ifndef COMPONENTS_SYNC_TEST_FAKE_SERVER_FAKE_SERVER_ENTITY_H_
6 #define COMPONENTS_SYNC_TEST_FAKE_SERVER_FAKE_SERVER_ENTITY_H_ 6 #define COMPONENTS_SYNC_TEST_FAKE_SERVER_FAKE_SERVER_ENTITY_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 13 matching lines...) Expand all
24 // 24 //
25 // If |inner_id| is globally unique, then the returned ID will also be 25 // If |inner_id| is globally unique, then the returned ID will also be
26 // globally unique. 26 // globally unique.
27 static std::string CreateId(const syncer::ModelType& model_type, 27 static std::string CreateId(const syncer::ModelType& model_type,
28 const std::string& inner_id); 28 const std::string& inner_id);
29 29
30 // Returns the ID string of the top level node for the specified type. 30 // Returns the ID string of the top level node for the specified type.
31 static std::string GetTopLevelId(const syncer::ModelType& model_type); 31 static std::string GetTopLevelId(const syncer::ModelType& model_type);
32 32
33 virtual ~FakeServerEntity(); 33 virtual ~FakeServerEntity();
34 const std::string& GetId() const; 34 const std::string& id() const { return id_; }
35 syncer::ModelType GetModelType() const; 35 const std::string& client_defined_unique_tag() const {
36 return client_defined_unique_tag_;
37 }
38 syncer::ModelType model_type() const { return model_type_; }
36 int64_t GetVersion() const; 39 int64_t GetVersion() const;
37 void SetVersion(int64_t version); 40 void SetVersion(int64_t version);
38 const std::string& GetName() const; 41 const std::string& GetName() const;
39 void SetName(const std::string& name); 42 void SetName(const std::string& name);
40 43
41 // Replaces |specifics_| with |updated_specifics|. This method is meant to be 44 // Replaces |specifics_| with |updated_specifics|. This method is meant to be
42 // used to mimic a client commit. 45 // used to mimic a client commit.
43 void SetSpecifics(const sync_pb::EntitySpecifics& updated_specifics); 46 void SetSpecifics(const sync_pb::EntitySpecifics& updated_specifics);
44 47
45 // Common data items needed by server 48 // Common data items needed by server
46 virtual bool RequiresParentId() const = 0; 49 virtual bool RequiresParentId() const = 0;
47 virtual std::string GetParentId() const = 0; 50 virtual std::string GetParentId() const = 0;
48 virtual void SerializeAsProto(sync_pb::SyncEntity* proto) const = 0; 51 virtual void SerializeAsProto(sync_pb::SyncEntity* proto) const = 0;
49 virtual bool IsDeleted() const; 52 virtual bool IsDeleted() const;
50 virtual bool IsFolder() const; 53 virtual bool IsFolder() const;
51 virtual bool IsPermanent() const; 54 virtual bool IsPermanent() const;
52 55
53 protected: 56 protected:
54 // Extracts the ModelType from |id|. If |id| is malformed or does not contain 57 // Extracts the ModelType from |id|. If |id| is malformed or does not contain
55 // a valid ModelType, UNSPECIFIED is returned. 58 // a valid ModelType, UNSPECIFIED is returned.
56 static syncer::ModelType GetModelTypeFromId(const std::string& id); 59 static syncer::ModelType GetModelTypeFromId(const std::string& id);
57 60
58 FakeServerEntity(const std::string& id, 61 FakeServerEntity(const std::string& id,
62 const std::string& client_defined_unique_tag,
59 const syncer::ModelType& model_type, 63 const syncer::ModelType& model_type,
60 int64_t version, 64 int64_t version,
61 const std::string& name); 65 const std::string& name);
62 66
63 void SerializeBaseProtoFields(sync_pb::SyncEntity* sync_entity) const; 67 void SerializeBaseProtoFields(sync_pb::SyncEntity* sync_entity) const;
64 68
65 private: 69 private:
66 // The entity's ID. 70 // The entity's ID.
67 std::string id_; 71 const std::string id_;
72
73 // The tag for this entity. Can be empty for bookmarks or permanent entities.
74 const std::string client_defined_unique_tag_;
68 75
69 // The ModelType that categorizes this entity. 76 // The ModelType that categorizes this entity.
70 syncer::ModelType model_type_; 77 const syncer::ModelType model_type_;
71 78
72 // The version of this entity. 79 // The version of this entity.
73 int64_t version_; 80 int64_t version_;
74 81
75 // The name of the entity. 82 // The name of the entity.
76 std::string name_; 83 std::string name_;
77 84
78 // The EntitySpecifics for the entity. 85 // The EntitySpecifics for the entity.
79 sync_pb::EntitySpecifics specifics_; 86 sync_pb::EntitySpecifics specifics_;
80 }; 87 };
81 88
82 } // namespace fake_server 89 } // namespace fake_server
83 90
84 #endif // COMPONENTS_SYNC_TEST_FAKE_SERVER_FAKE_SERVER_ENTITY_H_ 91 #endif // COMPONENTS_SYNC_TEST_FAKE_SERVER_FAKE_SERVER_ENTITY_H_
OLDNEW
« no previous file with comments | « components/sync/test/fake_server/fake_server.cc ('k') | components/sync/test/fake_server/fake_server_entity.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698