summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-12 19:25:25 +0000
committerrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-12 19:25:25 +0000
commit47b0ab7c912b4b884c6876c2b6c05c6e8e53a9e1 (patch)
tree5add5e881a6c742a134d0880f0657f1502ad8db9
parentf8621b0f6d9652721f012fe68595be02f644ac00 (diff)
downloadchromium_src-47b0ab7c912b4b884c6876c2b6c05c6e8e53a9e1.zip
chromium_src-47b0ab7c912b4b884c6876c2b6c05c6e8e53a9e1.tar.gz
chromium_src-47b0ab7c912b4b884c6876c2b6c05c6e8e53a9e1.tar.bz2
reland: sync: Initialize entries with a model type
This change modifies two important sync functions. The first is MutableEntry's CREATE constructor. It now requires that the ModelType of the entry to be specified when the entry is create. This doesn't quite eliminate the existence of nodes without a valid model type (the CREATE_NEW_UPDATE_ITEM can still make them), but it helps. This paves the way for the upcoming UniquePosition change. Part of that change is that bookmarks must be granted a unique tag on creation. To support this, we must know at creation time the type of a new entry, so we can take the appropriate bookmark-specific steps if necessary. The second function to get a new signature is WriteNode's InitByCreation(), which has been renamed to WriteNode::InitBookmarkByCreation(). The function can only be used to create bookmarks, so the new name describes its function more precisely. Updates to the call-sites of MutableEntry's constructor make up the majority of this change. This change also includes some minor updates to test functions that create entries to make them compatible with the stricter assertions or to make them more closely reflect real world behaviour. NOTE: The previous version of this patch misused DCHECK() so it did not function correctly in release mode. This has since been fixed. BUG=145412,126505 Review URL: https://chromiumcodereview.appspot.com/11861017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176575 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/sync/glue/bookmark_change_processor.cc4
-rw-r--r--chrome/browser/sync/profile_sync_service_autofill_unittest.cc3
-rw-r--r--chrome/browser/sync/profile_sync_service_bookmark_unittest.cc7
-rw-r--r--sync/engine/apply_updates_and_resolve_conflicts_command_unittest.cc29
-rw-r--r--sync/engine/process_commit_response_command_unittest.cc183
-rw-r--r--sync/engine/syncer_unittest.cc173
-rw-r--r--sync/internal_api/public/test/test_entry_factory.h27
-rw-r--r--sync/internal_api/public/write_node.h14
-rw-r--r--sync/internal_api/sync_encryption_handler_impl_unittest.cc1
-rw-r--r--sync/internal_api/sync_manager_impl_unittest.cc89
-rw-r--r--sync/internal_api/test/test_entry_factory.cc68
-rw-r--r--sync/internal_api/write_node.cc34
-rw-r--r--sync/syncable/mutable_entry.cc36
-rw-r--r--sync/syncable/mutable_entry.h9
-rw-r--r--sync/syncable/syncable_unittest.cc129
-rw-r--r--sync/test/engine/test_syncable_utils.cc1
16 files changed, 401 insertions, 406 deletions
diff --git a/chrome/browser/sync/glue/bookmark_change_processor.cc b/chrome/browser/sync/glue/bookmark_change_processor.cc
index b55d279..344f5a9 100644
--- a/chrome/browser/sync/glue/bookmark_change_processor.cc
+++ b/chrome/browser/sync/glue/bookmark_change_processor.cc
@@ -404,7 +404,7 @@ bool BookmarkChangeProcessor::PlaceSyncNode(MoveOrCreate operation,
if (index == 0) {
// Insert into first position.
success = (operation == CREATE) ?
- dst->InitByCreation(syncer::BOOKMARKS, sync_parent, NULL) :
+ dst->InitBookmarkByCreation(sync_parent, NULL) :
dst->SetPosition(sync_parent, NULL);
if (success) {
DCHECK_EQ(dst->GetParentId(), sync_parent.GetId());
@@ -420,7 +420,7 @@ bool BookmarkChangeProcessor::PlaceSyncNode(MoveOrCreate operation,
return false;
}
success = (operation == CREATE) ?
- dst->InitByCreation(syncer::BOOKMARKS, sync_parent, &sync_prev) :
+ dst->InitBookmarkByCreation(sync_parent, &sync_prev) :
dst->SetPosition(sync_parent, &sync_prev);
if (success) {
DCHECK_EQ(dst->GetParentId(), sync_parent.GetId());
diff --git a/chrome/browser/sync/profile_sync_service_autofill_unittest.cc b/chrome/browser/sync/profile_sync_service_autofill_unittest.cc
index c952eab..2e8ac94 100644
--- a/chrome/browser/sync/profile_sync_service_autofill_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_autofill_unittest.cc
@@ -741,7 +741,8 @@ class FakeServerUpdater : public base::RefCountedThreadSafe<FakeServerUpdater> {
// Simulates effects of UpdateLocalDataFromServerData
MutableEntry parent(&trans, GET_BY_SERVER_TAG,
syncer::ModelTypeToRootTag(syncer::AUTOFILL));
- MutableEntry item(&trans, CREATE, parent.Get(syncer::syncable::ID), tag);
+ MutableEntry item(&trans, CREATE, syncer::AUTOFILL,
+ parent.Get(syncer::syncable::ID), tag);
ASSERT_TRUE(item.good());
item.Put(SPECIFICS, entity_specifics);
item.Put(SERVER_SPECIFICS, entity_specifics);
diff --git a/chrome/browser/sync/profile_sync_service_bookmark_unittest.cc b/chrome/browser/sync/profile_sync_service_bookmark_unittest.cc
index 618b4ee..2b72b22 100644
--- a/chrome/browser/sync/profile_sync_service_bookmark_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_bookmark_unittest.cc
@@ -81,13 +81,12 @@ class FakeServerChange {
EXPECT_EQ(BaseNode::INIT_OK, parent.InitByIdLookup(parent_id));
syncer::WriteNode node(trans_);
if (predecessor_id == 0) {
- EXPECT_TRUE(node.InitByCreation(syncer::BOOKMARKS, parent, NULL));
+ EXPECT_TRUE(node.InitBookmarkByCreation(parent, NULL));
} else {
syncer::ReadNode predecessor(trans_);
EXPECT_EQ(BaseNode::INIT_OK, predecessor.InitByIdLookup(predecessor_id));
EXPECT_EQ(predecessor.GetParentId(), parent.GetId());
- EXPECT_TRUE(node.InitByCreation(syncer::BOOKMARKS, parent,
- &predecessor));
+ EXPECT_TRUE(node.InitBookmarkByCreation(parent, &predecessor));
}
EXPECT_EQ(node.GetPredecessorId(), predecessor_id);
EXPECT_EQ(node.GetParentId(), parent_id);
@@ -361,7 +360,7 @@ class ProfileSyncServiceBookmarkTest : public testing::Test {
predecessor = &predecessor_node;
}
syncer::WriteNode node(&trans);
- if (!node.InitByCreation(type, root, predecessor))
+ if (!node.InitBookmarkByCreation(root, predecessor))
return false;
node.SetIsFolder(true);
node.GetMutableEntryForTest()->Put(
diff --git a/sync/engine/apply_updates_and_resolve_conflicts_command_unittest.cc b/sync/engine/apply_updates_and_resolve_conflicts_command_unittest.cc
index 97d4c33..c341e8f 100644
--- a/sync/engine/apply_updates_and_resolve_conflicts_command_unittest.cc
+++ b/sync/engine/apply_updates_and_resolve_conflicts_command_unittest.cc
@@ -71,12 +71,10 @@ class ApplyUpdatesAndResolveConflictsCommandTest : public SyncerCommandTest {
TEST_F(ApplyUpdatesAndResolveConflictsCommandTest, Simple) {
string root_server_id = syncable::GetNullId().GetServerId();
- entry_factory_->CreateUnappliedNewItemWithParent("parent",
- DefaultBookmarkSpecifics(),
- root_server_id);
- entry_factory_->CreateUnappliedNewItemWithParent("child",
- DefaultBookmarkSpecifics(),
- "parent");
+ entry_factory_->CreateUnappliedNewBookmarkItemWithParent(
+ "parent", DefaultBookmarkSpecifics(), root_server_id);
+ entry_factory_->CreateUnappliedNewBookmarkItemWithParent(
+ "child", DefaultBookmarkSpecifics(), "parent");
ExpectGroupToChange(apply_updates_command_, GROUP_UI);
apply_updates_command_.ExecuteImpl(session());
@@ -95,15 +93,15 @@ TEST_F(ApplyUpdatesAndResolveConflictsCommandTest,
// Set a bunch of updates which are difficult to apply in the order
// they're received due to dependencies on other unseen items.
string root_server_id = syncable::GetNullId().GetServerId();
- entry_factory_->CreateUnappliedNewItemWithParent(
+ entry_factory_->CreateUnappliedNewBookmarkItemWithParent(
"a_child_created_first", DefaultBookmarkSpecifics(), "parent");
- entry_factory_->CreateUnappliedNewItemWithParent(
+ entry_factory_->CreateUnappliedNewBookmarkItemWithParent(
"x_child_created_first", DefaultBookmarkSpecifics(), "parent");
- entry_factory_->CreateUnappliedNewItemWithParent(
+ entry_factory_->CreateUnappliedNewBookmarkItemWithParent(
"parent", DefaultBookmarkSpecifics(), root_server_id);
- entry_factory_->CreateUnappliedNewItemWithParent(
+ entry_factory_->CreateUnappliedNewBookmarkItemWithParent(
"a_child_created_second", DefaultBookmarkSpecifics(), "parent");
- entry_factory_->CreateUnappliedNewItemWithParent(
+ entry_factory_->CreateUnappliedNewBookmarkItemWithParent(
"x_child_created_second", DefaultBookmarkSpecifics(), "parent");
ExpectGroupToChange(apply_updates_command_, GROUP_UI);
@@ -119,7 +117,7 @@ TEST_F(ApplyUpdatesAndResolveConflictsCommandTest,
// expect the command to detect that this update can't be applied because it is
// in a CONFLICT state.
TEST_F(ApplyUpdatesAndResolveConflictsCommandTest, SimpleConflict) {
- entry_factory_->CreateUnappliedAndUnsyncedItem("item", BOOKMARKS);
+ entry_factory_->CreateUnappliedAndUnsyncedBookmarkItem("item");
ExpectGroupToChange(apply_updates_command_, GROUP_UI);
apply_updates_command_.ExecuteImpl(session());
@@ -139,8 +137,8 @@ TEST_F(ApplyUpdatesAndResolveConflictsCommandTest, SimpleConflict) {
// CONFLICT_HIERARCHY state.
TEST_F(ApplyUpdatesAndResolveConflictsCommandTest, HierarchyAndSimpleConflict) {
// Create a simply-conflicting item. It will start with valid parent ids.
- int64 handle = entry_factory_->CreateUnappliedAndUnsyncedItem(
- "orphaned_by_server", BOOKMARKS);
+ int64 handle = entry_factory_->CreateUnappliedAndUnsyncedBookmarkItem(
+ "orphaned_by_server");
{
// Manually set the SERVER_PARENT_ID to bad value.
// A bad parent indicates a hierarchy conflict.
@@ -242,8 +240,7 @@ TEST_F(ApplyUpdatesAndResolveConflictsCommandTest,
// Create a server-deleted directory.
{
// Create it as a child of root node.
- int64 handle =
- entry_factory_->CreateSyncedItem("parent", BOOKMARKS, true);
+ int64 handle = entry_factory_->CreateSyncedItem("parent", BOOKMARKS, true);
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
MutableEntry entry(&trans, syncable::GET_BY_HANDLE, handle);
diff --git a/sync/engine/process_commit_response_command_unittest.cc b/sync/engine/process_commit_response_command_unittest.cc
index f96ea5e..40bd61b 100644
--- a/sync/engine/process_commit_response_command_unittest.cc
+++ b/sync/engine/process_commit_response_command_unittest.cc
@@ -8,6 +8,7 @@
#include "base/location.h"
#include "base/stringprintf.h"
+#include "sync/internal_api/public/test/test_entry_factory.h"
#include "sync/protocol/bookmark_specifics.pb.h"
#include "sync/protocol/sync.pb.h"
#include "sync/sessions/sync_session.h"
@@ -55,13 +56,14 @@ class ProcessCommitResponseCommandTest : public SyncerCommandTest {
(*mutable_routing_info())[AUTOFILL] = GROUP_DB;
SyncerCommandTest::SetUp();
+
+ test_entry_factory_.reset(new TestEntryFactory(directory()));
}
protected:
ProcessCommitResponseCommandTest()
- : next_old_revision_(1),
- next_new_revision_(4000),
+ : next_new_revision_(4000),
next_server_position_(10000) {
}
@@ -75,59 +77,22 @@ class ProcessCommitResponseCommandTest : public SyncerCommandTest {
<< "Item should have a valid (positive) server base revision";
}
- // Create an unsynced item in the database. If item_id is a local ID, it
- // will be treated as a create-new. Otherwise, if it's a server ID, we'll
- // fake the server data so that it looks like it exists on the server.
- // Returns the methandle of the created item in |metahandle_out| if not NULL.
- void CreateUnsyncedItem(const Id& item_id,
- const Id& parent_id,
- const string& name,
- bool is_folder,
- ModelType model_type,
- int64* metahandle_out) {
- WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- Id predecessor_id;
- ASSERT_TRUE(
- directory()->GetLastChildIdForTest(&trans, parent_id, &predecessor_id));
- MutableEntry entry(&trans, syncable::CREATE, parent_id, name);
- ASSERT_TRUE(entry.good());
- entry.Put(syncable::ID, item_id);
- entry.Put(syncable::BASE_VERSION,
- item_id.ServerKnows() ? next_old_revision_++ : 0);
- entry.Put(syncable::IS_UNSYNCED, true);
- entry.Put(syncable::IS_DIR, is_folder);
- entry.Put(syncable::IS_DEL, false);
- entry.Put(syncable::PARENT_ID, parent_id);
- entry.PutPredecessor(predecessor_id);
- sync_pb::EntitySpecifics default_specifics;
- AddDefaultFieldValue(model_type, &default_specifics);
- entry.Put(syncable::SPECIFICS, default_specifics);
- if (item_id.ServerKnows()) {
- entry.Put(syncable::SERVER_SPECIFICS, default_specifics);
- entry.Put(syncable::SERVER_IS_DIR, is_folder);
- entry.Put(syncable::SERVER_PARENT_ID, parent_id);
- entry.Put(syncable::SERVER_IS_DEL, false);
- }
- if (metahandle_out)
- *metahandle_out = entry.Get(syncable::META_HANDLE);
- }
-
- // Create a new unsynced item in the database, and synthesize a commit
- // record and a commit response for it in the syncer session. If item_id
- // is a local ID, the item will be a create operation. Otherwise, it
- // will be an edit.
- void CreateUnprocessedCommitResult(
+ // Create a new unsynced item in the database, and synthesize a commit record
+ // and a commit response for it in the syncer session. If item_id is a local
+ // ID, the item will be a create operation. Otherwise, it will be an edit.
+ // Returns the metahandle of the newly created item.
+ int CreateUnprocessedCommitResult(
const Id& item_id,
const Id& parent_id,
const string& name,
+ bool is_folder,
ModelType model_type,
sessions::OrderedCommitSet *commit_set,
sync_pb::ClientToServerMessage *commit,
sync_pb::ClientToServerResponse *response) {
- bool is_folder = true;
int64 metahandle = 0;
- CreateUnsyncedItem(item_id, parent_id, name, is_folder, model_type,
- &metahandle);
+ test_entry_factory_->CreateUnsyncedItem(item_id, parent_id, name,
+ is_folder, model_type, &metahandle);
// ProcessCommitResponseCommand consumes commit_ids from the session
// state, so we need to update that. O(n^2) because it's a test.
@@ -135,19 +100,26 @@ class ProcessCommitResponseCommandTest : public SyncerCommandTest {
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
MutableEntry entry(&trans, syncable::GET_BY_ID, item_id);
- ASSERT_TRUE(entry.good());
+ EXPECT_TRUE(entry.good());
entry.Put(syncable::SYNCING, true);
// Add to the commit message.
+ // TODO(sync): Use the real commit-building code to construct this.
commit->set_message_contents(ClientToServerMessage::COMMIT);
sync_pb::SyncEntity* entity = commit->mutable_commit()->add_entries();
- entity->set_non_unique_name(name);
- entity->set_folder(is_folder);
- entity->set_parent_id_string(SyncableIdToProto(parent_id));
+ entity->set_non_unique_name(entry.Get(syncable::NON_UNIQUE_NAME));
+ entity->set_folder(entry.Get(syncable::IS_DIR));
+ entity->set_parent_id_string(
+ SyncableIdToProto(entry.Get(syncable::PARENT_ID)));
entity->set_version(entry.Get(syncable::BASE_VERSION));
entity->mutable_specifics()->CopyFrom(entry.Get(syncable::SPECIFICS));
entity->set_id_string(SyncableIdToProto(item_id));
+ if (!entry.Get(syncable::UNIQUE_CLIENT_TAG).empty()) {
+ entity->set_client_defined_unique_tag(
+ entry.Get(syncable::UNIQUE_CLIENT_TAG));
+ }
+
// Add to the response message.
response->set_error_code(sync_pb::SyncEnums::SUCCESS);
sync_pb::CommitResponse_EntryResponse* entry_response =
@@ -173,6 +145,8 @@ class ProcessCommitResponseCommandTest : public SyncerCommandTest {
response->commit().entryresponse(i).id_string());
}
}
+
+ return metahandle;
}
void SetLastErrorCode(sync_pb::CommitResponse::ResponseType error_code,
@@ -184,8 +158,8 @@ class ProcessCommitResponseCommandTest : public SyncerCommandTest {
}
TestIdFactory id_factory_;
+ scoped_ptr<TestEntryFactory> test_entry_factory_;
private:
- int64 next_old_revision_;
int64 next_new_revision_;
int64 next_server_position_;
DISALLOW_COPY_AND_ASSIGN(ProcessCommitResponseCommandTest);
@@ -197,69 +171,63 @@ TEST_F(ProcessCommitResponseCommandTest, MultipleCommitIdProjections) {
sync_pb::ClientToServerResponse response;
Id bookmark_folder_id = id_factory_.NewLocalId();
- Id bookmark_id1 = id_factory_.NewLocalId();
- Id bookmark_id2 = id_factory_.NewLocalId();
- Id pref_id1 = id_factory_.NewLocalId(), pref_id2 = id_factory_.NewLocalId();
- Id autofill_id1 = id_factory_.NewLocalId();
- Id autofill_id2 = id_factory_.NewLocalId();
- CreateUnprocessedCommitResult(bookmark_folder_id, id_factory_.root(),
- "A bookmark folder", BOOKMARKS,
- &commit_set, &request, &response);
- CreateUnprocessedCommitResult(bookmark_id1, bookmark_folder_id,
- "bookmark 1", BOOKMARKS,
- &commit_set, &request, &response);
- CreateUnprocessedCommitResult(bookmark_id2, bookmark_folder_id,
- "bookmark 2", BOOKMARKS,
- &commit_set, &request, &response);
- CreateUnprocessedCommitResult(pref_id1, id_factory_.root(),
- "Pref 1", PREFERENCES,
- &commit_set, &request, &response);
- CreateUnprocessedCommitResult(pref_id2, id_factory_.root(),
- "Pref 2", PREFERENCES,
- &commit_set, &request, &response);
- CreateUnprocessedCommitResult(autofill_id1, id_factory_.root(),
- "Autofill 1", AUTOFILL,
- &commit_set, &request, &response);
- CreateUnprocessedCommitResult(autofill_id2, id_factory_.root(),
- "Autofill 2", AUTOFILL,
- &commit_set, &request, &response);
+ int bookmark_folder_handle = CreateUnprocessedCommitResult(
+ bookmark_folder_id, id_factory_.root(), "A bookmark folder", true,
+ BOOKMARKS, &commit_set, &request, &response);
+ int bookmark1_handle = CreateUnprocessedCommitResult(
+ id_factory_.NewLocalId(), bookmark_folder_id, "bookmark 1", false,
+ BOOKMARKS, &commit_set, &request, &response);
+ int bookmark2_handle = CreateUnprocessedCommitResult(
+ id_factory_.NewLocalId(), bookmark_folder_id, "bookmark 2", false,
+ BOOKMARKS, &commit_set, &request, &response);
+ int pref1_handle = CreateUnprocessedCommitResult(
+ id_factory_.NewLocalId(), id_factory_.root(), "Pref 1", false,
+ PREFERENCES, &commit_set, &request, &response);
+ int pref2_handle = CreateUnprocessedCommitResult(
+ id_factory_.NewLocalId(), id_factory_.root(), "Pref 2", false,
+ PREFERENCES, &commit_set, &request, &response);
+ int autofill1_handle = CreateUnprocessedCommitResult(
+ id_factory_.NewLocalId(), id_factory_.root(), "Autofill 1", false,
+ AUTOFILL, &commit_set, &request, &response);
+ int autofill2_handle = CreateUnprocessedCommitResult(
+ id_factory_.NewLocalId(), id_factory_.root(), "Autofill 2", false,
+ AUTOFILL, &commit_set, &request, &response);
ProcessCommitResponseCommand command(commit_set, request, response);
ExpectGroupsToChange(command, GROUP_UI, GROUP_DB);
command.ExecuteImpl(session());
syncable::ReadTransaction trans(FROM_HERE, directory());
- Id new_fid;
- ASSERT_TRUE(directory()->GetFirstChildId(
- &trans, id_factory_.root(), &new_fid));
+
+ Entry b_folder(&trans, syncable::GET_BY_HANDLE, bookmark_folder_handle);
+ ASSERT_TRUE(b_folder.good());
+
+ Id new_fid = b_folder.Get(syncable::ID);
ASSERT_FALSE(new_fid.IsRoot());
EXPECT_TRUE(new_fid.ServerKnows());
EXPECT_FALSE(bookmark_folder_id.ServerKnows());
EXPECT_FALSE(new_fid == bookmark_folder_id);
- Entry b_folder(&trans, syncable::GET_BY_ID, new_fid);
- ASSERT_TRUE(b_folder.good());
+
ASSERT_EQ("A bookmark folder", b_folder.Get(NON_UNIQUE_NAME))
<< "Name of bookmark folder should not change.";
ASSERT_LT(0, b_folder.Get(BASE_VERSION))
<< "Bookmark folder should have a valid (positive) server base revision";
// Look at the two bookmarks in bookmark_folder.
- Id cid;
- ASSERT_TRUE(directory()->GetFirstChildId(&trans, new_fid, &cid));
- Entry b1(&trans, syncable::GET_BY_ID, cid);
- Entry b2(&trans, syncable::GET_BY_ID, b1.GetSuccessorId());
+ Entry b1(&trans, syncable::GET_BY_HANDLE, bookmark1_handle);
+ Entry b2(&trans, syncable::GET_BY_HANDLE, bookmark2_handle);
CheckEntry(&b1, "bookmark 1", BOOKMARKS, new_fid);
CheckEntry(&b2, "bookmark 2", BOOKMARKS, new_fid);
ASSERT_TRUE(b2.GetSuccessorId().IsRoot());
// Look at the prefs and autofill items.
- Entry p1(&trans, syncable::GET_BY_ID, b_folder.GetSuccessorId());
- Entry p2(&trans, syncable::GET_BY_ID, p1.GetSuccessorId());
+ Entry p1(&trans, syncable::GET_BY_HANDLE, pref1_handle);
+ Entry p2(&trans, syncable::GET_BY_HANDLE, pref2_handle);
CheckEntry(&p1, "Pref 1", PREFERENCES, id_factory_.root());
CheckEntry(&p2, "Pref 2", PREFERENCES, id_factory_.root());
- Entry a1(&trans, syncable::GET_BY_ID, p2.GetSuccessorId());
- Entry a2(&trans, syncable::GET_BY_ID, a1.GetSuccessorId());
+ Entry a1(&trans, syncable::GET_BY_HANDLE, autofill1_handle);
+ Entry a2(&trans, syncable::GET_BY_HANDLE, autofill2_handle);
CheckEntry(&a1, "Autofill 1", AUTOFILL, id_factory_.root());
CheckEntry(&a2, "Autofill 2", AUTOFILL, id_factory_.root());
ASSERT_TRUE(a2.GetSuccessorId().IsRoot());
@@ -282,16 +250,18 @@ TEST_F(ProcessCommitResponseCommandTest, NewFolderCommitKeepsChildOrder) {
// Create the parent folder, a new item whose ID will change on commit.
Id folder_id = id_factory_.NewLocalId();
- CreateUnprocessedCommitResult(folder_id, id_factory_.root(), "A",
- BOOKMARKS,
+ CreateUnprocessedCommitResult(folder_id, id_factory_.root(),
+ "A", true, BOOKMARKS,
&commit_set, &request, &response);
// Verify that the item is reachable.
{
- syncable::ReadTransaction trans(FROM_HERE, directory());
Id child_id;
+ syncable::ReadTransaction trans(FROM_HERE, directory());
+ syncable::Entry root(&trans, syncable::GET_BY_ID, id_factory_.root());
+ ASSERT_TRUE(root.good());
ASSERT_TRUE(directory()->GetFirstChildId(
- &trans, id_factory_.root(), &child_id));
+ &trans, id_factory_.root(), &child_id));
ASSERT_EQ(folder_id, child_id);
}
@@ -303,8 +273,8 @@ TEST_F(ProcessCommitResponseCommandTest, NewFolderCommitKeepsChildOrder) {
// Alternate between new and old child items, just for kicks.
Id id = (i % 4 < 2) ? id_factory_.NewLocalId() : id_factory_.NewServerId();
CreateUnprocessedCommitResult(
- id, folder_id, base::StringPrintf("Item %d", i), BOOKMARKS,
- &commit_set, &request, &response);
+ id, folder_id, base::StringPrintf("Item %d", i), false,
+ BOOKMARKS, &commit_set, &request, &response);
}
// The second 25 children will be unsynced items but NOT part of the commit
// batch. When the ID of the parent folder changes during the commit,
@@ -313,8 +283,9 @@ TEST_F(ProcessCommitResponseCommandTest, NewFolderCommitKeepsChildOrder) {
for (; i < 2*batch_size; ++i) {
// Alternate between new and old child items, just for kicks.
Id id = (i % 4 < 2) ? id_factory_.NewLocalId() : id_factory_.NewServerId();
- CreateUnsyncedItem(id, folder_id, base::StringPrintf("Item %d", i),
- false, BOOKMARKS, NULL);
+ test_entry_factory_->CreateUnsyncedItem(
+ id, folder_id, base::StringPrintf("Item %d", i),
+ false, BOOKMARKS, NULL);
}
// Process the commit response for the parent folder and the first
@@ -413,15 +384,17 @@ TEST_P(MixedResult, ExtensionActivity) {
<< "To not be lame, this test requires more than one active group.";
// Bookmark item setup.
- CreateUnprocessedCommitResult(id_factory_.NewServerId(),
- id_factory_.root(), "Some bookmark", BOOKMARKS,
- &commit_set, &request, &response);
+ CreateUnprocessedCommitResult(
+ id_factory_.NewServerId(),
+ id_factory_.root(), "Some bookmark", false,
+ BOOKMARKS, &commit_set, &request, &response);
if (ShouldFailBookmarkCommit())
SetLastErrorCode(CommitResponse::TRANSIENT_ERROR, &response);
// Autofill item setup.
- CreateUnprocessedCommitResult(id_factory_.NewServerId(),
- id_factory_.root(), "Some autofill", AUTOFILL,
- &commit_set, &request, &response);
+ CreateUnprocessedCommitResult(
+ id_factory_.NewServerId(),
+ id_factory_.root(), "Some autofill", false,
+ AUTOFILL, &commit_set, &request, &response);
if (ShouldFailAutofillCommit())
SetLastErrorCode(CommitResponse::TRANSIENT_ERROR, &response);
diff --git a/sync/engine/syncer_unittest.cc b/sync/engine/syncer_unittest.cc
index 7fef4f4..669bda2 100644
--- a/sync/engine/syncer_unittest.cc
+++ b/sync/engine/syncer_unittest.cc
@@ -355,7 +355,7 @@ class SyncerTest : public testing::Test,
}
string utf8_name = test->id.GetServerId();
string name(utf8_name.begin(), utf8_name.end());
- MutableEntry entry(&trans, CREATE, test->parent_id, name);
+ MutableEntry entry(&trans, CREATE, BOOKMARKS, test->parent_id, name);
entry.Put(syncable::ID, test->id);
if (test->id.ServerKnows()) {
@@ -458,8 +458,8 @@ class SyncerTest : public testing::Test,
int64 CreateUnsyncedDirectory(const string& entry_name,
const syncable::Id& id) {
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
- MutableEntry entry(&wtrans, syncable::CREATE, wtrans.root_id(),
- entry_name);
+ MutableEntry entry(
+ &wtrans, CREATE, BOOKMARKS, wtrans.root_id(), entry_name);
EXPECT_TRUE(entry.good());
entry.Put(syncable::IS_UNSYNCED, true);
entry.Put(syncable::IS_DIR, true);
@@ -987,15 +987,14 @@ TEST_F(SyncerTest, EncryptionAwareConflicts) {
TEST_F(SyncerTest, TestGetUnsyncedAndSimpleCommit) {
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
- MutableEntry parent(&wtrans, syncable::CREATE, wtrans.root_id(),
- "Pete");
+ MutableEntry parent(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "Pete");
ASSERT_TRUE(parent.good());
parent.Put(syncable::IS_UNSYNCED, true);
parent.Put(syncable::IS_DIR, true);
parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics());
parent.Put(syncable::BASE_VERSION, 1);
parent.Put(syncable::ID, parent_id_);
- MutableEntry child(&wtrans, syncable::CREATE, parent_id_, "Pete");
+ MutableEntry child(&wtrans, CREATE, BOOKMARKS, parent_id_, "Pete");
ASSERT_TRUE(child.good());
child.Put(syncable::ID, child_id_);
child.Put(syncable::BASE_VERSION, 1);
@@ -1020,20 +1019,20 @@ TEST_F(SyncerTest, TestPurgeWhileUnsynced) {
syncable::Id pref_node_id = TestIdFactory::MakeServer("Tim");
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
- MutableEntry parent(&wtrans, syncable::CREATE, wtrans.root_id(), "Pete");
+ MutableEntry parent(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "Pete");
ASSERT_TRUE(parent.good());
parent.Put(syncable::IS_UNSYNCED, true);
parent.Put(syncable::IS_DIR, true);
parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics());
parent.Put(syncable::BASE_VERSION, 1);
parent.Put(syncable::ID, parent_id_);
- MutableEntry child(&wtrans, syncable::CREATE, parent_id_, "Pete");
+ MutableEntry child(&wtrans, CREATE, BOOKMARKS, parent_id_, "Pete");
ASSERT_TRUE(child.good());
child.Put(syncable::ID, child_id_);
child.Put(syncable::BASE_VERSION, 1);
WriteTestDataToEntry(&wtrans, &child);
- MutableEntry parent2(&wtrans, syncable::CREATE, wtrans.root_id(), "Tim");
+ MutableEntry parent2(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "Tim");
ASSERT_TRUE(parent2.good());
parent2.Put(syncable::IS_UNSYNCED, true);
parent2.Put(syncable::IS_DIR, true);
@@ -1067,7 +1066,7 @@ TEST_F(SyncerTest, TestPurgeWhileUnapplied) {
// Similar to above, but for unapplied items. Bug 49278.
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
- MutableEntry parent(&wtrans, syncable::CREATE, wtrans.root_id(), "Pete");
+ MutableEntry parent(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "Pete");
ASSERT_TRUE(parent.good());
parent.Put(syncable::IS_UNAPPLIED_UPDATE, true);
parent.Put(syncable::IS_DIR, true);
@@ -1222,24 +1221,23 @@ TEST_F(SyncerTest, TestCommitListOrderingWithNesting) {
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
{
- MutableEntry parent(&wtrans, syncable::CREATE, wtrans.root_id(),
- "Bob");
+ MutableEntry parent(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "Bob");
ASSERT_TRUE(parent.good());
parent.Put(syncable::IS_UNSYNCED, true);
parent.Put(syncable::IS_DIR, true);
parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics());
parent.Put(syncable::ID, ids_.FromNumber(100));
parent.Put(syncable::BASE_VERSION, 1);
- MutableEntry child(&wtrans, syncable::CREATE, ids_.FromNumber(100),
- "Bob");
+ MutableEntry child(
+ &wtrans, CREATE, BOOKMARKS, ids_.FromNumber(100), "Bob");
ASSERT_TRUE(child.good());
child.Put(syncable::IS_UNSYNCED, true);
child.Put(syncable::IS_DIR, true);
child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics());
child.Put(syncable::ID, ids_.FromNumber(101));
child.Put(syncable::BASE_VERSION, 1);
- MutableEntry grandchild(&wtrans, syncable::CREATE, ids_.FromNumber(101),
- "Bob");
+ MutableEntry grandchild(
+ &wtrans, CREATE, BOOKMARKS, ids_.FromNumber(101), "Bob");
ASSERT_TRUE(grandchild.good());
grandchild.Put(syncable::ID, ids_.FromNumber(102));
grandchild.Put(syncable::IS_UNSYNCED, true);
@@ -1249,8 +1247,7 @@ TEST_F(SyncerTest, TestCommitListOrderingWithNesting) {
{
// Create three deleted items which deletions we expect to be sent to the
// server.
- MutableEntry parent(&wtrans, syncable::CREATE, wtrans.root_id(),
- "Pete");
+ MutableEntry parent(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "Pete");
ASSERT_TRUE(parent.good());
parent.Put(syncable::ID, ids_.FromNumber(103));
parent.Put(syncable::IS_UNSYNCED, true);
@@ -1259,8 +1256,8 @@ TEST_F(SyncerTest, TestCommitListOrderingWithNesting) {
parent.Put(syncable::IS_DEL, true);
parent.Put(syncable::BASE_VERSION, 1);
parent.Put(syncable::MTIME, now_minus_2h);
- MutableEntry child(&wtrans, syncable::CREATE, ids_.FromNumber(103),
- "Pete");
+ MutableEntry child(
+ &wtrans, CREATE, BOOKMARKS, ids_.FromNumber(103), "Pete");
ASSERT_TRUE(child.good());
child.Put(syncable::ID, ids_.FromNumber(104));
child.Put(syncable::IS_UNSYNCED, true);
@@ -1269,8 +1266,8 @@ TEST_F(SyncerTest, TestCommitListOrderingWithNesting) {
child.Put(syncable::IS_DEL, true);
child.Put(syncable::BASE_VERSION, 1);
child.Put(syncable::MTIME, now_minus_2h);
- MutableEntry grandchild(&wtrans, syncable::CREATE, ids_.FromNumber(104),
- "Pete");
+ MutableEntry grandchild(
+ &wtrans, CREATE, BOOKMARKS, ids_.FromNumber(104), "Pete");
ASSERT_TRUE(grandchild.good());
grandchild.Put(syncable::ID, ids_.FromNumber(105));
grandchild.Put(syncable::IS_UNSYNCED, true);
@@ -1299,32 +1296,35 @@ TEST_F(SyncerTest, TestCommitListOrderingWithNesting) {
}
TEST_F(SyncerTest, TestCommitListOrderingWithNewItems) {
+ syncable::Id parent1_id = ids_.MakeServer("p1");
+ syncable::Id parent2_id = ids_.MakeServer("p2");
+
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
- MutableEntry parent(&wtrans, syncable::CREATE, wtrans.root_id(), "1");
+ MutableEntry parent(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "1");
ASSERT_TRUE(parent.good());
parent.Put(syncable::IS_UNSYNCED, true);
parent.Put(syncable::IS_DIR, true);
parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics());
- parent.Put(syncable::ID, parent_id_);
- MutableEntry child(&wtrans, syncable::CREATE, wtrans.root_id(), "2");
+ parent.Put(syncable::ID, parent1_id);
+ MutableEntry child(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "2");
ASSERT_TRUE(child.good());
child.Put(syncable::IS_UNSYNCED, true);
child.Put(syncable::IS_DIR, true);
child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics());
- child.Put(syncable::ID, child_id_);
+ child.Put(syncable::ID, parent2_id);
parent.Put(syncable::BASE_VERSION, 1);
child.Put(syncable::BASE_VERSION, 1);
}
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
- MutableEntry parent(&wtrans, syncable::CREATE, parent_id_, "A");
+ MutableEntry parent(&wtrans, CREATE, BOOKMARKS, parent1_id, "A");
ASSERT_TRUE(parent.good());
parent.Put(syncable::IS_UNSYNCED, true);
parent.Put(syncable::IS_DIR, true);
parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics());
parent.Put(syncable::ID, ids_.FromNumber(102));
- MutableEntry child(&wtrans, syncable::CREATE, parent_id_, "B");
+ MutableEntry child(&wtrans, CREATE, BOOKMARKS, parent1_id, "B");
ASSERT_TRUE(child.good());
child.Put(syncable::IS_UNSYNCED, true);
child.Put(syncable::IS_DIR, true);
@@ -1334,13 +1334,13 @@ TEST_F(SyncerTest, TestCommitListOrderingWithNewItems) {
}
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
- MutableEntry parent(&wtrans, syncable::CREATE, child_id_, "A");
+ MutableEntry parent(&wtrans, CREATE, BOOKMARKS, parent2_id, "A");
ASSERT_TRUE(parent.good());
parent.Put(syncable::IS_UNSYNCED, true);
parent.Put(syncable::IS_DIR, true);
parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics());
parent.Put(syncable::ID, ids_.FromNumber(-104));
- MutableEntry child(&wtrans, syncable::CREATE, child_id_, "B");
+ MutableEntry child(&wtrans, CREATE, BOOKMARKS, parent2_id, "B");
ASSERT_TRUE(child.good());
child.Put(syncable::IS_UNSYNCED, true);
child.Put(syncable::IS_DIR, true);
@@ -1352,8 +1352,8 @@ TEST_F(SyncerTest, TestCommitListOrderingWithNewItems) {
SyncShareNudge();
ASSERT_EQ(6u, mock_server_->committed_ids().size());
// If this test starts failing, be aware other sort orders could be valid.
- EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]);
- EXPECT_TRUE(child_id_ == mock_server_->committed_ids()[1]);
+ EXPECT_TRUE(parent1_id == mock_server_->committed_ids()[0]);
+ EXPECT_TRUE(parent2_id == mock_server_->committed_ids()[1]);
EXPECT_TRUE(ids_.FromNumber(102) == mock_server_->committed_ids()[2]);
EXPECT_TRUE(ids_.FromNumber(-103) == mock_server_->committed_ids()[3]);
EXPECT_TRUE(ids_.FromNumber(-104) == mock_server_->committed_ids()[4]);
@@ -1365,18 +1365,18 @@ TEST_F(SyncerTest, TestCommitListOrderingCounterexample) {
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
- MutableEntry parent(&wtrans, syncable::CREATE, wtrans.root_id(), "P");
+ MutableEntry parent(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "P");
ASSERT_TRUE(parent.good());
parent.Put(syncable::IS_UNSYNCED, true);
parent.Put(syncable::IS_DIR, true);
parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics());
parent.Put(syncable::ID, parent_id_);
- MutableEntry child1(&wtrans, syncable::CREATE, parent_id_, "1");
+ MutableEntry child1(&wtrans, CREATE, BOOKMARKS, parent_id_, "1");
ASSERT_TRUE(child1.good());
child1.Put(syncable::IS_UNSYNCED, true);
child1.Put(syncable::ID, child_id_);
child1.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics());
- MutableEntry child2(&wtrans, syncable::CREATE, parent_id_, "2");
+ MutableEntry child2(&wtrans, CREATE, BOOKMARKS, parent_id_, "2");
ASSERT_TRUE(child2.good());
child2.Put(syncable::IS_UNSYNCED, true);
child2.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics());
@@ -1402,7 +1402,7 @@ TEST_F(SyncerTest, TestCommitListOrderingAndNewParent) {
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
- MutableEntry parent(&wtrans, syncable::CREATE, wtrans.root_id(),
+ MutableEntry parent(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(),
parent1_name);
ASSERT_TRUE(parent.good());
parent.Put(syncable::IS_UNSYNCED, true);
@@ -1416,14 +1416,16 @@ TEST_F(SyncerTest, TestCommitListOrderingAndNewParent) {
syncable::Id child_id = ids_.NewServerId();
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
- MutableEntry parent2(&wtrans, syncable::CREATE, parent_id_, parent2_name);
+ MutableEntry parent2(
+ &wtrans, CREATE, BOOKMARKS, parent_id_, parent2_name);
ASSERT_TRUE(parent2.good());
parent2.Put(syncable::IS_UNSYNCED, true);
parent2.Put(syncable::IS_DIR, true);
parent2.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics());
parent2.Put(syncable::ID, parent2_id);
- MutableEntry child(&wtrans, syncable::CREATE, parent2_id, child_name);
+ MutableEntry child(
+ &wtrans, CREATE, BOOKMARKS, parent2_id, child_name);
ASSERT_TRUE(child.good());
child.Put(syncable::IS_UNSYNCED, true);
child.Put(syncable::IS_DIR, true);
@@ -1470,7 +1472,7 @@ TEST_F(SyncerTest, TestCommitListOrderingAndNewParentAndChild) {
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
MutableEntry parent(&wtrans,
- syncable::CREATE,
+ CREATE, BOOKMARKS,
wtrans.root_id(),
parent_name);
ASSERT_TRUE(parent.good());
@@ -1486,14 +1488,15 @@ TEST_F(SyncerTest, TestCommitListOrderingAndNewParentAndChild) {
const Id child_local_id = ids_.NewLocalId();
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
- MutableEntry parent2(&wtrans, syncable::CREATE, parent_id_, parent2_name);
+ MutableEntry parent2(&wtrans, CREATE, BOOKMARKS, parent_id_, parent2_name);
ASSERT_TRUE(parent2.good());
parent2.Put(syncable::IS_UNSYNCED, true);
parent2.Put(syncable::IS_DIR, true);
parent2.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics());
parent2.Put(syncable::ID, parent2_local_id);
- MutableEntry child(&wtrans, syncable::CREATE, parent2_local_id, child_name);
+ MutableEntry child(
+ &wtrans, CREATE, BOOKMARKS, parent2_local_id, child_name);
ASSERT_TRUE(child.good());
child.Put(syncable::IS_UNSYNCED, true);
child.Put(syncable::IS_DIR, true);
@@ -1711,14 +1714,14 @@ TEST_F(SyncerTest, CommitTimeRename) {
// Create a folder and an entry.
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry parent(&trans, CREATE, root_id_, "Folder");
+ MutableEntry parent(&trans, CREATE, BOOKMARKS, root_id_, "Folder");
ASSERT_TRUE(parent.good());
parent.Put(IS_DIR, true);
parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics());
parent.Put(IS_UNSYNCED, true);
metahandle_folder = parent.Get(META_HANDLE);
- MutableEntry entry(&trans, CREATE, parent.Get(ID), "new_entry");
+ MutableEntry entry(&trans, CREATE, BOOKMARKS, parent.Get(ID), "new_entry");
ASSERT_TRUE(entry.good());
metahandle_new_entry = entry.Get(META_HANDLE);
WriteTestDataToEntry(&trans, &entry);
@@ -1759,7 +1762,7 @@ TEST_F(SyncerTest, CommitTimeRenameI18N) {
// Create a folder, expect a commit time rename.
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry parent(&trans, CREATE, root_id_, "Folder");
+ MutableEntry parent(&trans, CREATE, BOOKMARKS, root_id_, "Folder");
ASSERT_TRUE(parent.good());
parent.Put(IS_DIR, true);
parent.Put(SPECIFICS, DefaultBookmarkSpecifics());
@@ -1790,7 +1793,8 @@ TEST_F(SyncerTest, CommitReuniteUpdateAdjustsChildren) {
int64 metahandle_folder;
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry entry(&trans, CREATE, trans.root_id(), "new_folder");
+ MutableEntry entry(
+ &trans, CREATE, BOOKMARKS, trans.root_id(), "new_folder");
ASSERT_TRUE(entry.good());
entry.Put(IS_DIR, true);
entry.Put(SPECIFICS, DefaultBookmarkSpecifics());
@@ -1812,7 +1816,7 @@ TEST_F(SyncerTest, CommitReuniteUpdateAdjustsChildren) {
// Create an entry in the newly created folder.
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry entry(&trans, CREATE, folder_id, "new_entry");
+ MutableEntry entry(&trans, CREATE, BOOKMARKS, folder_id, "new_entry");
ASSERT_TRUE(entry.good());
metahandle_entry = entry.Get(META_HANDLE);
WriteTestDataToEntry(&trans, &entry);
@@ -1881,7 +1885,7 @@ TEST_F(SyncerTest, CommitReuniteUpdate) {
int64 entry_metahandle;
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry entry(&trans, CREATE, trans.root_id(), "new_entry");
+ MutableEntry entry(&trans, CREATE, BOOKMARKS, trans.root_id(), "new_entry");
ASSERT_TRUE(entry.good());
entry_metahandle = entry.Get(META_HANDLE);
WriteTestDataToEntry(&trans, &entry);
@@ -1935,7 +1939,7 @@ TEST_F(SyncerTest, CommitReuniteUpdateDoesNotChokeOnDeletedLocalEntry) {
int64 entry_metahandle;
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry entry(&trans, CREATE, trans.root_id(), "new_entry");
+ MutableEntry entry(&trans, CREATE, BOOKMARKS, trans.root_id(), "new_entry");
ASSERT_TRUE(entry.good());
entry_metahandle = entry.Get(META_HANDLE);
WriteTestDataToEntry(&trans, &entry);
@@ -2099,8 +2103,8 @@ class EntryCreatedInNewFolderTest : public SyncerTest {
"bob"));
CHECK(bob.good());
- MutableEntry entry2(&trans, syncable::CREATE, bob.Get(syncable::ID),
- "bob");
+ MutableEntry entry2(
+ &trans, CREATE, BOOKMARKS, bob.Get(syncable::ID), "bob");
CHECK(entry2.good());
entry2.Put(syncable::IS_DIR, true);
entry2.Put(syncable::IS_UNSYNCED, true);
@@ -2111,8 +2115,7 @@ class EntryCreatedInNewFolderTest : public SyncerTest {
TEST_F(EntryCreatedInNewFolderTest, EntryCreatedInNewFolderMidSync) {
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry entry(&trans, syncable::CREATE, trans.root_id(),
- "bob");
+ MutableEntry entry(&trans, CREATE, BOOKMARKS, trans.root_id(), "bob");
ASSERT_TRUE(entry.good());
entry.Put(syncable::IS_DIR, true);
entry.Put(syncable::IS_UNSYNCED, true);
@@ -2150,7 +2153,7 @@ TEST_F(SyncerTest, UnappliedUpdateOnCreatedItemItemDoesNotCrash) {
{
// Create an item.
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry fred_match(&trans, CREATE, trans.root_id(),
+ MutableEntry fred_match(&trans, CREATE, BOOKMARKS, trans.root_id(),
"fred_match");
ASSERT_TRUE(fred_match.good());
metahandle_fred = fred_match.Get(META_HANDLE);
@@ -2186,13 +2189,13 @@ TEST_F(SyncerTest, UnappliedUpdateOnCreatedItemItemDoesNotCrash) {
TEST_F(SyncerTest, DoublyChangedWithResolver) {
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
- MutableEntry parent(&wtrans, syncable::CREATE, root_id_, "Folder");
+ MutableEntry parent(&wtrans, CREATE, BOOKMARKS, root_id_, "Folder");
ASSERT_TRUE(parent.good());
parent.Put(syncable::IS_DIR, true);
parent.Put(syncable::ID, parent_id_);
parent.Put(syncable::BASE_VERSION, 5);
parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics());
- MutableEntry child(&wtrans, syncable::CREATE, parent_id_, "Pete.htm");
+ MutableEntry child(&wtrans, CREATE, BOOKMARKS, parent_id_, "Pete.htm");
ASSERT_TRUE(child.good());
child.Put(syncable::ID, child_id_);
child.Put(syncable::BASE_VERSION, 10);
@@ -2227,7 +2230,7 @@ TEST_F(SyncerTest, CommitsUpdateDoesntAlterEntry) {
int64 entry_metahandle;
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
- MutableEntry entry(&wtrans, syncable::CREATE, root_id_, "Pete");
+ MutableEntry entry(&wtrans, CREATE, BOOKMARKS, root_id_, "Pete");
ASSERT_TRUE(entry.good());
EXPECT_FALSE(entry.Get(ID).ServerKnows());
entry.Put(syncable::IS_DIR, true);
@@ -2273,7 +2276,7 @@ TEST_F(SyncerTest, ParentAndChildBothMatch) {
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
- MutableEntry parent(&wtrans, CREATE, root_id_, "Folder");
+ MutableEntry parent(&wtrans, CREATE, BOOKMARKS, root_id_, "Folder");
ASSERT_TRUE(parent.good());
parent.Put(IS_DIR, true);
parent.Put(IS_UNSYNCED, true);
@@ -2281,7 +2284,7 @@ TEST_F(SyncerTest, ParentAndChildBothMatch) {
parent.Put(BASE_VERSION, 1);
parent.Put(SPECIFICS, DefaultBookmarkSpecifics());
- MutableEntry child(&wtrans, CREATE, parent.Get(ID), "test.htm");
+ MutableEntry child(&wtrans, CREATE, BOOKMARKS, parent.Get(ID), "test.htm");
ASSERT_TRUE(child.good());
child.Put(ID, child_id);
child.Put(BASE_VERSION, 1);
@@ -2314,7 +2317,7 @@ TEST_F(SyncerTest, ParentAndChildBothMatch) {
TEST_F(SyncerTest, CommittingNewDeleted) {
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry entry(&trans, CREATE, trans.root_id(), "bob");
+ MutableEntry entry(&trans, CREATE, BOOKMARKS, trans.root_id(), "bob");
entry.Put(IS_UNSYNCED, true);
entry.Put(IS_DEL, true);
}
@@ -2335,7 +2338,7 @@ TEST_F(SyncerTest, UnappliedUpdateDuringCommit) {
// This test is a little fake.
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry entry(&trans, CREATE, trans.root_id(), "bob");
+ MutableEntry entry(&trans, CREATE, BOOKMARKS, trans.root_id(), "bob");
entry.Put(ID, ids_.FromNumber(20));
entry.Put(BASE_VERSION, 1);
entry.Put(SERVER_VERSION, 1);
@@ -2367,7 +2370,7 @@ TEST_F(SyncerTest, DeletingEntryInFolder) {
int64 existing_metahandle;
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry entry(&trans, CREATE, trans.root_id(), "existing");
+ MutableEntry entry(&trans, CREATE, BOOKMARKS, trans.root_id(), "existing");
ASSERT_TRUE(entry.good());
entry.Put(IS_DIR, true);
entry.Put(SPECIFICS, DefaultBookmarkSpecifics());
@@ -2377,7 +2380,7 @@ TEST_F(SyncerTest, DeletingEntryInFolder) {
syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END);
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry newfolder(&trans, CREATE, trans.root_id(), "new");
+ MutableEntry newfolder(&trans, CREATE, BOOKMARKS, trans.root_id(), "new");
ASSERT_TRUE(newfolder.good());
newfolder.Put(IS_DIR, true);
newfolder.Put(SPECIFICS, DefaultBookmarkSpecifics());
@@ -2403,7 +2406,8 @@ TEST_F(SyncerTest, DeletingEntryWithLocalEdits) {
SyncShareNudge();
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry newfolder(&trans, CREATE, ids_.FromNumber(1), "local");
+ MutableEntry newfolder(
+ &trans, CREATE, BOOKMARKS, ids_.FromNumber(1), "local");
ASSERT_TRUE(newfolder.good());
newfolder.Put(IS_UNSYNCED, true);
newfolder.Put(IS_DIR, true);
@@ -2494,7 +2498,7 @@ TEST_F(SyncerTest, CommitManyItemsInOneGo_Success) {
for (uint32 i = 0; i < items_to_commit; i++) {
string nameutf8 = base::StringPrintf("%d", i);
string name(nameutf8.begin(), nameutf8.end());
- MutableEntry e(&trans, CREATE, trans.root_id(), name);
+ MutableEntry e(&trans, CREATE, BOOKMARKS, trans.root_id(), name);
e.Put(IS_UNSYNCED, true);
e.Put(IS_DIR, true);
e.Put(SPECIFICS, DefaultBookmarkSpecifics());
@@ -2517,7 +2521,7 @@ TEST_F(SyncerTest, CommitManyItemsInOneGo_PostBufferFail) {
for (uint32 i = 0; i < items_to_commit; i++) {
string nameutf8 = base::StringPrintf("%d", i);
string name(nameutf8.begin(), nameutf8.end());
- MutableEntry e(&trans, CREATE, trans.root_id(), name);
+ MutableEntry e(&trans, CREATE, BOOKMARKS, trans.root_id(), name);
e.Put(IS_UNSYNCED, true);
e.Put(IS_DIR, true);
e.Put(SPECIFICS, DefaultBookmarkSpecifics());
@@ -2547,7 +2551,7 @@ TEST_F(SyncerTest, CommitManyItemsInOneGo_CommitConflict) {
for (uint32 i = 0; i < items_to_commit; i++) {
string nameutf8 = base::StringPrintf("%d", i);
string name(nameutf8.begin(), nameutf8.end());
- MutableEntry e(&trans, CREATE, trans.root_id(), name);
+ MutableEntry e(&trans, CREATE, BOOKMARKS, trans.root_id(), name);
e.Put(IS_UNSYNCED, true);
e.Put(IS_DIR, true);
e.Put(SPECIFICS, DefaultBookmarkSpecifics());
@@ -2645,7 +2649,8 @@ TEST_F(SyncerTest, NewEntryAndAlteredServerEntrySharePath) {
syncable::Id local_folder_id;
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
- MutableEntry new_entry(&wtrans, CREATE, wtrans.root_id(), "Bar.htm");
+ MutableEntry new_entry(
+ &wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "Bar.htm");
ASSERT_TRUE(new_entry.good());
local_folder_id = new_entry.Get(ID);
local_folder_handle = new_entry.Get(META_HANDLE);
@@ -2711,7 +2716,8 @@ TEST_F(SyncerTest, NewEntryAndAlteredServerEntrySharePath_OldBookmarksProto) {
syncable::Id local_folder_id;
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
- MutableEntry new_entry(&wtrans, CREATE, wtrans.root_id(), "Bar.htm");
+ MutableEntry new_entry(
+ &wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "Bar.htm");
ASSERT_TRUE(new_entry.good());
local_folder_id = new_entry.Get(ID);
local_folder_handle = new_entry.Get(META_HANDLE);
@@ -2883,12 +2889,12 @@ TEST_F(SyncerTest, ResolveWeWroteTheyDeleted) {
TEST_F(SyncerTest, DuplicateIDReturn) {
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry folder(&trans, CREATE, trans.root_id(), "bob");
+ MutableEntry folder(&trans, CREATE, BOOKMARKS, trans.root_id(), "bob");
ASSERT_TRUE(folder.good());
folder.Put(IS_UNSYNCED, true);
folder.Put(IS_DIR, true);
folder.Put(SPECIFICS, DefaultBookmarkSpecifics());
- MutableEntry folder2(&trans, CREATE, trans.root_id(), "fred");
+ MutableEntry folder2(&trans, CREATE, BOOKMARKS, trans.root_id(), "fred");
ASSERT_TRUE(folder2.good());
folder2.Put(IS_UNSYNCED, false);
folder2.Put(IS_DIR, true);
@@ -2927,7 +2933,8 @@ TEST_F(SyncerTest, ConflictResolverMergesLocalDeleteAndServerUpdate) {
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry local_deleted(&trans, CREATE, trans.root_id(), "name");
+ MutableEntry local_deleted(
+ &trans, CREATE, BOOKMARKS, trans.root_id(), "name");
local_deleted.Put(ID, ids_.FromNumber(1));
local_deleted.Put(BASE_VERSION, 1);
local_deleted.Put(IS_DEL, true);
@@ -2960,7 +2967,8 @@ TEST_F(SyncerTest, UpdateFlipsTheFolderBit) {
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry local_deleted(&trans, CREATE, trans.root_id(), "name");
+ MutableEntry local_deleted(
+ &trans, CREATE, BOOKMARKS, trans.root_id(), "name");
local_deleted.Put(ID, ids_.FromNumber(1));
local_deleted.Put(BASE_VERSION, 1);
local_deleted.Put(IS_DEL, true);
@@ -2998,7 +3006,8 @@ TEST_F(SyncerTest, MergingExistingItems) {
SyncShareNudge();
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry entry(&trans, CREATE, trans.root_id(), "Copy of base");
+ MutableEntry entry(
+ &trans, CREATE, BOOKMARKS, trans.root_id(), "Copy of base");
WriteTestDataToEntry(&trans, &entry);
}
mock_server_->AddUpdateBookmark(1, 0, "Copy of base", 50, 50);
@@ -3188,7 +3197,7 @@ TEST_F(SyncerTest, DirectoryCommitTest) {
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
- MutableEntry parent(&wtrans, syncable::CREATE, root_id_, "foo");
+ MutableEntry parent(&wtrans, CREATE, BOOKMARKS, root_id_, "foo");
ASSERT_TRUE(parent.good());
parent.Put(syncable::IS_UNSYNCED, true);
parent.Put(syncable::IS_DIR, true);
@@ -3196,7 +3205,7 @@ TEST_F(SyncerTest, DirectoryCommitTest) {
in_root_id = parent.Get(syncable::ID);
foo_metahandle = parent.Get(META_HANDLE);
- MutableEntry child(&wtrans, syncable::CREATE, parent.Get(ID), "bar");
+ MutableEntry child(&wtrans, CREATE, BOOKMARKS, parent.Get(ID), "bar");
ASSERT_TRUE(child.good());
child.Put(syncable::IS_UNSYNCED, true);
child.Put(syncable::IS_DIR, true);
@@ -3308,7 +3317,8 @@ TEST_F(SyncerTest, EnsureWeSendUpOldParent) {
entry.Put(PARENT_ID, folder_two_id);
entry.Put(IS_UNSYNCED, true);
// A new entry should send no "old parent."
- MutableEntry create(&trans, CREATE, trans.root_id(), "new_folder");
+ MutableEntry create(
+ &trans, CREATE, BOOKMARKS, trans.root_id(), "new_folder");
create.Put(IS_UNSYNCED, true);
create.Put(SPECIFICS, DefaultBookmarkSpecifics());
}
@@ -3328,7 +3338,7 @@ TEST_F(SyncerTest, Test64BitVersionSupport) {
// Try writing max int64 to the version fields of a meta entry.
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
- MutableEntry entry(&wtrans, syncable::CREATE, wtrans.root_id(), name);
+ MutableEntry entry(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), name);
ASSERT_TRUE(entry.good());
entry.Put(syncable::BASE_VERSION, really_big_int);
entry.Put(syncable::SERVER_VERSION, really_big_int);
@@ -3539,7 +3549,8 @@ TEST_F(SyncerTest, ClientTagUncommittedTagMatchesUpdate) {
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry perm_folder(&trans, CREATE, ids_.root(), "clientname");
+ MutableEntry perm_folder(
+ &trans, CREATE, BOOKMARKS, ids_.root(), "clientname");
ASSERT_TRUE(perm_folder.good());
perm_folder.Put(UNIQUE_CLIENT_TAG, "clientperm");
perm_folder.Put(SPECIFICS, local_bookmark);
@@ -3604,7 +3615,8 @@ TEST_F(SyncerTest, ClientTagConflictWithDeletedLocalEntry) {
{
// Create a deleted local entry with a unique client tag.
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry perm_folder(&trans, CREATE, ids_.root(), "clientname");
+ MutableEntry perm_folder(
+ &trans, CREATE, BOOKMARKS, ids_.root(), "clientname");
ASSERT_TRUE(perm_folder.good());
ASSERT_FALSE(perm_folder.Get(ID).ServerKnows());
perm_folder.Put(UNIQUE_CLIENT_TAG, "clientperm");
@@ -4066,7 +4078,8 @@ class SyncerUndeletionTest : public SyncerTest {
void Create() {
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry perm_folder(&trans, CREATE, ids_.root(), "clientname");
+ MutableEntry perm_folder(
+ &trans, CREATE, BOOKMARKS, ids_.root(), "clientname");
ASSERT_TRUE(perm_folder.good());
perm_folder.Put(UNIQUE_CLIENT_TAG, client_tag_);
perm_folder.Put(IS_UNSYNCED, true);
diff --git a/sync/internal_api/public/test/test_entry_factory.h b/sync/internal_api/public/test/test_entry_factory.h
index 071a501..7ca79e6 100644
--- a/sync/internal_api/public/test/test_entry_factory.h
+++ b/sync/internal_api/public/test/test_entry_factory.h
@@ -29,15 +29,21 @@ class TestEntryFactory {
const sync_pb::EntitySpecifics& specifics,
const std::string& parent_id);
+ int64 CreateUnappliedNewBookmarkItemWithParent(
+ const std::string& item_id,
+ const sync_pb::EntitySpecifics& specifics,
+ const std::string& parent_id);
+
// Create a new unapplied update without a parent.
int64 CreateUnappliedNewItem(const std::string& item_id,
const sync_pb::EntitySpecifics& specifics,
bool is_unique);
- // Create an unsynced item in the database. If item_id is a local ID, it will
- // be treated as a create-new. Otherwise, if it's a server ID, we'll fake the
- // server data so that it looks like it exists on the server. Returns the
- // methandle of the created item in |metahandle_out| if not NULL.
+ // Create an unsynced unique_client_tag item in the database. If item_id is a
+ // local ID, it will be treated as a create-new. Otherwise, if it's a server
+ // ID, we'll fake the server data so that it looks like it exists on the
+ // server. Returns the methandle of the created item in |metahandle_out| if
+ // not NULL.
void CreateUnsyncedItem(const syncable::Id& item_id,
const syncable::Id& parent_id,
const std::string& name,
@@ -45,14 +51,13 @@ class TestEntryFactory {
ModelType model_type,
int64* metahandle_out);
- // Creates an item that is both unsynced an an unapplied update. Returns the
- // metahandle of the created item.
- int64 CreateUnappliedAndUnsyncedItem(const std::string& name,
- ModelType model_type);
+ // Creates a bookmark that is both unsynced an an unapplied update. Returns
+ // the metahandle of the created item.
+ int64 CreateUnappliedAndUnsyncedBookmarkItem(const std::string& name);
- // Creates an item that has neither IS_UNSYNED or IS_UNAPPLIED_UPDATE. The
- // item is known to both the server and client. Returns the metahandle of
- // the created item.
+ // Creates a unique_client_tag item that has neither IS_UNSYNED or
+ // IS_UNAPPLIED_UPDATE. The item is known to both the server and client.
+ // Returns the metahandle of the created item.
int64 CreateSyncedItem(const std::string& name,
ModelType model_type, bool is_folder);
diff --git a/sync/internal_api/public/write_node.h b/sync/internal_api/public/write_node.h
index 73baa6f..990f040 100644
--- a/sync/internal_api/public/write_node.h
+++ b/sync/internal_api/public/write_node.h
@@ -67,15 +67,12 @@ class SYNC_EXPORT WriteNode : public BaseNode {
ModelType model_type,
const std::string& tag) OVERRIDE;
- // Create a new node with the specified parent and predecessor. |model_type|
- // dictates the type of the item, and controls which EntitySpecifics proto
- // extension can be used with this item. Use a NULL |predecessor|
- // to indicate that this is to be the first child.
+ // Create a new bookmark node with the specified parent and predecessor. Use
+ // a NULL |predecessor| to indicate that this is to be the first child.
// |predecessor| must be a child of |new_parent| or NULL. Returns false on
// failure.
- bool InitByCreation(ModelType model_type,
- const BaseNode& parent,
- const BaseNode* predecessor);
+ bool InitBookmarkByCreation(const BaseNode& parent,
+ const BaseNode* predecessor);
// Create nodes using this function if they're unique items that
// you want to fetch using client_tag. Note that the behavior of these
@@ -183,9 +180,6 @@ class SYNC_EXPORT WriteNode : public BaseNode {
void* operator new(size_t size); // Node is meant for stack use only.
- // Helper to set model type. This will clear any specifics data.
- void PutModelType(ModelType model_type);
-
// Helper to set the previous node.
bool PutPredecessor(const BaseNode* predecessor) WARN_UNUSED_RESULT;
diff --git a/sync/internal_api/sync_encryption_handler_impl_unittest.cc b/sync/internal_api/sync_encryption_handler_impl_unittest.cc
index 6e0b757..a650c14 100644
--- a/sync/internal_api/sync_encryption_handler_impl_unittest.cc
+++ b/sync/internal_api/sync_encryption_handler_impl_unittest.cc
@@ -103,6 +103,7 @@ class SyncEncryptionHandlerImplTest : public ::testing::Test {
syncable::WriteTransaction wtrans(FROM_HERE, syncable::UNITTEST, directory);
syncable::MutableEntry node(&wtrans,
syncable::CREATE,
+ model_type,
wtrans.root_id(),
tag_name);
node.Put(syncable::UNIQUE_SERVER_TAG, tag_name);
diff --git a/sync/internal_api/sync_manager_impl_unittest.cc b/sync/internal_api/sync_manager_impl_unittest.cc
index fd981f1..aed4432 100644
--- a/sync/internal_api/sync_manager_impl_unittest.cc
+++ b/sync/internal_api/sync_manager_impl_unittest.cc
@@ -130,35 +130,29 @@ int64 MakeNode(UserShare* share,
return node.GetId();
}
-// Makes a non-folder child of a non-root node. Returns the id of the
+// Makes a folder child of a non-root node. Returns the id of the
// newly-created node.
-int64 MakeNodeWithParent(UserShare* share,
- ModelType model_type,
- const std::string& client_tag,
- int64 parent_id) {
+int64 MakeFolderWithParent(UserShare* share,
+ ModelType model_type,
+ int64 parent_id,
+ BaseNode* predecessor) {
WriteTransaction trans(FROM_HERE, share);
ReadNode parent_node(&trans);
EXPECT_EQ(BaseNode::INIT_OK, parent_node.InitByIdLookup(parent_id));
WriteNode node(&trans);
- WriteNode::InitUniqueByCreationResult result =
- node.InitUniqueByCreation(model_type, parent_node, client_tag);
- EXPECT_EQ(WriteNode::INIT_SUCCESS, result);
- node.SetIsFolder(false);
+ EXPECT_TRUE(node.InitBookmarkByCreation(parent_node, predecessor));
+ node.SetIsFolder(true);
return node.GetId();
}
-// Makes a folder child of a non-root node. Returns the id of the
-// newly-created node.
-int64 MakeFolderWithParent(UserShare* share,
- ModelType model_type,
- int64 parent_id,
- BaseNode* predecessor) {
+int64 MakeBookmarkWithParent(UserShare* share,
+ int64 parent_id,
+ BaseNode* predecessor) {
WriteTransaction trans(FROM_HERE, share);
ReadNode parent_node(&trans);
EXPECT_EQ(BaseNode::INIT_OK, parent_node.InitByIdLookup(parent_id));
WriteNode node(&trans);
- EXPECT_TRUE(node.InitByCreation(model_type, parent_node, predecessor));
- node.SetIsFolder(true);
+ EXPECT_TRUE(node.InitBookmarkByCreation(parent_node, predecessor));
return node.GetId();
}
@@ -350,8 +344,7 @@ TEST_F(SyncApiTest, TestDeleteBehavior) {
// we'll use this spare folder later
WriteNode folder_node(&trans);
- EXPECT_TRUE(folder_node.InitByCreation(BOOKMARKS,
- root_node, NULL));
+ EXPECT_TRUE(folder_node.InitBookmarkByCreation(root_node, NULL));
folder_id = folder_node.GetId();
WriteNode wnode(&trans);
@@ -460,22 +453,21 @@ TEST_F(SyncApiTest, WriteEncryptedTitle) {
trans.GetCryptographer()->AddKey(params);
}
test_user_share_.encryption_handler()->EnableEncryptEverything();
+ int bookmark_id;
{
WriteTransaction trans(FROM_HERE, test_user_share_.user_share());
ReadNode root_node(&trans);
root_node.InitByRootLookup();
WriteNode bookmark_node(&trans);
- WriteNode::InitUniqueByCreationResult result =
- bookmark_node.InitUniqueByCreation(BOOKMARKS,
- root_node, "foo");
- EXPECT_EQ(WriteNode::INIT_SUCCESS, result);
+ ASSERT_TRUE(bookmark_node.InitBookmarkByCreation(root_node, NULL));
+ bookmark_id = bookmark_node.GetId();
bookmark_node.SetTitle(UTF8ToWide("foo"));
WriteNode pref_node(&trans);
- result =
+ WriteNode::InitUniqueByCreationResult result =
pref_node.InitUniqueByCreation(PREFERENCES, root_node, "bar");
- EXPECT_EQ(WriteNode::INIT_SUCCESS, result);
+ ASSERT_EQ(WriteNode::INIT_SUCCESS, result);
pref_node.SetTitle(UTF8ToWide("bar"));
}
{
@@ -484,15 +476,13 @@ TEST_F(SyncApiTest, WriteEncryptedTitle) {
root_node.InitByRootLookup();
ReadNode bookmark_node(&trans);
- EXPECT_EQ(BaseNode::INIT_OK,
- bookmark_node.InitByClientTagLookup(BOOKMARKS,
- "foo"));
+ ASSERT_EQ(BaseNode::INIT_OK, bookmark_node.InitByIdLookup(bookmark_id));
EXPECT_EQ("foo", bookmark_node.GetTitle());
EXPECT_EQ(kEncryptedString,
bookmark_node.GetEntry()->Get(syncable::NON_UNIQUE_NAME));
ReadNode pref_node(&trans);
- EXPECT_EQ(BaseNode::INIT_OK,
+ ASSERT_EQ(BaseNode::INIT_OK,
pref_node.InitByClientTagLookup(PREFERENCES,
"bar"));
EXPECT_EQ(kEncryptedString, pref_node.GetTitle());
@@ -672,16 +662,14 @@ TEST_F(SyncApiTest, GetTotalNodeCountMultipleChildren) {
BOOKMARKS,
parent,
NULL);
- ignore_result(MakeNodeWithParent(
+ ignore_result(MakeBookmarkWithParent(
test_user_share_.user_share(),
- BOOKMARKS,
- "c2",
- parent));
- ignore_result(MakeNodeWithParent(
+ parent,
+ NULL));
+ ignore_result(MakeBookmarkWithParent(
test_user_share_.user_share(),
- BOOKMARKS,
- "c1c1",
- child1));
+ child1,
+ NULL));
{
ReadTransaction trans(FROM_HERE, test_user_share_.user_share());
@@ -1540,20 +1528,17 @@ TEST_F(SyncManagerTest, EncryptDataTypesWithData) {
// First batch_size nodes are children of folder.
size_t i;
for (i = 0; i < batch_size; ++i) {
- MakeNodeWithParent(sync_manager_.GetUserShare(), BOOKMARKS,
- base::StringPrintf("%"PRIuS"", i), folder);
+ MakeBookmarkWithParent(sync_manager_.GetUserShare(), folder, NULL);
}
// Next batch_size nodes are a different type and on their own.
for (; i < 2*batch_size; ++i) {
- MakeNodeWithParent(sync_manager_.GetUserShare(), SESSIONS,
- base::StringPrintf("%"PRIuS"", i),
- GetIdForDataType(SESSIONS));
+ MakeNode(sync_manager_.GetUserShare(), SESSIONS,
+ base::StringPrintf("%"PRIuS"", i));
}
// Last batch_size nodes are a third type that will not need encryption.
for (; i < 3*batch_size; ++i) {
- MakeNodeWithParent(sync_manager_.GetUserShare(), THEMES,
- base::StringPrintf("%"PRIuS"", i),
- GetIdForDataType(THEMES));
+ MakeNode(sync_manager_.GetUserShare(), THEMES,
+ base::StringPrintf("%"PRIuS"", i));
}
{
@@ -2150,10 +2135,11 @@ TEST_F(SyncManagerTest, CreateLocalBookmark) {
std::string url = "url";
{
WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
- ReadNode root_node(&trans);
- root_node.InitByRootLookup();
+ ReadNode bookmark_root(&trans);
+ ASSERT_EQ(BaseNode::INIT_OK,
+ bookmark_root.InitByTagLookup(ModelTypeToRootTag(BOOKMARKS)));
WriteNode node(&trans);
- ASSERT_TRUE(node.InitByCreation(BOOKMARKS, root_node, NULL));
+ ASSERT_TRUE(node.InitBookmarkByCreation(bookmark_root, NULL));
node.SetIsFolder(false);
node.SetTitle(UTF8ToWide(title));
@@ -2163,9 +2149,10 @@ TEST_F(SyncManagerTest, CreateLocalBookmark) {
}
{
ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
- ReadNode root_node(&trans);
- root_node.InitByRootLookup();
- int64 child_id = root_node.GetFirstChildId();
+ ReadNode bookmark_root(&trans);
+ ASSERT_EQ(BaseNode::INIT_OK,
+ bookmark_root.InitByTagLookup(ModelTypeToRootTag(BOOKMARKS)));
+ int64 child_id = bookmark_root.GetFirstChildId();
ReadNode node(&trans);
ASSERT_EQ(BaseNode::INIT_OK, node.InitByIdLookup(child_id));
diff --git a/sync/internal_api/test/test_entry_factory.cc b/sync/internal_api/test/test_entry_factory.cc
index 8e6b2b3..e53c458 100644
--- a/sync/internal_api/test/test_entry_factory.cc
+++ b/sync/internal_api/test/test_entry_factory.cc
@@ -9,6 +9,7 @@
#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"
@@ -45,6 +46,25 @@ int64 TestEntryFactory::CreateUnappliedNewItemWithParent(
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,
@@ -73,11 +93,20 @@ void TestEntryFactory::CreateUnsyncedItem(
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;
- DCHECK(
- directory_->GetLastChildIdForTest(&trans, parent_id, &predecessor_id));
- MutableEntry entry(&trans, syncable::CREATE, parent_id, name);
+ if (model_type == BOOKMARKS) {
+ bool lookup_result = directory_->GetLastChildIdForTest(
+ &trans, parent_id, &predecessor_id);
+ DCHECK(lookup_result);
+ }
+
+ MutableEntry entry(&trans, syncable::CREATE, model_type, parent_id, name);
DCHECK(entry.good());
entry.Put(syncable::ID, item_id);
entry.Put(syncable::BASE_VERSION,
@@ -86,13 +115,19 @@ void TestEntryFactory::CreateUnsyncedItem(
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) {
+ bool put_result = entry.PutPredecessor(predecessor_id);
+ DCHECK(put_result);
+ }
+
if (item_id.ServerKnows()) {
entry.Put(syncable::SERVER_SPECIFICS, default_specifics);
- entry.Put(syncable::SERVER_IS_DIR, is_folder);
+ entry.Put(syncable::SERVER_IS_DIR, false);
entry.Put(syncable::SERVER_PARENT_ID, parent_id);
entry.Put(syncable::SERVER_IS_DEL, false);
}
@@ -100,13 +135,12 @@ void TestEntryFactory::CreateUnsyncedItem(
*metahandle_out = entry.Get(syncable::META_HANDLE);
}
-int64 TestEntryFactory::CreateUnappliedAndUnsyncedItem(
- const string& name,
- ModelType model_type) {
+int64 TestEntryFactory::CreateUnappliedAndUnsyncedBookmarkItem(
+ const string& name) {
int64 metahandle = 0;
CreateUnsyncedItem(
TestIdFactory::MakeServer(name), TestIdFactory::root(),
- name, false, model_type, &metahandle);
+ name, false, BOOKMARKS, &metahandle);
WriteTransaction trans(FROM_HERE, UNITTEST, directory_);
MutableEntry entry(&trans, syncable::GET_BY_HANDLE, metahandle);
@@ -129,10 +163,7 @@ int64 TestEntryFactory::CreateSyncedItem(
syncable::Id item_id(TestIdFactory::MakeServer(name));
int64 version = GetNextRevision();
- sync_pb::EntitySpecifics default_specifics;
- AddDefaultFieldValue(model_type, &default_specifics);
-
- MutableEntry entry(&trans, syncable::CREATE, parent_id, name);
+ MutableEntry entry(&trans, syncable::CREATE, model_type, parent_id, name);
if (!entry.good()) {
NOTREACHED();
return syncable::kInvalidMetaHandle;
@@ -146,20 +177,19 @@ int64 TestEntryFactory::CreateSyncedItem(
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, true);
- entry.Put(syncable::SERVER_NON_UNIQUE_NAME, "X");
- entry.Put(syncable::SERVER_PARENT_ID, TestIdFactory::MakeServer("Y"));
+ 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::SERVER_IS_DIR, is_folder);
entry.Put(syncable::SERVER_IS_DEL, false);
- entry.Put(syncable::SERVER_SPECIFICS, default_specifics);
- entry.Put(syncable::SERVER_PARENT_ID, parent_id);
+ entry.Put(syncable::SERVER_SPECIFICS, entry.Get(syncable::SPECIFICS));
return entry.Get(syncable::META_HANDLE);
}
diff --git a/sync/internal_api/write_node.cc b/sync/internal_api/write_node.cc
index 5628571..43d6e50 100644
--- a/sync/internal_api/write_node.cc
+++ b/sync/internal_api/write_node.cc
@@ -212,12 +212,7 @@ void WriteNode::SetEntitySpecifics(
DCHECK_NE(new_specifics_type, UNSPECIFIED);
DVLOG(1) << "Writing entity specifics of type "
<< ModelTypeToString(new_specifics_type);
- // GetModelType() can be unspecified if this is the first time this
- // node is being initialized (see PutModelType()). Otherwise, it
- // should match |new_specifics_type|.
- if (GetModelType() != UNSPECIFIED) {
- DCHECK_EQ(new_specifics_type, GetModelType());
- }
+ DCHECK_EQ(new_specifics_type, GetModelType());
// Preserve unknown fields.
const sync_pb::EntitySpecifics& old_specifics = entry_->Get(SPECIFICS);
@@ -327,22 +322,10 @@ BaseNode::InitByLookupResult WriteNode::InitByTagLookup(
return INIT_OK;
}
-void WriteNode::PutModelType(ModelType model_type) {
- // Set an empty specifics of the appropriate datatype. The presence
- // of the specific field will identify the model type.
- DCHECK(GetModelType() == model_type ||
- GetModelType() == UNSPECIFIED); // Immutable once set.
-
- sync_pb::EntitySpecifics specifics;
- AddDefaultFieldValue(model_type, &specifics);
- SetEntitySpecifics(specifics);
-}
-
// Create a new node with default properties, and bind this WriteNode to it.
// Return true on success.
-bool WriteNode::InitByCreation(ModelType model_type,
- const BaseNode& parent,
- const BaseNode* predecessor) {
+bool WriteNode::InitBookmarkByCreation(const BaseNode& parent,
+ const BaseNode* predecessor) {
DCHECK(!entry_) << "Init called twice";
// |predecessor| must be a child of |parent| or NULL.
if (predecessor && predecessor->GetParentId() != parent.GetId()) {
@@ -357,7 +340,8 @@ bool WriteNode::InitByCreation(ModelType model_type,
string dummy(kDefaultNameForNewNodes);
entry_ = new syncable::MutableEntry(transaction_->GetWrappedWriteTrans(),
- syncable::CREATE, parent_id, dummy);
+ syncable::CREATE, BOOKMARKS,
+ parent_id, dummy);
if (!entry_->good())
return false;
@@ -365,8 +349,6 @@ bool WriteNode::InitByCreation(ModelType model_type,
// Entries are untitled folders by default.
entry_->Put(syncable::IS_DIR, true);
- PutModelType(model_type);
-
// Now set the predecessor, which sets IS_UNSYNCED as necessary.
return PutPredecessor(predecessor);
}
@@ -434,7 +416,8 @@ WriteNode::InitUniqueByCreationResult WriteNode::InitUniqueByCreation(
}
} else {
entry_ = new syncable::MutableEntry(transaction_->GetWrappedWriteTrans(),
- syncable::CREATE, parent_id, dummy);
+ syncable::CREATE,
+ model_type, parent_id, dummy);
if (!entry_->good())
return INIT_FAILED_COULD_NOT_CREATE_ENTRY;
@@ -445,9 +428,6 @@ WriteNode::InitUniqueByCreationResult WriteNode::InitUniqueByCreation(
// We don't support directory and tag combinations.
entry_->Put(syncable::IS_DIR, false);
- // Will clear specifics data.
- PutModelType(model_type);
-
// Now set the predecessor, which sets IS_UNSYNCED as necessary.
bool success = PutPredecessor(NULL);
if (!success)
diff --git a/sync/syncable/mutable_entry.cc b/sync/syncable/mutable_entry.cc
index 64a23ce..2353128 100644
--- a/sync/syncable/mutable_entry.cc
+++ b/sync/syncable/mutable_entry.cc
@@ -19,15 +19,9 @@ using std::string;
namespace syncer {
namespace syncable {
-MutableEntry::MutableEntry(WriteTransaction* trans, Create,
- const Id& parent_id, const string& name)
- : Entry(trans),
- write_transaction_(trans) {
- Init(trans, parent_id, name);
-}
-
-
-void MutableEntry::Init(WriteTransaction* trans, const Id& parent_id,
+void MutableEntry::Init(WriteTransaction* trans,
+ ModelType model_type,
+ const Id& parent_id,
const string& name) {
scoped_ptr<EntryKernel> kernel(new EntryKernel);
kernel_ = NULL;
@@ -43,9 +37,15 @@ void MutableEntry::Init(WriteTransaction* trans, const Id& parent_id,
// We match the database defaults here
kernel->put(BASE_VERSION, CHANGES_VERSION);
kernel->put(SERVER_ORDINAL_IN_PARENT, NodeOrdinal::CreateInitialOrdinal());
- if (!trans->directory()->InsertEntry(trans, kernel.get())) {
- return; // We failed inserting, nothing more to do.
- }
+
+ // Normally the SPECIFICS setting code is wrapped in logic to deal with
+ // unknown fields and encryption. Since all we want to do here is ensure that
+ // GetModelType() returns a correct value from the very beginning, these
+ // few lines are sufficient.
+ sync_pb::EntitySpecifics specifics;
+ AddDefaultFieldValue(model_type, &specifics);
+ kernel->put(SPECIFICS, specifics);
+
// Because this entry is new, it was originally deleted.
kernel->put(IS_DEL, true);
trans->SaveOriginal(kernel.get());
@@ -55,6 +55,18 @@ void MutableEntry::Init(WriteTransaction* trans, const Id& parent_id,
kernel_ = kernel.release();
}
+MutableEntry::MutableEntry(WriteTransaction* trans,
+ Create,
+ ModelType model_type,
+ const Id& parent_id,
+ const string& name)
+ : Entry(trans),
+ write_transaction_(trans) {
+ Init(trans, model_type, parent_id, name);
+ bool insert_result = trans->directory()->InsertEntry(trans, kernel_);
+ DCHECK(insert_result);
+}
+
MutableEntry::MutableEntry(WriteTransaction* trans, CreateNewUpdateItem,
const Id& id)
: Entry(trans), write_transaction_(trans) {
diff --git a/sync/syncable/mutable_entry.h b/sync/syncable/mutable_entry.h
index cf7768a..51cd794 100644
--- a/sync/syncable/mutable_entry.h
+++ b/sync/syncable/mutable_entry.h
@@ -6,6 +6,7 @@
#define SYNC_SYNCABLE_MUTABLE_ENTRY_H_
#include "sync/base/sync_export.h"
+#include "sync/internal_api/public/base/model_type.h"
#include "sync/internal_api/public/base/node_ordinal.h"
#include "sync/syncable/entry.h"
#include "sync/syncable/metahandle_set.h"
@@ -28,12 +29,12 @@ enum CreateNewUpdateItem {
// A mutable meta entry. Changes get committed to the database when the
// WriteTransaction is destroyed.
class SYNC_EXPORT_PRIVATE MutableEntry : public Entry {
- void Init(WriteTransaction* trans, const Id& parent_id,
- const std::string& name);
+ void Init(WriteTransaction* trans, ModelType model_type,
+ const Id& parent_id, const std::string& name);
public:
- MutableEntry(WriteTransaction* trans, Create, const Id& parent_id,
- const std::string& name);
+ MutableEntry(WriteTransaction* trans, Create, ModelType model_type,
+ const Id& parent_id, const std::string& name);
MutableEntry(WriteTransaction* trans, CreateNewUpdateItem, const Id& id);
MutableEntry(WriteTransaction* trans, GetByHandle, int64);
MutableEntry(WriteTransaction* trans, GetById, const Id&);
diff --git a/sync/syncable/syncable_unittest.cc b/sync/syncable/syncable_unittest.cc
index 7c72ed4b..444e9e3 100644
--- a/sync/syncable/syncable_unittest.cc
+++ b/sync/syncable/syncable_unittest.cc
@@ -146,7 +146,7 @@ TEST_F(SyncableGeneralTest, General) {
// Test creating a new meta entry.
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, &dir);
- MutableEntry me(&wtrans, CREATE, wtrans.root_id(), name);
+ MutableEntry me(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), name);
ASSERT_TRUE(me.good());
me.Put(ID, id);
me.Put(BASE_VERSION, 1);
@@ -238,7 +238,7 @@ TEST_F(SyncableGeneralTest, ChildrenOps) {
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, &dir);
- MutableEntry me(&wtrans, CREATE, wtrans.root_id(), name);
+ MutableEntry me(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), name);
ASSERT_TRUE(me.good());
me.Put(ID, id);
me.Put(BASE_VERSION, 1);
@@ -300,7 +300,7 @@ TEST_F(SyncableGeneralTest, ClientIndexRebuildsProperly) {
NullTransactionObserver()));
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, &dir);
- MutableEntry me(&wtrans, CREATE, wtrans.root_id(), name);
+ MutableEntry me(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), name);
ASSERT_TRUE(me.good());
me.Put(ID, id);
me.Put(BASE_VERSION, 1);
@@ -346,7 +346,7 @@ TEST_F(SyncableGeneralTest, ClientIndexRebuildsDeletedProperly) {
NullTransactionObserver()));
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, &dir);
- MutableEntry me(&wtrans, CREATE, wtrans.root_id(), "deleted");
+ MutableEntry me(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "deleted");
ASSERT_TRUE(me.good());
me.Put(ID, id);
me.Put(BASE_VERSION, 1);
@@ -401,7 +401,7 @@ TEST_F(SyncableGeneralTest, ToValue) {
// Test creating a new meta entry.
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, &dir);
- MutableEntry me(&wtrans, CREATE, wtrans.root_id(), "new");
+ MutableEntry me(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "new");
ASSERT_TRUE(me.good());
me.Put(ID, id);
me.Put(BASE_VERSION, 1);
@@ -409,7 +409,7 @@ TEST_F(SyncableGeneralTest, ToValue) {
scoped_ptr<DictionaryValue> value(me.ToValue(NULL));
ExpectDictBooleanValue(true, *value, "good");
EXPECT_TRUE(value->HasKey("kernel"));
- ExpectDictStringValue("Unspecified", *value, "modelType");
+ ExpectDictStringValue("Bookmarks", *value, "modelType");
ExpectDictBooleanValue(true, *value, "existsOnClientBecauseNameIsNonEmpty");
ExpectDictBooleanValue(false, *value, "isRoot");
}
@@ -504,7 +504,7 @@ class SyncableDirectoryTest : public testing::Test {
}
void CreateEntry(const std::string& entryname, Id id) {
WriteTransaction wtrans(FROM_HERE, UNITTEST, dir_.get());
- MutableEntry me(&wtrans, CREATE, wtrans.root_id(), entryname);
+ MutableEntry me(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), entryname);
ASSERT_TRUE(me.good());
me.Put(ID, id);
me.Put(IS_UNSYNCED, true);
@@ -544,7 +544,7 @@ TEST_F(SyncableDirectoryTest, TakeSnapshotGetsMetahandlesToPurge) {
{
WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get());
for (int i = 0; i < metas_to_create; i++) {
- MutableEntry e(&trans, CREATE, trans.root_id(), "foo");
+ MutableEntry e(&trans, CREATE, BOOKMARKS, trans.root_id(), "foo");
e.Put(IS_UNSYNCED, true);
sync_pb::EntitySpecifics specs;
if (i % 2 == 0) {
@@ -585,7 +585,7 @@ TEST_F(SyncableDirectoryTest, TakeSnapshotGetsAllDirtyHandlesTest) {
{
WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get());
for (int i = 0; i < metahandles_to_create; i++) {
- MutableEntry e(&trans, CREATE, trans.root_id(), "foo");
+ MutableEntry e(&trans, CREATE, BOOKMARKS, trans.root_id(), "foo");
expected_dirty_metahandles.push_back(e.Get(META_HANDLE));
e.Put(IS_UNSYNCED, true);
}
@@ -616,7 +616,7 @@ TEST_F(SyncableDirectoryTest, TakeSnapshotGetsAllDirtyHandlesTest) {
e1.Put(IS_DIR, true);
e1.Put(IS_UNSYNCED, true);
// Add new entries
- MutableEntry e2(&trans, CREATE, trans.root_id(), "bar");
+ MutableEntry e2(&trans, CREATE, BOOKMARKS, trans.root_id(), "bar");
e2.Put(IS_UNSYNCED, true);
new_dirty_metahandles.push_back(e2.Get(META_HANDLE));
}
@@ -648,7 +648,7 @@ TEST_F(SyncableDirectoryTest, TakeSnapshotGetsOnlyDirtyHandlesTest) {
{
WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get());
for (int i = 0; i < metahandles_to_create; i++) {
- MutableEntry e(&trans, CREATE, trans.root_id(), "foo");
+ MutableEntry e(&trans, CREATE, BOOKMARKS, trans.root_id(), "foo");
expected_dirty_metahandles.push_back(e.Get(META_HANDLE));
e.Put(IS_UNSYNCED, true);
}
@@ -667,7 +667,7 @@ TEST_F(SyncableDirectoryTest, TakeSnapshotGetsOnlyDirtyHandlesTest) {
e1.Put(IS_DIR, true);
e1.Put(IS_UNSYNCED, true);
// Add new entries
- MutableEntry e2(&trans, CREATE, trans.root_id(), "bar");
+ MutableEntry e2(&trans, CREATE, BOOKMARKS, trans.root_id(), "bar");
e2.Put(IS_UNSYNCED, true);
new_dirty_metahandles.push_back(e2.Get(META_HANDLE));
}
@@ -871,13 +871,13 @@ TEST_F(SyncableDirectoryTest, TestBasicLookupValidID) {
TEST_F(SyncableDirectoryTest, TestDelete) {
std::string name = "peanut butter jelly time";
WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get());
- MutableEntry e1(&trans, CREATE, trans.root_id(), name);
+ MutableEntry e1(&trans, CREATE, BOOKMARKS, trans.root_id(), name);
ASSERT_TRUE(e1.good());
ASSERT_TRUE(e1.Put(IS_DEL, true));
- MutableEntry e2(&trans, CREATE, trans.root_id(), name);
+ MutableEntry e2(&trans, CREATE, BOOKMARKS, trans.root_id(), name);
ASSERT_TRUE(e2.good());
ASSERT_TRUE(e2.Put(IS_DEL, true));
- MutableEntry e3(&trans, CREATE, trans.root_id(), name);
+ MutableEntry e3(&trans, CREATE, BOOKMARKS, trans.root_id(), name);
ASSERT_TRUE(e3.good());
ASSERT_TRUE(e3.Put(IS_DEL, true));
@@ -899,14 +899,14 @@ TEST_F(SyncableDirectoryTest, TestGetUnsynced) {
dir_->GetUnsyncedMetaHandles(&trans, &handles);
ASSERT_TRUE(0 == handles.size());
- MutableEntry e1(&trans, CREATE, trans.root_id(), "abba");
+ MutableEntry e1(&trans, CREATE, BOOKMARKS, trans.root_id(), "abba");
ASSERT_TRUE(e1.good());
handle1 = e1.Get(META_HANDLE);
e1.Put(BASE_VERSION, 1);
e1.Put(IS_DIR, true);
e1.Put(ID, TestIdFactory::FromNumber(101));
- MutableEntry e2(&trans, CREATE, e1.Get(ID), "bread");
+ MutableEntry e2(&trans, CREATE, BOOKMARKS, e1.Get(ID), "bread");
ASSERT_TRUE(e2.good());
handle2 = e2.Get(META_HANDLE);
e2.Put(BASE_VERSION, 1);
@@ -971,7 +971,7 @@ TEST_F(SyncableDirectoryTest, TestGetUnappliedUpdates) {
dir_->GetUnappliedUpdateMetaHandles(&trans, all_types, &handles);
ASSERT_TRUE(0 == handles.size());
- MutableEntry e1(&trans, CREATE, trans.root_id(), "abba");
+ MutableEntry e1(&trans, CREATE, BOOKMARKS, trans.root_id(), "abba");
ASSERT_TRUE(e1.good());
handle1 = e1.Get(META_HANDLE);
e1.Put(IS_UNAPPLIED_UPDATE, false);
@@ -979,7 +979,7 @@ TEST_F(SyncableDirectoryTest, TestGetUnappliedUpdates) {
e1.Put(ID, TestIdFactory::FromNumber(101));
e1.Put(IS_DIR, true);
- MutableEntry e2(&trans, CREATE, e1.Get(ID), "bread");
+ MutableEntry e2(&trans, CREATE, BOOKMARKS, e1.Get(ID), "bread");
ASSERT_TRUE(e2.good());
handle2 = e2.Get(META_HANDLE);
e2.Put(IS_UNAPPLIED_UPDATE, false);
@@ -1040,22 +1040,22 @@ TEST_F(SyncableDirectoryTest, DeleteBug_531383) {
int64 grandchild_handle;
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, dir_.get());
- MutableEntry parent(&wtrans, CREATE, id_factory.root(), "Bob");
+ MutableEntry parent(&wtrans, CREATE, BOOKMARKS, id_factory.root(), "Bob");
ASSERT_TRUE(parent.good());
parent.Put(IS_DIR, true);
parent.Put(ID, id_factory.NewServerId());
parent.Put(BASE_VERSION, 1);
- MutableEntry child(&wtrans, CREATE, parent.Get(ID), "Bob");
+ MutableEntry child(&wtrans, CREATE, BOOKMARKS, parent.Get(ID), "Bob");
ASSERT_TRUE(child.good());
child.Put(IS_DIR, true);
child.Put(ID, id_factory.NewServerId());
child.Put(BASE_VERSION, 1);
- MutableEntry grandchild(&wtrans, CREATE, child.Get(ID), "Bob");
+ MutableEntry grandchild(&wtrans, CREATE, BOOKMARKS, child.Get(ID), "Bob");
ASSERT_TRUE(grandchild.good());
grandchild.Put(ID, id_factory.NewServerId());
grandchild.Put(BASE_VERSION, 1);
ASSERT_TRUE(grandchild.Put(IS_DEL, true));
- MutableEntry twin(&wtrans, CREATE, child.Get(ID), "Bob");
+ MutableEntry twin(&wtrans, CREATE, BOOKMARKS, child.Get(ID), "Bob");
ASSERT_TRUE(twin.good());
ASSERT_TRUE(twin.Put(IS_DEL, true));
ASSERT_TRUE(grandchild.Put(IS_DEL, false));
@@ -1079,32 +1079,32 @@ TEST_F(SyncableDirectoryTest, TestIsLegalNewParent) {
WriteTransaction wtrans(FROM_HERE, UNITTEST, dir_.get());
Entry root(&wtrans, GET_BY_ID, id_factory.root());
ASSERT_TRUE(root.good());
- MutableEntry parent(&wtrans, CREATE, root.Get(ID), "Bob");
+ MutableEntry parent(&wtrans, CREATE, BOOKMARKS, root.Get(ID), "Bob");
ASSERT_TRUE(parent.good());
parent.Put(IS_DIR, true);
parent.Put(ID, id_factory.NewServerId());
parent.Put(BASE_VERSION, 1);
- MutableEntry child(&wtrans, CREATE, parent.Get(ID), "Bob");
+ MutableEntry child(&wtrans, CREATE, BOOKMARKS, parent.Get(ID), "Bob");
ASSERT_TRUE(child.good());
child.Put(IS_DIR, true);
child.Put(ID, id_factory.NewServerId());
child.Put(BASE_VERSION, 1);
- MutableEntry grandchild(&wtrans, CREATE, child.Get(ID), "Bob");
+ MutableEntry grandchild(&wtrans, CREATE, BOOKMARKS, child.Get(ID), "Bob");
ASSERT_TRUE(grandchild.good());
grandchild.Put(ID, id_factory.NewServerId());
grandchild.Put(BASE_VERSION, 1);
- MutableEntry parent2(&wtrans, CREATE, root.Get(ID), "Pete");
+ MutableEntry parent2(&wtrans, CREATE, BOOKMARKS, root.Get(ID), "Pete");
ASSERT_TRUE(parent2.good());
parent2.Put(IS_DIR, true);
parent2.Put(ID, id_factory.NewServerId());
parent2.Put(BASE_VERSION, 1);
- MutableEntry child2(&wtrans, CREATE, parent2.Get(ID), "Pete");
+ MutableEntry child2(&wtrans, CREATE, BOOKMARKS, parent2.Get(ID), "Pete");
ASSERT_TRUE(child2.good());
child2.Put(IS_DIR, true);
child2.Put(ID, id_factory.NewServerId());
child2.Put(BASE_VERSION, 1);
- MutableEntry grandchild2(&wtrans, CREATE, child2.Get(ID), "Pete");
+ MutableEntry grandchild2(&wtrans, CREATE, BOOKMARKS, child2.Get(ID), "Pete");
ASSERT_TRUE(grandchild2.good());
grandchild2.Put(ID, id_factory.NewServerId());
grandchild2.Put(BASE_VERSION, 1);
@@ -1136,13 +1136,13 @@ TEST_F(SyncableDirectoryTest, TestEntryIsInFolder) {
{
WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get());
- MutableEntry folder(&trans, CREATE, trans.root_id(), "folder");
+ MutableEntry folder(&trans, CREATE, BOOKMARKS, trans.root_id(), "folder");
ASSERT_TRUE(folder.good());
EXPECT_TRUE(folder.Put(IS_DIR, true));
EXPECT_TRUE(folder.Put(IS_UNSYNCED, true));
folder_id = folder.Get(ID);
- MutableEntry entry(&trans, CREATE, folder.Get(ID), entry_name);
+ MutableEntry entry(&trans, CREATE, BOOKMARKS, folder.Get(ID), entry_name);
ASSERT_TRUE(entry.good());
entry_handle = entry.Get(META_HANDLE);
entry.Put(IS_UNSYNCED, true);
@@ -1167,15 +1167,15 @@ TEST_F(SyncableDirectoryTest, TestParentIdIndexUpdate) {
std::string child_name = "child";
WriteTransaction wt(FROM_HERE, UNITTEST, dir_.get());
- MutableEntry parent_folder(&wt, CREATE, wt.root_id(), "folder1");
+ MutableEntry parent_folder(&wt, CREATE, BOOKMARKS, wt.root_id(), "folder1");
parent_folder.Put(IS_UNSYNCED, true);
EXPECT_TRUE(parent_folder.Put(IS_DIR, true));
- MutableEntry parent_folder2(&wt, CREATE, wt.root_id(), "folder2");
+ MutableEntry parent_folder2(&wt, CREATE, BOOKMARKS, wt.root_id(), "folder2");
parent_folder2.Put(IS_UNSYNCED, true);
EXPECT_TRUE(parent_folder2.Put(IS_DIR, true));
- MutableEntry child(&wt, CREATE, parent_folder.Get(ID), child_name);
+ MutableEntry child(&wt, CREATE, BOOKMARKS, parent_folder.Get(ID), child_name);
EXPECT_TRUE(child.Put(IS_DIR, true));
child.Put(IS_UNSYNCED, true);
@@ -1196,7 +1196,7 @@ TEST_F(SyncableDirectoryTest, TestNoReindexDeletedItems) {
std::string new_name = "new_name";
WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get());
- MutableEntry folder(&trans, CREATE, trans.root_id(), folder_name);
+ MutableEntry folder(&trans, CREATE, BOOKMARKS, trans.root_id(), folder_name);
ASSERT_TRUE(folder.good());
ASSERT_TRUE(folder.Put(IS_DIR, true));
ASSERT_TRUE(folder.Put(IS_DEL, true));
@@ -1214,7 +1214,7 @@ TEST_F(SyncableDirectoryTest, TestNoReindexDeletedItems) {
TEST_F(SyncableDirectoryTest, TestCaseChangeRename) {
WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get());
- MutableEntry folder(&trans, CREATE, trans.root_id(), "CaseChange");
+ MutableEntry folder(&trans, CREATE, BOOKMARKS, trans.root_id(), "CaseChange");
ASSERT_TRUE(folder.good());
EXPECT_TRUE(folder.Put(PARENT_ID, trans.root_id()));
EXPECT_TRUE(folder.Put(NON_UNIQUE_NAME, "CASECHANGE"));
@@ -1240,7 +1240,7 @@ TEST_F(SyncableDirectoryTest, GetModelType) {
WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get());
- MutableEntry folder(&trans, CREATE, trans.root_id(), "Folder");
+ MutableEntry folder(&trans, CREATE, BOOKMARKS, trans.root_id(), "Folder");
ASSERT_TRUE(folder.good());
folder.Put(ID, id_factory.NewServerId());
folder.Put(SPECIFICS, specifics);
@@ -1249,7 +1249,7 @@ TEST_F(SyncableDirectoryTest, GetModelType) {
folder.Put(IS_DEL, false);
ASSERT_EQ(datatype, folder.GetModelType());
- MutableEntry item(&trans, CREATE, trans.root_id(), "Item");
+ MutableEntry item(&trans, CREATE, BOOKMARKS, trans.root_id(), "Item");
ASSERT_TRUE(item.good());
item.Put(ID, id_factory.NewServerId());
item.Put(SPECIFICS, specifics);
@@ -1260,7 +1260,8 @@ TEST_F(SyncableDirectoryTest, GetModelType) {
// It's critical that deletion records retain their datatype, so that
// they can be dispatched to the appropriate change processor.
- MutableEntry deleted_item(&trans, CREATE, trans.root_id(), "Deleted Item");
+ MutableEntry deleted_item(
+ &trans, CREATE, BOOKMARKS, trans.root_id(), "Deleted Item");
ASSERT_TRUE(item.good());
deleted_item.Put(ID, id_factory.NewServerId());
deleted_item.Put(SPECIFICS, specifics);
@@ -1315,11 +1316,11 @@ TEST_F(SyncableDirectoryTest, ChangeEntryIDAndUpdateChildren_ParentAndChild) {
// Create two client-side items, a parent and child.
WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get());
- MutableEntry parent(&trans, CREATE, id_factory.root(), "parent");
+ MutableEntry parent(&trans, CREATE, BOOKMARKS, id_factory.root(), "parent");
parent.Put(IS_DIR, true);
parent.Put(IS_UNSYNCED, true);
- MutableEntry child(&trans, CREATE, parent.Get(ID), "child");
+ MutableEntry child(&trans, CREATE, BOOKMARKS, parent.Get(ID), "child");
child.Put(IS_UNSYNCED, true);
orig_parent_id = parent.Get(ID);
@@ -1363,11 +1364,11 @@ TEST_F(SyncableDirectoryTest,
// Create two client-side items, a parent and child.
WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get());
- MutableEntry parent(&trans, CREATE, id_factory.root(), "parent");
+ MutableEntry parent(&trans, CREATE, BOOKMARKS, id_factory.root(), "parent");
parent.Put(IS_DIR, true);
parent.Put(IS_UNSYNCED, true);
- MutableEntry child(&trans, CREATE, parent.Get(ID), "child");
+ MutableEntry child(&trans, CREATE, BOOKMARKS, parent.Get(ID), "child");
child.Put(IS_UNSYNCED, true);
orig_parent_id = parent.Get(ID);
@@ -1446,7 +1447,7 @@ TEST_F(SyncableDirectoryTest, OldClientLeftUnsyncedDeletedLocalItem) {
WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get());
// Create an uncommitted tombstone entry.
- MutableEntry server_knows(&trans, CREATE, id_factory.root(),
+ MutableEntry server_knows(&trans, CREATE, BOOKMARKS, id_factory.root(),
"server_knows");
server_knows.Put(ID, server_knows_id);
server_knows.Put(IS_UNSYNCED, true);
@@ -1455,7 +1456,8 @@ TEST_F(SyncableDirectoryTest, OldClientLeftUnsyncedDeletedLocalItem) {
server_knows.Put(SERVER_VERSION, 4);
// Create a valid update entry.
- MutableEntry not_is_del(&trans, CREATE, id_factory.root(), "not_is_del");
+ MutableEntry not_is_del(
+ &trans, CREATE, BOOKMARKS, id_factory.root(), "not_is_del");
not_is_del.Put(ID, not_is_del_id);
not_is_del.Put(IS_DEL, false);
not_is_del.Put(IS_UNSYNCED, true);
@@ -1466,7 +1468,7 @@ TEST_F(SyncableDirectoryTest, OldClientLeftUnsyncedDeletedLocalItem) {
// New clients should never put entries into this state. We work around
// this by setting IS_DEL before setting IS_UNSYNCED, something which the
// client should never do in practice.
- MutableEntry zombie(&trans, CREATE, id_factory.root(), "zombie");
+ MutableEntry zombie(&trans, CREATE, BOOKMARKS, id_factory.root(), "zombie");
zombie.Put(ID, zombie_id);
zombie.Put(IS_DEL, true);
zombie.Put(IS_UNSYNCED, true);
@@ -1502,11 +1504,11 @@ TEST_F(SyncableDirectoryTest, OrdinalWithNullSurvivesSaveAndReload) {
{
WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get());
- MutableEntry parent(&trans, CREATE, id_factory.root(), "parent");
+ MutableEntry parent(&trans, CREATE, BOOKMARKS, id_factory.root(), "parent");
parent.Put(IS_DIR, true);
parent.Put(IS_UNSYNCED, true);
- MutableEntry child(&trans, CREATE, parent.Get(ID), "child");
+ MutableEntry child(&trans, CREATE, BOOKMARKS, parent.Get(ID), "child");
child.Put(IS_UNSYNCED, true);
child.Put(SERVER_ORDINAL_IN_PARENT, null_ord);
@@ -1690,9 +1692,8 @@ TEST_F(OnDiskSyncableDirectoryTest, TestPurgeEntriesWithTypeIn) {
// Add more nodes for this type. Technically, they should be placed under
// the proper type root nodes but the assertions in this test won't notice
// if their parent isn't quite right.
- MutableEntry item1(&trans, CREATE, trans.root_id(), "Item");
+ MutableEntry item1(&trans, CREATE, BOOKMARKS, trans.root_id(), "Item");
ASSERT_TRUE(item1.good());
- item1.Put(SPECIFICS, bookmark_specs);
item1.Put(SERVER_SPECIFICS, bookmark_specs);
item1.Put(IS_UNSYNCED, true);
@@ -1702,7 +1703,8 @@ TEST_F(OnDiskSyncableDirectoryTest, TestPurgeEntriesWithTypeIn) {
item2.Put(SERVER_SPECIFICS, bookmark_specs);
item2.Put(IS_UNAPPLIED_UPDATE, true);
- MutableEntry item3(&trans, CREATE, trans.root_id(), "Item");
+ MutableEntry item3(&trans, CREATE, PREFERENCES,
+ trans.root_id(), "Item");
ASSERT_TRUE(item3.good());
item3.Put(SPECIFICS, preference_specs);
item3.Put(SERVER_SPECIFICS, preference_specs);
@@ -1714,7 +1716,8 @@ TEST_F(OnDiskSyncableDirectoryTest, TestPurgeEntriesWithTypeIn) {
item4.Put(SERVER_SPECIFICS, preference_specs);
item4.Put(IS_UNAPPLIED_UPDATE, true);
- MutableEntry item5(&trans, CREATE, trans.root_id(), "Item");
+ MutableEntry item5(&trans, CREATE, AUTOFILL,
+ trans.root_id(), "Item");
ASSERT_TRUE(item5.good());
item5.Put(SPECIFICS, autofill_specs);
item5.Put(SERVER_SPECIFICS, autofill_specs);
@@ -1791,7 +1794,8 @@ TEST_F(OnDiskSyncableDirectoryTest,
{
WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get());
- MutableEntry create(&trans, CREATE, trans.root_id(), create_name);
+ MutableEntry create(
+ &trans, CREATE, BOOKMARKS, trans.root_id(), create_name);
MutableEntry update(&trans, CREATE_NEW_UPDATE_ITEM, update_id);
create.Put(IS_UNSYNCED, true);
update.Put(IS_UNAPPLIED_UPDATE, true);
@@ -1891,7 +1895,7 @@ TEST_F(OnDiskSyncableDirectoryTest, TestSaveChangesFailure) {
{
WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get());
- MutableEntry e1(&trans, CREATE, trans.root_id(), "aguilera");
+ MutableEntry e1(&trans, CREATE, BOOKMARKS, trans.root_id(), "aguilera");
ASSERT_TRUE(e1.good());
EXPECT_TRUE(e1.GetKernelCopy().is_dirty());
handle1 = e1.Get(META_HANDLE);
@@ -1937,7 +1941,8 @@ TEST_F(OnDiskSyncableDirectoryTest, TestSaveChangesFailure) {
EXPECT_TRUE(IsInDirtyMetahandles(handle1));
// New item.
- MutableEntry kids_on_block(&trans, CREATE, trans.root_id(), "kids");
+ MutableEntry kids_on_block(
+ &trans, CREATE, BOOKMARKS, trans.root_id(), "kids");
ASSERT_TRUE(kids_on_block.good());
handle2 = kids_on_block.Get(META_HANDLE);
kids_on_block.Put(BASE_VERSION, 1);
@@ -1972,7 +1977,7 @@ TEST_F(OnDiskSyncableDirectoryTest, TestSaveChangesFailureWithPurge) {
{
WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get());
- MutableEntry e1(&trans, CREATE, trans.root_id(), "aguilera");
+ MutableEntry e1(&trans, CREATE, BOOKMARKS, trans.root_id(), "aguilera");
ASSERT_TRUE(e1.good());
EXPECT_TRUE(e1.GetKernelCopy().is_dirty());
handle1 = e1.Get(META_HANDLE);
@@ -2116,7 +2121,7 @@ class StressTransactionsDelegate : public base::PlatformThread::Delegate {
base::StringPrintf("%d.%d", thread_number_, entry_count++);
path_name.assign(unique_name.begin(), unique_name.end());
WriteTransaction trans(FROM_HERE, UNITTEST, dir_);
- MutableEntry e(&trans, CREATE, trans.root_id(), path_name);
+ MutableEntry e(&trans, CREATE, BOOKMARKS, trans.root_id(), path_name);
CHECK(e.good());
base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(
rand() % 20));
@@ -2173,13 +2178,9 @@ class SyncableClientTagTest : public SyncableDirectoryTest {
SyncableClientTagTest() : test_name_("test_name"), test_tag_("dietcoke") {}
bool CreateWithDefaultTag(Id id, bool deleted) {
- return CreateWithTag(test_tag_, id, deleted);
- }
-
- // Attempt to create an entry with a default tag.
- bool CreateWithTag(const char* tag, Id id, bool deleted) {
WriteTransaction wtrans(FROM_HERE, UNITTEST, dir_.get());
- MutableEntry me(&wtrans, CREATE, wtrans.root_id(), test_name_);
+ MutableEntry me(&wtrans, CREATE, PREFERENCES,
+ wtrans.root_id(), test_name_);
CHECK(me.good());
me.Put(ID, id);
if (id.ServerKnows()) {
@@ -2188,7 +2189,7 @@ class SyncableClientTagTest : public SyncableDirectoryTest {
me.Put(IS_UNSYNCED, true);
me.Put(IS_DEL, deleted);
me.Put(IS_DIR, false);
- return me.Put(UNIQUE_CLIENT_TAG, tag);
+ return me.Put(UNIQUE_CLIENT_TAG, test_tag_);
}
// Verify an entry exists with the default tag.
diff --git a/sync/test/engine/test_syncable_utils.cc b/sync/test/engine/test_syncable_utils.cc
index 77be4c3..389a16a 100644
--- a/sync/test/engine/test_syncable_utils.cc
+++ b/sync/test/engine/test_syncable_utils.cc
@@ -71,6 +71,7 @@ void CreateTypeRoot(WriteTransaction* trans,
std::string tag_name = syncer::ModelTypeToRootTag(type);
syncable::MutableEntry node(trans,
syncable::CREATE,
+ type,
TestIdFactory::root(),
tag_name);
DCHECK(node.good());