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

Unified Diff: sync/internal_api/test/test_entry_factory.cc

Issue 11863011: Revert 176340 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/internal_api/sync_manager_impl_unittest.cc ('k') | sync/internal_api/write_node.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/internal_api/test/test_entry_factory.cc
===================================================================
--- sync/internal_api/test/test_entry_factory.cc (revision 176351)
+++ sync/internal_api/test/test_entry_factory.cc (working copy)
@@ -9,7 +9,6 @@
#include "sync/syncable/mutable_entry.h"
#include "sync/syncable/syncable_id.h"
#include "sync/syncable/syncable_read_transaction.h"
-#include "sync/syncable/syncable_util.h"
#include "sync/syncable/syncable_write_transaction.h"
#include "sync/test/engine/test_id_factory.h"
@@ -46,25 +45,6 @@
return entry.Get(syncable::META_HANDLE);
}
-int64 TestEntryFactory::CreateUnappliedNewBookmarkItemWithParent(
- const string& item_id,
- const sync_pb::EntitySpecifics& specifics,
- const string& parent_id) {
- WriteTransaction trans(FROM_HERE, UNITTEST, directory_);
- MutableEntry entry(&trans, syncable::CREATE_NEW_UPDATE_ITEM,
- Id::CreateFromServerId(item_id));
- DCHECK(entry.good());
- entry.Put(syncable::SERVER_VERSION, GetNextRevision());
- entry.Put(syncable::IS_UNAPPLIED_UPDATE, true);
-
- entry.Put(syncable::SERVER_NON_UNIQUE_NAME, item_id);
- entry.Put(syncable::SERVER_PARENT_ID, Id::CreateFromServerId(parent_id));
- entry.Put(syncable::SERVER_IS_DIR, true);
- entry.Put(syncable::SERVER_SPECIFICS, specifics);
-
- return entry.Get(syncable::META_HANDLE);
-}
-
int64 TestEntryFactory::CreateUnappliedNewItem(
const string& item_id,
const sync_pb::EntitySpecifics& specifics,
@@ -93,19 +73,11 @@
bool is_folder,
ModelType model_type,
int64* metahandle_out) {
- if (is_folder) {
- DCHECK_EQ(model_type, BOOKMARKS);
- }
-
WriteTransaction trans(FROM_HERE, UNITTEST, directory_);
-
Id predecessor_id;
- if (model_type == BOOKMARKS) {
- DCHECK(directory_->GetLastChildIdForTest(
- &trans, parent_id, &predecessor_id));
- }
-
- MutableEntry entry(&trans, syncable::CREATE, model_type, parent_id, name);
+ DCHECK(
+ directory_->GetLastChildIdForTest(&trans, parent_id, &predecessor_id));
+ MutableEntry entry(&trans, syncable::CREATE, parent_id, name);
DCHECK(entry.good());
entry.Put(syncable::ID, item_id);
entry.Put(syncable::BASE_VERSION,
@@ -114,18 +86,13 @@
entry.Put(syncable::IS_DIR, is_folder);
entry.Put(syncable::IS_DEL, false);
entry.Put(syncable::PARENT_ID, parent_id);
+ CHECK(entry.PutPredecessor(predecessor_id));
sync_pb::EntitySpecifics default_specifics;
AddDefaultFieldValue(model_type, &default_specifics);
entry.Put(syncable::SPECIFICS, default_specifics);
-
- // Bookmarks get inserted at the end of the list.
- if (model_type == BOOKMARKS) {
- DCHECK(entry.PutPredecessor(predecessor_id));
- }
-
if (item_id.ServerKnows()) {
entry.Put(syncable::SERVER_SPECIFICS, default_specifics);
- entry.Put(syncable::SERVER_IS_DIR, false);
+ entry.Put(syncable::SERVER_IS_DIR, is_folder);
entry.Put(syncable::SERVER_PARENT_ID, parent_id);
entry.Put(syncable::SERVER_IS_DEL, false);
}
@@ -133,12 +100,13 @@
*metahandle_out = entry.Get(syncable::META_HANDLE);
}
-int64 TestEntryFactory::CreateUnappliedAndUnsyncedBookmarkItem(
- const string& name) {
+int64 TestEntryFactory::CreateUnappliedAndUnsyncedItem(
+ const string& name,
+ ModelType model_type) {
int64 metahandle = 0;
CreateUnsyncedItem(
TestIdFactory::MakeServer(name), TestIdFactory::root(),
- name, false, BOOKMARKS, &metahandle);
+ name, false, model_type, &metahandle);
WriteTransaction trans(FROM_HERE, UNITTEST, directory_);
MutableEntry entry(&trans, syncable::GET_BY_HANDLE, metahandle);
@@ -161,7 +129,10 @@
syncable::Id item_id(TestIdFactory::MakeServer(name));
int64 version = GetNextRevision();
- MutableEntry entry(&trans, syncable::CREATE, model_type, parent_id, name);
+ sync_pb::EntitySpecifics default_specifics;
+ AddDefaultFieldValue(model_type, &default_specifics);
+
+ MutableEntry entry(&trans, syncable::CREATE, parent_id, name);
if (!entry.good()) {
NOTREACHED();
return syncable::kInvalidMetaHandle;
@@ -175,19 +146,20 @@
entry.Put(syncable::IS_DEL, false);
entry.Put(syncable::PARENT_ID, parent_id);
- // TODO(sync): Place bookmarks at the end of the list?
if (!entry.PutPredecessor(TestIdFactory::root())) {
NOTREACHED();
return syncable::kInvalidMetaHandle;
}
+ entry.Put(syncable::SPECIFICS, default_specifics);
entry.Put(syncable::SERVER_VERSION, GetNextRevision());
- entry.Put(syncable::IS_UNAPPLIED_UPDATE, false);
- entry.Put(syncable::SERVER_NON_UNIQUE_NAME, name);
- entry.Put(syncable::SERVER_PARENT_ID, parent_id);
+ entry.Put(syncable::IS_UNAPPLIED_UPDATE, true);
+ entry.Put(syncable::SERVER_NON_UNIQUE_NAME, "X");
+ entry.Put(syncable::SERVER_PARENT_ID, TestIdFactory::MakeServer("Y"));
entry.Put(syncable::SERVER_IS_DIR, is_folder);
entry.Put(syncable::SERVER_IS_DEL, false);
- entry.Put(syncable::SERVER_SPECIFICS, entry.Get(syncable::SPECIFICS));
+ entry.Put(syncable::SERVER_SPECIFICS, default_specifics);
+ entry.Put(syncable::SERVER_PARENT_ID, parent_id);
return entry.Get(syncable::META_HANDLE);
}
« no previous file with comments | « sync/internal_api/sync_manager_impl_unittest.cc ('k') | sync/internal_api/write_node.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698