diff options
author | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-12 19:25:25 +0000 |
---|---|---|
committer | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-12 19:25:25 +0000 |
commit | 47b0ab7c912b4b884c6876c2b6c05c6e8e53a9e1 (patch) | |
tree | 5add5e881a6c742a134d0880f0657f1502ad8db9 /sync/engine/apply_updates_and_resolve_conflicts_command_unittest.cc | |
parent | f8621b0f6d9652721f012fe68595be02f644ac00 (diff) | |
download | chromium_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
Diffstat (limited to 'sync/engine/apply_updates_and_resolve_conflicts_command_unittest.cc')
-rw-r--r-- | sync/engine/apply_updates_and_resolve_conflicts_command_unittest.cc | 29 |
1 files changed, 13 insertions, 16 deletions
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); |