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

Side by Side Diff: sync/internal_api/test/test_entry_factory.cc

Issue 10795018: [Sync] Remove unneeded 'using syncer::' lines and 'syncer::' scopings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fiix indent Created 8 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/internal_api/public/test/test_entry_factory.h" 5 #include "sync/internal_api/public/test/test_entry_factory.h"
6 6
7 #include "sync/syncable/directory.h" 7 #include "sync/syncable/directory.h"
8 #include "sync/syncable/mutable_entry.h" 8 #include "sync/syncable/mutable_entry.h"
9 #include "sync/syncable/syncable_id.h" 9 #include "sync/syncable/syncable_id.h"
10 #include "sync/syncable/write_transaction.h" 10 #include "sync/syncable/write_transaction.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 entry.Put(syncable::SERVER_SPECIFICS, specifics); 58 entry.Put(syncable::SERVER_SPECIFICS, specifics);
59 if (is_unique) // For top-level nodes. 59 if (is_unique) // For top-level nodes.
60 entry.Put(syncable::UNIQUE_SERVER_TAG, item_id); 60 entry.Put(syncable::UNIQUE_SERVER_TAG, item_id);
61 } 61 }
62 62
63 void TestEntryFactory::CreateUnsyncedItem( 63 void TestEntryFactory::CreateUnsyncedItem(
64 const Id& item_id, 64 const Id& item_id,
65 const Id& parent_id, 65 const Id& parent_id,
66 const string& name, 66 const string& name,
67 bool is_folder, 67 bool is_folder,
68 syncer::ModelType model_type, 68 ModelType model_type,
69 int64* metahandle_out) { 69 int64* metahandle_out) {
70 WriteTransaction trans(FROM_HERE, UNITTEST, directory_); 70 WriteTransaction trans(FROM_HERE, UNITTEST, directory_);
71 Id predecessor_id; 71 Id predecessor_id;
72 DCHECK( 72 DCHECK(
73 directory_->GetLastChildIdForTest(&trans, parent_id, &predecessor_id)); 73 directory_->GetLastChildIdForTest(&trans, parent_id, &predecessor_id));
74 MutableEntry entry(&trans, syncable::CREATE, parent_id, name); 74 MutableEntry entry(&trans, syncable::CREATE, parent_id, name);
75 DCHECK(entry.good()); 75 DCHECK(entry.good());
76 entry.Put(syncable::ID, item_id); 76 entry.Put(syncable::ID, item_id);
77 entry.Put(syncable::BASE_VERSION, 77 entry.Put(syncable::BASE_VERSION,
78 item_id.ServerKnows() ? GetNextRevision() : 0); 78 item_id.ServerKnows() ? GetNextRevision() : 0);
79 entry.Put(syncable::IS_UNSYNCED, true); 79 entry.Put(syncable::IS_UNSYNCED, true);
80 entry.Put(syncable::IS_DIR, is_folder); 80 entry.Put(syncable::IS_DIR, is_folder);
81 entry.Put(syncable::IS_DEL, false); 81 entry.Put(syncable::IS_DEL, false);
82 entry.Put(syncable::PARENT_ID, parent_id); 82 entry.Put(syncable::PARENT_ID, parent_id);
83 CHECK(entry.PutPredecessor(predecessor_id)); 83 CHECK(entry.PutPredecessor(predecessor_id));
84 sync_pb::EntitySpecifics default_specifics; 84 sync_pb::EntitySpecifics default_specifics;
85 syncer::AddDefaultFieldValue(model_type, &default_specifics); 85 AddDefaultFieldValue(model_type, &default_specifics);
86 entry.Put(syncable::SPECIFICS, default_specifics); 86 entry.Put(syncable::SPECIFICS, default_specifics);
87 if (item_id.ServerKnows()) { 87 if (item_id.ServerKnows()) {
88 entry.Put(syncable::SERVER_SPECIFICS, default_specifics); 88 entry.Put(syncable::SERVER_SPECIFICS, default_specifics);
89 entry.Put(syncable::SERVER_IS_DIR, is_folder); 89 entry.Put(syncable::SERVER_IS_DIR, is_folder);
90 entry.Put(syncable::SERVER_PARENT_ID, parent_id); 90 entry.Put(syncable::SERVER_PARENT_ID, parent_id);
91 entry.Put(syncable::SERVER_IS_DEL, false); 91 entry.Put(syncable::SERVER_IS_DEL, false);
92 } 92 }
93 if (metahandle_out) 93 if (metahandle_out)
94 *metahandle_out = entry.Get(syncable::META_HANDLE); 94 *metahandle_out = entry.Get(syncable::META_HANDLE);
95 } 95 }
96 96
97 int64 TestEntryFactory::CreateUnappliedAndUnsyncedItem( 97 int64 TestEntryFactory::CreateUnappliedAndUnsyncedItem(
98 const string& name, 98 const string& name,
99 syncer::ModelType model_type) { 99 ModelType model_type) {
100 int64 metahandle = 0; 100 int64 metahandle = 0;
101 CreateUnsyncedItem( 101 CreateUnsyncedItem(
102 TestIdFactory::MakeServer(name), TestIdFactory::root(), 102 TestIdFactory::MakeServer(name), TestIdFactory::root(),
103 name, false, model_type, &metahandle); 103 name, false, model_type, &metahandle);
104 104
105 WriteTransaction trans(FROM_HERE, UNITTEST, directory_); 105 WriteTransaction trans(FROM_HERE, UNITTEST, directory_);
106 MutableEntry entry(&trans, syncable::GET_BY_HANDLE, metahandle); 106 MutableEntry entry(&trans, syncable::GET_BY_HANDLE, metahandle);
107 if (!entry.good()) { 107 if (!entry.good()) {
108 NOTREACHED(); 108 NOTREACHED();
109 return syncable::kInvalidMetaHandle; 109 return syncable::kInvalidMetaHandle;
110 } 110 }
111 111
112 entry.Put(syncable::IS_UNAPPLIED_UPDATE, true); 112 entry.Put(syncable::IS_UNAPPLIED_UPDATE, true);
113 entry.Put(syncable::SERVER_VERSION, GetNextRevision()); 113 entry.Put(syncable::SERVER_VERSION, GetNextRevision());
114 114
115 return metahandle; 115 return metahandle;
116 } 116 }
117 117
118 int64 TestEntryFactory::CreateSyncedItem( 118 int64 TestEntryFactory::CreateSyncedItem(
119 const std::string& name, syncer::ModelType 119 const std::string& name, ModelType
120 model_type, bool is_folder) { 120 model_type, bool is_folder) {
121 WriteTransaction trans(FROM_HERE, UNITTEST, directory_); 121 WriteTransaction trans(FROM_HERE, UNITTEST, directory_);
122 122
123 syncable::Id parent_id(TestIdFactory::root()); 123 syncable::Id parent_id(TestIdFactory::root());
124 syncable::Id item_id(TestIdFactory::MakeServer(name)); 124 syncable::Id item_id(TestIdFactory::MakeServer(name));
125 int64 version = GetNextRevision(); 125 int64 version = GetNextRevision();
126 126
127 sync_pb::EntitySpecifics default_specifics; 127 sync_pb::EntitySpecifics default_specifics;
128 syncer::AddDefaultFieldValue(model_type, &default_specifics); 128 AddDefaultFieldValue(model_type, &default_specifics);
129 129
130 MutableEntry entry(&trans, syncable::CREATE, parent_id, name); 130 MutableEntry entry(&trans, syncable::CREATE, parent_id, name);
131 if (!entry.good()) { 131 if (!entry.good()) {
132 NOTREACHED(); 132 NOTREACHED();
133 return syncable::kInvalidMetaHandle; 133 return syncable::kInvalidMetaHandle;
134 } 134 }
135 135
136 entry.Put(syncable::ID, item_id); 136 entry.Put(syncable::ID, item_id);
137 entry.Put(syncable::BASE_VERSION, version); 137 entry.Put(syncable::BASE_VERSION, version);
138 entry.Put(syncable::IS_UNSYNCED, false); 138 entry.Put(syncable::IS_UNSYNCED, false);
(...skipping 18 matching lines...) Expand all
157 entry.Put(syncable::SERVER_PARENT_ID, parent_id); 157 entry.Put(syncable::SERVER_PARENT_ID, parent_id);
158 158
159 return entry.Get(syncable::META_HANDLE); 159 return entry.Get(syncable::META_HANDLE);
160 } 160 }
161 161
162 int64 TestEntryFactory::GetNextRevision() { 162 int64 TestEntryFactory::GetNextRevision() {
163 return next_revision_++; 163 return next_revision_++;
164 } 164 }
165 165
166 } // namespace syncer 166 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/test/fake_sync_manager.cc ('k') | sync/internal_api/test/test_internal_components_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698