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

Side by Side Diff: sync/test/fake_server/unique_client_entity.cc

Issue 998373004: Sync: Generalize entity injection in Android tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 "sync/test/fake_server/unique_client_entity.h" 5 #include "sync/test/fake_server/unique_client_entity.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/guid.h" 10 #include "base/guid.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "sync/internal_api/public/base/model_type.h" 12 #include "sync/internal_api/public/base/model_type.h"
13 #include "sync/protocol/sync.pb.h" 13 #include "sync/protocol/sync.pb.h"
14 #include "sync/syncable/syncable_util.h" 14 #include "sync/syncable/syncable_util.h"
15 #include "sync/test/fake_server/fake_server_entity.h" 15 #include "sync/test/fake_server/fake_server_entity.h"
16 #include "sync/test/fake_server/permanent_entity.h" 16 #include "sync/test/fake_server/permanent_entity.h"
17 17
18 using std::string; 18 using std::string;
19 19
20 using syncer::GetModelTypeFromSpecifics;
20 using syncer::ModelType; 21 using syncer::ModelType;
21 using syncer::syncable::GenerateSyncableHash; 22 using syncer::syncable::GenerateSyncableHash;
22 23
23 namespace fake_server { 24 namespace fake_server {
24 25
25 namespace { 26 namespace {
26 27
27 // A version must be passed when creating a FakeServerEntity, but this value 28 // A version must be passed when creating a FakeServerEntity, but this value
28 // is overrideen immediately when saving the entity in FakeServer. 29 // is overrideen immediately when saving the entity in FakeServer.
29 const int64 kUnusedVersion = 0L; 30 const int64 kUnusedVersion = 0L;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 client_entity.version(), 64 client_entity.version(),
64 client_entity.name(), 65 client_entity.name(),
65 client_entity.client_defined_unique_tag(), 66 client_entity.client_defined_unique_tag(),
66 client_entity.specifics(), 67 client_entity.specifics(),
67 client_entity.ctime(), 68 client_entity.ctime(),
68 client_entity.mtime()); 69 client_entity.mtime());
69 } 70 }
70 71
71 // static 72 // static
72 scoped_ptr<FakeServerEntity> UniqueClientEntity::CreateForInjection( 73 scoped_ptr<FakeServerEntity> UniqueClientEntity::CreateForInjection(
73 ModelType model_type,
74 const string& name, 74 const string& name,
75 const sync_pb::EntitySpecifics& entity_specifics) { 75 const sync_pb::EntitySpecifics& entity_specifics) {
76 ModelType model_type = GetModelTypeFromSpecifics(entity_specifics);
76 string client_defined_unique_tag = GenerateSyncableHash(model_type, name); 77 string client_defined_unique_tag = GenerateSyncableHash(model_type, name);
77 string id = FakeServerEntity::CreateId(model_type, base::GenerateGUID()); 78 string id = FakeServerEntity::CreateId(model_type, base::GenerateGUID());
78 return scoped_ptr<FakeServerEntity>( 79 return scoped_ptr<FakeServerEntity>(
79 new UniqueClientEntity(id, 80 new UniqueClientEntity(id,
80 model_type, 81 model_type,
81 kUnusedVersion, 82 kUnusedVersion,
82 name, 83 name,
83 client_defined_unique_tag, 84 client_defined_unique_tag,
84 entity_specifics, 85 entity_specifics,
85 kDefaultTime, 86 kDefaultTime,
(...skipping 28 matching lines...) Expand all
114 115
115 bool UniqueClientEntity::IsDeleted() const { 116 bool UniqueClientEntity::IsDeleted() const {
116 return false; 117 return false;
117 } 118 }
118 119
119 bool UniqueClientEntity::IsFolder() const { 120 bool UniqueClientEntity::IsFolder() const {
120 return false; 121 return false;
121 } 122 }
122 123
123 } // namespace fake_server 124 } // namespace fake_server
OLDNEW
« sync/sync_tests.gypi ('K') | « sync/test/fake_server/unique_client_entity.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698