OLD | NEW |
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 Loading... |
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.InitByCreation(syncer::BOOKMARKS, parent, NULL)); | 84 EXPECT_TRUE(node.InitBookmarkByCreation(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.InitByCreation(syncer::BOOKMARKS, parent, | 89 EXPECT_TRUE(node.InitBookmarkByCreation(parent, &predecessor)); |
90 &predecessor)); | |
91 } | 90 } |
92 EXPECT_EQ(node.GetPredecessorId(), predecessor_id); | 91 EXPECT_EQ(node.GetPredecessorId(), predecessor_id); |
93 EXPECT_EQ(node.GetParentId(), parent_id); | 92 EXPECT_EQ(node.GetParentId(), parent_id); |
94 node.SetIsFolder(is_folder); | 93 node.SetIsFolder(is_folder); |
95 node.SetTitle(title); | 94 node.SetTitle(title); |
96 if (!is_folder) { | 95 if (!is_folder) { |
97 sync_pb::BookmarkSpecifics specifics(node.GetBookmarkSpecifics()); | 96 sync_pb::BookmarkSpecifics specifics(node.GetBookmarkSpecifics()); |
98 specifics.set_url(url); | 97 specifics.set_url(url); |
99 node.SetBookmarkSpecifics(specifics); | 98 node.SetBookmarkSpecifics(specifics); |
100 } | 99 } |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 // If it doesn't exist, create the permanent node at the end of the | 353 // If it doesn't exist, create the permanent node at the end of the |
355 // ordering. | 354 // ordering. |
356 syncer::ReadNode predecessor_node(&trans); | 355 syncer::ReadNode predecessor_node(&trans); |
357 syncer::ReadNode* predecessor = NULL; | 356 syncer::ReadNode* predecessor = NULL; |
358 if (last_child_id != syncer::kInvalidId) { | 357 if (last_child_id != syncer::kInvalidId) { |
359 EXPECT_EQ(BaseNode::INIT_OK, | 358 EXPECT_EQ(BaseNode::INIT_OK, |
360 predecessor_node.InitByIdLookup(last_child_id)); | 359 predecessor_node.InitByIdLookup(last_child_id)); |
361 predecessor = &predecessor_node; | 360 predecessor = &predecessor_node; |
362 } | 361 } |
363 syncer::WriteNode node(&trans); | 362 syncer::WriteNode node(&trans); |
364 if (!node.InitByCreation(type, root, predecessor)) | 363 if (!node.InitBookmarkByCreation(root, predecessor)) |
365 return false; | 364 return false; |
366 node.SetIsFolder(true); | 365 node.SetIsFolder(true); |
367 node.GetMutableEntryForTest()->Put( | 366 node.GetMutableEntryForTest()->Put( |
368 syncer::syncable::UNIQUE_SERVER_TAG, permanent_tags[i]); | 367 syncer::syncable::UNIQUE_SERVER_TAG, permanent_tags[i]); |
369 node.SetTitle(UTF8ToWide(permanent_tags[i])); | 368 node.SetTitle(UTF8ToWide(permanent_tags[i])); |
370 node.SetExternalId(0); | 369 node.SetExternalId(0); |
371 last_child_id = node.GetId(); | 370 last_child_id = node.GetId(); |
372 } | 371 } |
373 return true; | 372 return true; |
374 } | 373 } |
(...skipping 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1746 new_versions[changed_bookmark->id()]); | 1745 new_versions[changed_bookmark->id()]); |
1747 initial_versions.erase(changed_bookmark->id()); | 1746 initial_versions.erase(changed_bookmark->id()); |
1748 ExpectTransactionVersionMatch(model_->bookmark_bar_node(), initial_versions); | 1747 ExpectTransactionVersionMatch(model_->bookmark_bar_node(), initial_versions); |
1749 ExpectTransactionVersionMatch(model_->other_node(), initial_versions); | 1748 ExpectTransactionVersionMatch(model_->other_node(), initial_versions); |
1750 ExpectTransactionVersionMatch(model_->mobile_node(), initial_versions); | 1749 ExpectTransactionVersionMatch(model_->mobile_node(), initial_versions); |
1751 } | 1750 } |
1752 | 1751 |
1753 } // namespace | 1752 } // namespace |
1754 | 1753 |
1755 } // namespace browser_sync | 1754 } // namespace browser_sync |
OLD | NEW |