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

Unified Diff: sync/internal_api/sync_manager_impl_unittest.cc

Issue 11863011: Revert 176340 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sync/internal_api/sync_manager_impl_unittest.cc
===================================================================
--- sync/internal_api/sync_manager_impl_unittest.cc (revision 176351)
+++ sync/internal_api/sync_manager_impl_unittest.cc (working copy)
@@ -130,6 +130,23 @@
return node.GetId();
}
+// Makes a non-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) {
+ 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);
+ return node.GetId();
+}
+
// Makes a folder child of a non-root node. Returns the id of the
// newly-created node.
int64 MakeFolderWithParent(UserShare* share,
@@ -138,24 +155,13 @@
BaseNode* predecessor) {
WriteTransaction trans(FROM_HERE, share);
ReadNode parent_node(&trans);
- DCHECK_EQ(BaseNode::INIT_OK, parent_node.InitByIdLookup(parent_id));
+ EXPECT_EQ(BaseNode::INIT_OK, parent_node.InitByIdLookup(parent_id));
WriteNode node(&trans);
- DCHECK(node.InitBookmarkByCreation(parent_node, predecessor));
+ EXPECT_TRUE(node.InitByCreation(model_type, parent_node, predecessor));
node.SetIsFolder(true);
return node.GetId();
}
-int64 MakeBookmarkWithParent(UserShare* share,
- int64 parent_id,
- BaseNode* predecessor) {
- WriteTransaction trans(FROM_HERE, share);
- ReadNode parent_node(&trans);
- DCHECK_EQ(BaseNode::INIT_OK, parent_node.InitByIdLookup(parent_id));
- WriteNode node(&trans);
- DCHECK(node.InitBookmarkByCreation(parent_node, predecessor));
- return node.GetId();
-}
-
// Creates the "synced" root node for a particular datatype. We use the syncable
// methods here so that the syncer treats these nodes as if they were already
// received from the server.
@@ -344,7 +350,8 @@
// we'll use this spare folder later
WriteNode folder_node(&trans);
- EXPECT_TRUE(folder_node.InitBookmarkByCreation(root_node, NULL));
+ EXPECT_TRUE(folder_node.InitByCreation(BOOKMARKS,
+ root_node, NULL));
folder_id = folder_node.GetId();
WriteNode wnode(&trans);
@@ -453,21 +460,22 @@
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);
- ASSERT_TRUE(bookmark_node.InitBookmarkByCreation(root_node, NULL));
- bookmark_id = bookmark_node.GetId();
+ WriteNode::InitUniqueByCreationResult result =
+ bookmark_node.InitUniqueByCreation(BOOKMARKS,
+ root_node, "foo");
+ EXPECT_EQ(WriteNode::INIT_SUCCESS, result);
bookmark_node.SetTitle(UTF8ToWide("foo"));
WriteNode pref_node(&trans);
- WriteNode::InitUniqueByCreationResult result =
+ result =
pref_node.InitUniqueByCreation(PREFERENCES, root_node, "bar");
- ASSERT_EQ(WriteNode::INIT_SUCCESS, result);
+ EXPECT_EQ(WriteNode::INIT_SUCCESS, result);
pref_node.SetTitle(UTF8ToWide("bar"));
}
{
@@ -476,13 +484,15 @@
root_node.InitByRootLookup();
ReadNode bookmark_node(&trans);
- ASSERT_EQ(BaseNode::INIT_OK, bookmark_node.InitByIdLookup(bookmark_id));
+ EXPECT_EQ(BaseNode::INIT_OK,
+ bookmark_node.InitByClientTagLookup(BOOKMARKS,
+ "foo"));
EXPECT_EQ("foo", bookmark_node.GetTitle());
EXPECT_EQ(kEncryptedString,
bookmark_node.GetEntry()->Get(syncable::NON_UNIQUE_NAME));
ReadNode pref_node(&trans);
- ASSERT_EQ(BaseNode::INIT_OK,
+ EXPECT_EQ(BaseNode::INIT_OK,
pref_node.InitByClientTagLookup(PREFERENCES,
"bar"));
EXPECT_EQ(kEncryptedString, pref_node.GetTitle());
@@ -662,14 +672,16 @@
BOOKMARKS,
parent,
NULL);
- ignore_result(MakeBookmarkWithParent(
+ ignore_result(MakeNodeWithParent(
test_user_share_.user_share(),
- parent,
- NULL));
- ignore_result(MakeBookmarkWithParent(
+ BOOKMARKS,
+ "c2",
+ parent));
+ ignore_result(MakeNodeWithParent(
test_user_share_.user_share(),
- child1,
- NULL));
+ BOOKMARKS,
+ "c1c1",
+ child1));
{
ReadTransaction trans(FROM_HERE, test_user_share_.user_share());
@@ -1528,17 +1540,20 @@
// First batch_size nodes are children of folder.
size_t i;
for (i = 0; i < batch_size; ++i) {
- MakeBookmarkWithParent(sync_manager_.GetUserShare(), folder, NULL);
+ MakeNodeWithParent(sync_manager_.GetUserShare(), BOOKMARKS,
+ base::StringPrintf("%"PRIuS"", i), folder);
}
// Next batch_size nodes are a different type and on their own.
for (; i < 2*batch_size; ++i) {
- MakeNode(sync_manager_.GetUserShare(), SESSIONS,
- base::StringPrintf("%"PRIuS"", i));
+ MakeNodeWithParent(sync_manager_.GetUserShare(), SESSIONS,
+ base::StringPrintf("%"PRIuS"", i),
+ GetIdForDataType(SESSIONS));
}
// Last batch_size nodes are a third type that will not need encryption.
for (; i < 3*batch_size; ++i) {
- MakeNode(sync_manager_.GetUserShare(), THEMES,
- base::StringPrintf("%"PRIuS"", i));
+ MakeNodeWithParent(sync_manager_.GetUserShare(), THEMES,
+ base::StringPrintf("%"PRIuS"", i),
+ GetIdForDataType(THEMES));
}
{
@@ -2135,11 +2150,10 @@
std::string url = "url";
{
WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
- ReadNode bookmark_root(&trans);
- ASSERT_EQ(BaseNode::INIT_OK,
- bookmark_root.InitByTagLookup(ModelTypeToRootTag(BOOKMARKS)));
+ ReadNode root_node(&trans);
+ root_node.InitByRootLookup();
WriteNode node(&trans);
- ASSERT_TRUE(node.InitBookmarkByCreation(bookmark_root, NULL));
+ ASSERT_TRUE(node.InitByCreation(BOOKMARKS, root_node, NULL));
node.SetIsFolder(false);
node.SetTitle(UTF8ToWide(title));
@@ -2149,10 +2163,9 @@
}
{
ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
- ReadNode bookmark_root(&trans);
- ASSERT_EQ(BaseNode::INIT_OK,
- bookmark_root.InitByTagLookup(ModelTypeToRootTag(BOOKMARKS)));
- int64 child_id = bookmark_root.GetFirstChildId();
+ ReadNode root_node(&trans);
+ root_node.InitByRootLookup();
+ int64 child_id = root_node.GetFirstChildId();
ReadNode node(&trans);
ASSERT_EQ(BaseNode::INIT_OK, node.InitByIdLookup(child_id));
« no previous file with comments | « sync/internal_api/sync_encryption_handler_impl_unittest.cc ('k') | sync/internal_api/test/test_entry_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698