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

Side by Side Diff: chrome/browser/sync/profile_sync_service_bookmark_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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // TODO(akalin): This file is basically just a unit test for 5 // TODO(akalin): This file is basically just a unit test for
6 // BookmarkChangeProcessor. Write unit tests for 6 // BookmarkChangeProcessor. Write unit tests for
7 // BookmarkModelAssociator separately. 7 // BookmarkModelAssociator separately.
8 8
9 #include <map> 9 #include <map>
10 #include <queue> 10 #include <queue>
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 // Pretend that the server told the syncer to add a bookmark object. 74 // Pretend that the server told the syncer to add a bookmark object.
75 int64 Add(const std::wstring& title, 75 int64 Add(const std::wstring& title,
76 const std::string& url, 76 const std::string& url,
77 bool is_folder, 77 bool is_folder,
78 int64 parent_id, 78 int64 parent_id,
79 int64 predecessor_id) { 79 int64 predecessor_id) {
80 syncer::ReadNode parent(trans_); 80 syncer::ReadNode parent(trans_);
81 EXPECT_EQ(BaseNode::INIT_OK, parent.InitByIdLookup(parent_id)); 81 EXPECT_EQ(BaseNode::INIT_OK, parent.InitByIdLookup(parent_id));
82 syncer::WriteNode node(trans_); 82 syncer::WriteNode node(trans_);
83 if (predecessor_id == 0) { 83 if (predecessor_id == 0) {
84 EXPECT_TRUE(node.InitBookmarkByCreation(parent, NULL)); 84 EXPECT_TRUE(node.InitByCreation(syncer::BOOKMARKS, parent, NULL));
85 } else { 85 } else {
86 syncer::ReadNode predecessor(trans_); 86 syncer::ReadNode predecessor(trans_);
87 EXPECT_EQ(BaseNode::INIT_OK, predecessor.InitByIdLookup(predecessor_id)); 87 EXPECT_EQ(BaseNode::INIT_OK, predecessor.InitByIdLookup(predecessor_id));
88 EXPECT_EQ(predecessor.GetParentId(), parent.GetId()); 88 EXPECT_EQ(predecessor.GetParentId(), parent.GetId());
89 EXPECT_TRUE(node.InitBookmarkByCreation(parent, &predecessor)); 89 EXPECT_TRUE(node.InitByCreation(syncer::BOOKMARKS, parent,
90 &predecessor));
90 } 91 }
91 EXPECT_EQ(node.GetPredecessorId(), predecessor_id); 92 EXPECT_EQ(node.GetPredecessorId(), predecessor_id);
92 EXPECT_EQ(node.GetParentId(), parent_id); 93 EXPECT_EQ(node.GetParentId(), parent_id);
93 node.SetIsFolder(is_folder); 94 node.SetIsFolder(is_folder);
94 node.SetTitle(title); 95 node.SetTitle(title);
95 if (!is_folder) { 96 if (!is_folder) {
96 sync_pb::BookmarkSpecifics specifics(node.GetBookmarkSpecifics()); 97 sync_pb::BookmarkSpecifics specifics(node.GetBookmarkSpecifics());
97 specifics.set_url(url); 98 specifics.set_url(url);
98 node.SetBookmarkSpecifics(specifics); 99 node.SetBookmarkSpecifics(specifics);
99 } 100 }
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 // If it doesn't exist, create the permanent node at the end of the 354 // If it doesn't exist, create the permanent node at the end of the
354 // ordering. 355 // ordering.
355 syncer::ReadNode predecessor_node(&trans); 356 syncer::ReadNode predecessor_node(&trans);
356 syncer::ReadNode* predecessor = NULL; 357 syncer::ReadNode* predecessor = NULL;
357 if (last_child_id != syncer::kInvalidId) { 358 if (last_child_id != syncer::kInvalidId) {
358 EXPECT_EQ(BaseNode::INIT_OK, 359 EXPECT_EQ(BaseNode::INIT_OK,
359 predecessor_node.InitByIdLookup(last_child_id)); 360 predecessor_node.InitByIdLookup(last_child_id));
360 predecessor = &predecessor_node; 361 predecessor = &predecessor_node;
361 } 362 }
362 syncer::WriteNode node(&trans); 363 syncer::WriteNode node(&trans);
363 if (!node.InitBookmarkByCreation(root, predecessor)) 364 if (!node.InitByCreation(type, root, predecessor))
364 return false; 365 return false;
365 node.SetIsFolder(true); 366 node.SetIsFolder(true);
366 node.GetMutableEntryForTest()->Put( 367 node.GetMutableEntryForTest()->Put(
367 syncer::syncable::UNIQUE_SERVER_TAG, permanent_tags[i]); 368 syncer::syncable::UNIQUE_SERVER_TAG, permanent_tags[i]);
368 node.SetTitle(UTF8ToWide(permanent_tags[i])); 369 node.SetTitle(UTF8ToWide(permanent_tags[i]));
369 node.SetExternalId(0); 370 node.SetExternalId(0);
370 last_child_id = node.GetId(); 371 last_child_id = node.GetId();
371 } 372 }
372 return true; 373 return true;
373 } 374 }
(...skipping 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1745 new_versions[changed_bookmark->id()]); 1746 new_versions[changed_bookmark->id()]);
1746 initial_versions.erase(changed_bookmark->id()); 1747 initial_versions.erase(changed_bookmark->id());
1747 ExpectTransactionVersionMatch(model_->bookmark_bar_node(), initial_versions); 1748 ExpectTransactionVersionMatch(model_->bookmark_bar_node(), initial_versions);
1748 ExpectTransactionVersionMatch(model_->other_node(), initial_versions); 1749 ExpectTransactionVersionMatch(model_->other_node(), initial_versions);
1749 ExpectTransactionVersionMatch(model_->mobile_node(), initial_versions); 1750 ExpectTransactionVersionMatch(model_->mobile_node(), initial_versions);
1750 } 1751 }
1751 1752
1752 } // namespace 1753 } // namespace
1753 1754
1754 } // namespace browser_sync 1755 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698