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

Side by Side Diff: chrome/browser/sync/profile_sync_service_bookmark_unittest.cc

Issue 10696087: [Sync] Move ModelType and related classes to 'syncer' namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sort headers, update copyrights Created 8 years, 5 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 <stack> 9 #include <stack>
10 #include <vector> 10 #include <vector>
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 error_handler, 60 error_handler,
61 true /* expect_mobile_bookmarks_folder */), 61 true /* expect_mobile_bookmarks_folder */),
62 user_share_(user_share) {} 62 user_share_(user_share) {}
63 63
64 // TODO(akalin): This logic lazily creates any tagged node that is 64 // TODO(akalin): This logic lazily creates any tagged node that is
65 // requested. A better way would be to have utility functions to 65 // requested. A better way would be to have utility functions to
66 // create sync nodes from some bookmark structure and to use that. 66 // create sync nodes from some bookmark structure and to use that.
67 virtual bool GetSyncIdForTaggedNode(const std::string& tag, int64* sync_id) { 67 virtual bool GetSyncIdForTaggedNode(const std::string& tag, int64* sync_id) {
68 std::string tag_str = std::string(tag.c_str(), tag.length()); 68 std::string tag_str = std::string(tag.c_str(), tag.length());
69 bool root_exists = false; 69 bool root_exists = false;
70 syncable::ModelType type = model_type(); 70 syncer::ModelType type = model_type();
71 { 71 {
72 syncer::WriteTransaction trans(FROM_HERE, user_share_); 72 syncer::WriteTransaction trans(FROM_HERE, user_share_);
73 syncer::ReadNode uber_root(&trans); 73 syncer::ReadNode uber_root(&trans);
74 uber_root.InitByRootLookup(); 74 uber_root.InitByRootLookup();
75 75
76 syncer::ReadNode root(&trans); 76 syncer::ReadNode root(&trans);
77 root_exists = root.InitByTagLookup( 77 root_exists = root.InitByTagLookup(
78 ProfileSyncServiceTestHelper::GetTagForType(type)) == 78 ProfileSyncServiceTestHelper::GetTagForType(type)) ==
79 BaseNode::INIT_OK; 79 BaseNode::INIT_OK;
80 } 80 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 // Pretend that the server told the syncer to add a bookmark object. 148 // Pretend that the server told the syncer to add a bookmark object.
149 int64 Add(const std::wstring& title, 149 int64 Add(const std::wstring& title,
150 const std::string& url, 150 const std::string& url,
151 bool is_folder, 151 bool is_folder,
152 int64 parent_id, 152 int64 parent_id,
153 int64 predecessor_id) { 153 int64 predecessor_id) {
154 syncer::ReadNode parent(trans_); 154 syncer::ReadNode parent(trans_);
155 EXPECT_EQ(BaseNode::INIT_OK, parent.InitByIdLookup(parent_id)); 155 EXPECT_EQ(BaseNode::INIT_OK, parent.InitByIdLookup(parent_id));
156 syncer::WriteNode node(trans_); 156 syncer::WriteNode node(trans_);
157 if (predecessor_id == 0) { 157 if (predecessor_id == 0) {
158 EXPECT_TRUE(node.InitByCreation(syncable::BOOKMARKS, parent, NULL)); 158 EXPECT_TRUE(node.InitByCreation(syncer::BOOKMARKS, parent, NULL));
159 } else { 159 } else {
160 syncer::ReadNode predecessor(trans_); 160 syncer::ReadNode predecessor(trans_);
161 EXPECT_EQ(BaseNode::INIT_OK, predecessor.InitByIdLookup(predecessor_id)); 161 EXPECT_EQ(BaseNode::INIT_OK, predecessor.InitByIdLookup(predecessor_id));
162 EXPECT_EQ(predecessor.GetParentId(), parent.GetId()); 162 EXPECT_EQ(predecessor.GetParentId(), parent.GetId());
163 EXPECT_TRUE(node.InitByCreation(syncable::BOOKMARKS, parent, 163 EXPECT_TRUE(node.InitByCreation(syncer::BOOKMARKS, parent,
164 &predecessor)); 164 &predecessor));
165 } 165 }
166 EXPECT_EQ(node.GetPredecessorId(), predecessor_id); 166 EXPECT_EQ(node.GetPredecessorId(), predecessor_id);
167 EXPECT_EQ(node.GetParentId(), parent_id); 167 EXPECT_EQ(node.GetParentId(), parent_id);
168 node.SetIsFolder(is_folder); 168 node.SetIsFolder(is_folder);
169 node.SetTitle(title); 169 node.SetTitle(title);
170 if (!is_folder) 170 if (!is_folder)
171 node.SetURL(GURL(url)); 171 node.SetURL(GURL(url));
172 syncer::ChangeRecord record; 172 syncer::ChangeRecord record;
173 record.action = syncer::ChangeRecord::ACTION_ADD; 173 record.action = syncer::ChangeRecord::ACTION_ADD;
(...skipping 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after
1491 EXPECT_EQ(1, observer.get_started()); 1491 EXPECT_EQ(1, observer.get_started());
1492 EXPECT_EQ(0, observer.get_completed_count_at_started()); 1492 EXPECT_EQ(0, observer.get_completed_count_at_started());
1493 EXPECT_EQ(1, observer.get_completed()); 1493 EXPECT_EQ(1, observer.get_completed());
1494 1494
1495 model_->RemoveObserver(&observer); 1495 model_->RemoveObserver(&observer);
1496 } 1496 }
1497 1497
1498 } // namespace 1498 } // namespace
1499 1499
1500 } // namespace browser_sync 1500 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service_autofill_unittest.cc ('k') | chrome/browser/sync/profile_sync_service_harness.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698