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

Side by Side Diff: components/browser_sync/browser/profile_sync_service_bookmark_unittest.cc

Issue 1714073002: Format profile_sync_service_bookmark_unittest.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@586642_move_files_bookmarks
Patch Set: Just rebased Created 4 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 9 #include <stddef.h>
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 } 94 }
95 95
96 // FakeServerChange constructs a list of syncer::ChangeRecords while modifying 96 // FakeServerChange constructs a list of syncer::ChangeRecords while modifying
97 // the sync model, and can pass the ChangeRecord list to a 97 // the sync model, and can pass the ChangeRecord list to a
98 // syncer::SyncObserver (i.e., the ProfileSyncService) to test the client 98 // syncer::SyncObserver (i.e., the ProfileSyncService) to test the client
99 // change-application behavior. 99 // change-application behavior.
100 // Tests using FakeServerChange should be careful to avoid back-references, 100 // Tests using FakeServerChange should be careful to avoid back-references,
101 // since FakeServerChange will send the edits in the order specified. 101 // since FakeServerChange will send the edits in the order specified.
102 class FakeServerChange { 102 class FakeServerChange {
103 public: 103 public:
104 explicit FakeServerChange(syncer::WriteTransaction* trans) : trans_(trans) { 104 explicit FakeServerChange(syncer::WriteTransaction* trans) : trans_(trans) {}
105 }
106 105
107 // Pretend that the server told the syncer to add a bookmark object. 106 // Pretend that the server told the syncer to add a bookmark object.
108 int64_t AddWithMetaInfo(const std::string& title, 107 int64_t AddWithMetaInfo(const std::string& title,
109 const std::string& url, 108 const std::string& url,
110 const BookmarkNode::MetaInfoMap* meta_info_map, 109 const BookmarkNode::MetaInfoMap* meta_info_map,
111 bool is_folder, 110 bool is_folder,
112 int64_t parent_id, 111 int64_t parent_id,
113 int64_t predecessor_id) { 112 int64_t predecessor_id) {
114 syncer::ReadNode parent(trans_); 113 syncer::ReadNode parent(trans_);
115 EXPECT_EQ(BaseNode::INIT_OK, parent.InitByIdLookup(parent_id)); 114 EXPECT_EQ(BaseNode::INIT_OK, parent.InitByIdLookup(parent_id));
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 node.SetBookmarkSpecifics(specifics); 260 node.SetBookmarkSpecifics(specifics);
262 SetModified(id); 261 SetModified(id);
263 } 262 }
264 263
265 // Pass the fake change list to |service|. 264 // Pass the fake change list to |service|.
266 void ApplyPendingChanges(sync_driver::ChangeProcessor* processor) { 265 void ApplyPendingChanges(sync_driver::ChangeProcessor* processor) {
267 processor->ApplyChangesFromSyncModel( 266 processor->ApplyChangesFromSyncModel(
268 trans_, 0, syncer::ImmutableChangeRecordList(&changes_)); 267 trans_, 0, syncer::ImmutableChangeRecordList(&changes_));
269 } 268 }
270 269
271 const syncer::ChangeRecordList& changes() { 270 const syncer::ChangeRecordList& changes() { return changes_; }
272 return changes_;
273 }
274 271
275 private: 272 private:
276 // Helper function to push an ACTION_UPDATE record onto the back 273 // Helper function to push an ACTION_UPDATE record onto the back
277 // of the changelist. 274 // of the changelist.
278 void SetModified(int64_t id) { 275 void SetModified(int64_t id) {
279 // Coalesce multi-property edits. 276 // Coalesce multi-property edits.
280 if (!changes_.empty() && changes_.back().id == id && 277 if (!changes_.empty() && changes_.back().id == id &&
281 changes_.back().action == 278 changes_.back().action == syncer::ChangeRecord::ACTION_UPDATE)
282 syncer::ChangeRecord::ACTION_UPDATE)
283 return; 279 return;
284 syncer::ChangeRecord record; 280 syncer::ChangeRecord record;
285 record.action = syncer::ChangeRecord::ACTION_UPDATE; 281 record.action = syncer::ChangeRecord::ACTION_UPDATE;
286 record.id = id; 282 record.id = id;
287 changes_.push_back(record); 283 changes_.push_back(record);
288 } 284 }
289 285
290 void SetNodeMetaInfo(const BookmarkNode::MetaInfoMap& meta_info_map, 286 void SetNodeMetaInfo(const BookmarkNode::MetaInfoMap& meta_info_map,
291 sync_pb::BookmarkSpecifics* specifics) { 287 sync_pb::BookmarkSpecifics* specifics) {
292 specifics->clear_meta_info(); 288 specifics->clear_meta_info();
293 // Deliberatly set MetaInfoMap entries in opposite order (compared 289 // Deliberatly set MetaInfoMap entries in opposite order (compared
294 // to the implementation in BookmarkChangeProcessor) to ensure that 290 // to the implementation in BookmarkChangeProcessor) to ensure that
295 // (a) the implementation isn't sensitive to the order and 291 // (a) the implementation isn't sensitive to the order and
296 // (b) the original meta info isn't blindly overwritten by 292 // (b) the original meta info isn't blindly overwritten by
297 // BookmarkChangeProcessor unless there is a real change. 293 // BookmarkChangeProcessor unless there is a real change.
298 BookmarkNode::MetaInfoMap::const_iterator it = meta_info_map.end(); 294 BookmarkNode::MetaInfoMap::const_iterator it = meta_info_map.end();
299 while (it != meta_info_map.begin()) { 295 while (it != meta_info_map.begin()) {
300 --it; 296 --it;
301 sync_pb::MetaInfo* meta_info = specifics->add_meta_info(); 297 sync_pb::MetaInfo* meta_info = specifics->add_meta_info();
302 meta_info->set_key(it->first); 298 meta_info->set_key(it->first);
303 meta_info->set_value(it->second); 299 meta_info->set_value(it->second);
304 } 300 }
305 } 301 }
306 302
307 // The transaction on which everything happens. 303 // The transaction on which everything happens.
308 syncer::WriteTransaction *trans_; 304 syncer::WriteTransaction* trans_;
309 305
310 // The change list we construct. 306 // The change list we construct.
311 syncer::ChangeRecordList changes_; 307 syncer::ChangeRecordList changes_;
312 DISALLOW_COPY_AND_ASSIGN(FakeServerChange); 308 DISALLOW_COPY_AND_ASSIGN(FakeServerChange);
313 }; 309 };
314 310
315 class ExtensiveChangesBookmarkModelObserver 311 class ExtensiveChangesBookmarkModelObserver
316 : public bookmarks::BaseBookmarkModelObserver { 312 : public bookmarks::BaseBookmarkModelObserver {
317 public: 313 public:
318 ExtensiveChangesBookmarkModelObserver() 314 ExtensiveChangesBookmarkModelObserver()
319 : started_count_(0), 315 : started_count_(0),
320 completed_count_at_started_(0), 316 completed_count_at_started_(0),
321 completed_count_(0) {} 317 completed_count_(0) {}
322 318
323 void ExtensiveBookmarkChangesBeginning(BookmarkModel* model) override { 319 void ExtensiveBookmarkChangesBeginning(BookmarkModel* model) override {
324 ++started_count_; 320 ++started_count_;
325 completed_count_at_started_ = completed_count_; 321 completed_count_at_started_ = completed_count_;
326 } 322 }
327 323
328 void ExtensiveBookmarkChangesEnded(BookmarkModel* model) override { 324 void ExtensiveBookmarkChangesEnded(BookmarkModel* model) override {
329 ++completed_count_; 325 ++completed_count_;
330 } 326 }
331 327
332 void BookmarkModelChanged() override {} 328 void BookmarkModelChanged() override {}
333 329
334 int get_started() const { 330 int get_started() const { return started_count_; }
335 return started_count_;
336 }
337 331
338 int get_completed_count_at_started() const { 332 int get_completed_count_at_started() const {
339 return completed_count_at_started_; 333 return completed_count_at_started_;
340 } 334 }
341 335
342 int get_completed() const { 336 int get_completed() const { return completed_count_; }
343 return completed_count_;
344 }
345 337
346 private: 338 private:
347 int started_count_; 339 int started_count_;
348 int completed_count_at_started_; 340 int completed_count_at_started_;
349 int completed_count_; 341 int completed_count_;
350 342
351 DISALLOW_COPY_AND_ASSIGN(ExtensiveChangesBookmarkModelObserver); 343 DISALLOW_COPY_AND_ASSIGN(ExtensiveChangesBookmarkModelObserver);
352 }; 344 };
353 345
354 class ProfileSyncServiceBookmarkTest : public testing::Test { 346 class ProfileSyncServiceBookmarkTest : public testing::Test {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 return 0; 476 return 0;
485 return node.GetTotalNodeCount(); 477 return node.GetTotalNodeCount();
486 } 478 }
487 479
488 // Creates the bookmark root node and the permanent nodes if they don't 480 // Creates the bookmark root node and the permanent nodes if they don't
489 // already exist. 481 // already exist.
490 bool CreatePermanentBookmarkNodes() { 482 bool CreatePermanentBookmarkNodes() {
491 bool root_exists = false; 483 bool root_exists = false;
492 syncer::ModelType type = syncer::BOOKMARKS; 484 syncer::ModelType type = syncer::BOOKMARKS;
493 { 485 {
494 syncer::WriteTransaction trans(FROM_HERE, 486 syncer::WriteTransaction trans(FROM_HERE, test_user_share_.user_share());
495 test_user_share_.user_share());
496 syncer::ReadNode uber_root(&trans); 487 syncer::ReadNode uber_root(&trans);
497 uber_root.InitByRootLookup(); 488 uber_root.InitByRootLookup();
498 489
499 syncer::ReadNode root(&trans); 490 syncer::ReadNode root(&trans);
500 root_exists = (root.InitTypeRoot(type) == BaseNode::INIT_OK); 491 root_exists = (root.InitTypeRoot(type) == BaseNode::INIT_OK);
501 } 492 }
502 493
503 if (!root_exists) { 494 if (!root_exists) {
504 if (!syncer::TestUserShare::CreateRoot(type, 495 if (!syncer::TestUserShare::CreateRoot(type,
505 test_user_share_.user_share())) 496 test_user_share_.user_share()))
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 model_associator_.reset(new BookmarkModelAssociator( 545 model_associator_.reset(new BookmarkModelAssociator(
555 model_.get(), sync_client_.get(), test_user_share_.user_share(), 546 model_.get(), sync_client_.get(), test_user_share_.user_share(),
556 &mock_error_handler_, kExpectMobileBookmarks)); 547 &mock_error_handler_, kExpectMobileBookmarks));
557 548
558 local_merge_result_ = syncer::SyncMergeResult(syncer::BOOKMARKS); 549 local_merge_result_ = syncer::SyncMergeResult(syncer::BOOKMARKS);
559 syncer_merge_result_ = syncer::SyncMergeResult(syncer::BOOKMARKS); 550 syncer_merge_result_ = syncer::SyncMergeResult(syncer::BOOKMARKS);
560 int local_count_before = model_->root_node()->GetTotalNodeCount(); 551 int local_count_before = model_->root_node()->GetTotalNodeCount();
561 int syncer_count_before = GetSyncBookmarkCount(); 552 int syncer_count_before = GetSyncBookmarkCount();
562 553
563 syncer::SyncError error = model_associator_->AssociateModels( 554 syncer::SyncError error = model_associator_->AssociateModels(
564 &local_merge_result_, 555 &local_merge_result_, &syncer_merge_result_);
565 &syncer_merge_result_);
566 if (error.IsSet()) 556 if (error.IsSet())
567 return false; 557 return false;
568 558
569 base::RunLoop().RunUntilIdle(); 559 base::RunLoop().RunUntilIdle();
570 560
571 // Verify the merge results were calculated properly. 561 // Verify the merge results were calculated properly.
572 EXPECT_EQ(local_count_before, 562 EXPECT_EQ(local_count_before,
573 local_merge_result_.num_items_before_association()); 563 local_merge_result_.num_items_before_association());
574 EXPECT_EQ(syncer_count_before, 564 EXPECT_EQ(syncer_count_before,
575 syncer_merge_result_.num_items_before_association()); 565 syncer_merge_result_.num_items_before_association());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 599
610 base::RunLoop().RunUntilIdle(); 600 base::RunLoop().RunUntilIdle();
611 601
612 // TODO(akalin): Actually close the database and flush it to disk 602 // TODO(akalin): Actually close the database and flush it to disk
613 // (and make StartSync reload from disk). This would require 603 // (and make StartSync reload from disk). This would require
614 // refactoring TestUserShare. 604 // refactoring TestUserShare.
615 } 605 }
616 606
617 bool InitSyncNodeFromChromeNode(const BookmarkNode* bnode, 607 bool InitSyncNodeFromChromeNode(const BookmarkNode* bnode,
618 BaseNode* sync_node) { 608 BaseNode* sync_node) {
619 return model_associator_->InitSyncNodeFromChromeId(bnode->id(), 609 return model_associator_->InitSyncNodeFromChromeId(bnode->id(), sync_node);
620 sync_node);
621 } 610 }
622 611
623 void ExpectSyncerNodeMatching(syncer::BaseTransaction* trans, 612 void ExpectSyncerNodeMatching(syncer::BaseTransaction* trans,
624 const BookmarkNode* bnode) { 613 const BookmarkNode* bnode) {
625 std::string truncated_title = base::UTF16ToUTF8(bnode->GetTitle()); 614 std::string truncated_title = base::UTF16ToUTF8(bnode->GetTitle());
626 syncer::SyncAPINameToServerName(truncated_title, &truncated_title); 615 syncer::SyncAPINameToServerName(truncated_title, &truncated_title);
627 base::TruncateUTF8ToByteSize(truncated_title, 255, &truncated_title); 616 base::TruncateUTF8ToByteSize(truncated_title, 255, &truncated_title);
628 syncer::ServerNameToSyncAPIName(truncated_title, &truncated_title); 617 syncer::ServerNameToSyncAPIName(truncated_title, &truncated_title);
629 618
630 syncer::ReadNode gnode(trans); 619 syncer::ReadNode gnode(trans);
631 ASSERT_TRUE(InitSyncNodeFromChromeNode(bnode, &gnode)); 620 ASSERT_TRUE(InitSyncNodeFromChromeNode(bnode, &gnode));
632 // Non-root node titles and parents must match. 621 // Non-root node titles and parents must match.
633 if (!model_->is_permanent_node(bnode)) { 622 if (!model_->is_permanent_node(bnode)) {
634 EXPECT_EQ(truncated_title, gnode.GetTitle()); 623 EXPECT_EQ(truncated_title, gnode.GetTitle());
635 EXPECT_EQ( 624 EXPECT_EQ(model_associator_->GetChromeNodeFromSyncId(gnode.GetParentId()),
636 model_associator_->GetChromeNodeFromSyncId(gnode.GetParentId()), 625 bnode->parent());
637 bnode->parent());
638 } 626 }
639 EXPECT_EQ(bnode->is_folder(), gnode.GetIsFolder()); 627 EXPECT_EQ(bnode->is_folder(), gnode.GetIsFolder());
640 if (bnode->is_url()) 628 if (bnode->is_url())
641 EXPECT_EQ(bnode->url(), GURL(gnode.GetBookmarkSpecifics().url())); 629 EXPECT_EQ(bnode->url(), GURL(gnode.GetBookmarkSpecifics().url()));
642 630
643 // Check that meta info matches. 631 // Check that meta info matches.
644 const BookmarkNode::MetaInfoMap* meta_info_map = bnode->GetMetaInfoMap(); 632 const BookmarkNode::MetaInfoMap* meta_info_map = bnode->GetMetaInfoMap();
645 sync_pb::BookmarkSpecifics specifics = gnode.GetBookmarkSpecifics(); 633 sync_pb::BookmarkSpecifics specifics = gnode.GetBookmarkSpecifics();
646 if (!meta_info_map) { 634 if (!meta_info_map) {
647 EXPECT_EQ(0, specifics.meta_info_size()); 635 EXPECT_EQ(0, specifics.meta_info_size());
648 } else { 636 } else {
649 EXPECT_EQ(meta_info_map->size(), 637 EXPECT_EQ(meta_info_map->size(),
650 static_cast<size_t>(specifics.meta_info_size())); 638 static_cast<size_t>(specifics.meta_info_size()));
651 for (int i = 0; i < specifics.meta_info_size(); i++) { 639 for (int i = 0; i < specifics.meta_info_size(); i++) {
652 BookmarkNode::MetaInfoMap::const_iterator it = 640 BookmarkNode::MetaInfoMap::const_iterator it =
653 meta_info_map->find(specifics.meta_info(i).key()); 641 meta_info_map->find(specifics.meta_info(i).key());
654 EXPECT_TRUE(it != meta_info_map->end()); 642 EXPECT_TRUE(it != meta_info_map->end());
655 EXPECT_EQ(it->second, specifics.meta_info(i).value()); 643 EXPECT_EQ(it->second, specifics.meta_info(i).value());
656 } 644 }
657 } 645 }
658 646
659 // Check for position matches. 647 // Check for position matches.
660 int browser_index = bnode->parent()->GetIndexOf(bnode); 648 int browser_index = bnode->parent()->GetIndexOf(bnode);
661 if (browser_index == 0) { 649 if (browser_index == 0) {
662 EXPECT_EQ(gnode.GetPredecessorId(), 0); 650 EXPECT_EQ(gnode.GetPredecessorId(), 0);
663 } else { 651 } else {
664 const BookmarkNode* bprev = 652 const BookmarkNode* bprev = bnode->parent()->GetChild(browser_index - 1);
665 bnode->parent()->GetChild(browser_index - 1);
666 syncer::ReadNode gprev(trans); 653 syncer::ReadNode gprev(trans);
667 ASSERT_TRUE(InitSyncNodeFromChromeNode(bprev, &gprev)); 654 ASSERT_TRUE(InitSyncNodeFromChromeNode(bprev, &gprev));
668 EXPECT_EQ(gnode.GetPredecessorId(), gprev.GetId()); 655 EXPECT_EQ(gnode.GetPredecessorId(), gprev.GetId());
669 EXPECT_EQ(gnode.GetParentId(), gprev.GetParentId()); 656 EXPECT_EQ(gnode.GetParentId(), gprev.GetParentId());
670 } 657 }
671 // Note: the managed node is the last child of the root_node but isn't 658 // Note: the managed node is the last child of the root_node but isn't
672 // synced; if CanSyncNode() is false then there is no next node to sync. 659 // synced; if CanSyncNode() is false then there is no next node to sync.
673 const BookmarkNode* bnext = NULL; 660 const BookmarkNode* bnext = NULL;
674 if (browser_index + 1 < bnode->parent()->child_count()) 661 if (browser_index + 1 < bnode->parent()->child_count())
675 bnext = bnode->parent()->GetChild(browser_index + 1); 662 bnext = bnode->parent()->GetChild(browser_index + 1);
676 if (!bnext || !CanSyncNode(bnext)) { 663 if (!bnext || !CanSyncNode(bnext)) {
677 EXPECT_EQ(gnode.GetSuccessorId(), 0); 664 EXPECT_EQ(gnode.GetSuccessorId(), 0);
678 } else { 665 } else {
679 syncer::ReadNode gnext(trans); 666 syncer::ReadNode gnext(trans);
680 ASSERT_TRUE(InitSyncNodeFromChromeNode(bnext, &gnext)); 667 ASSERT_TRUE(InitSyncNodeFromChromeNode(bnext, &gnext));
681 EXPECT_EQ(gnode.GetSuccessorId(), gnext.GetId()); 668 EXPECT_EQ(gnode.GetSuccessorId(), gnext.GetId());
682 EXPECT_EQ(gnode.GetParentId(), gnext.GetParentId()); 669 EXPECT_EQ(gnode.GetParentId(), gnext.GetParentId());
683 } 670 }
684 if (!bnode->empty()) 671 if (!bnode->empty())
685 EXPECT_TRUE(gnode.GetFirstChildId()); 672 EXPECT_TRUE(gnode.GetFirstChildId());
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 const BookmarkNode* root = model_->root_node(); 736 const BookmarkNode* root = model_->root_node();
750 EXPECT_EQ(root->GetIndexOf(model_->bookmark_bar_node()), 0); 737 EXPECT_EQ(root->GetIndexOf(model_->bookmark_bar_node()), 0);
751 EXPECT_EQ(root->GetIndexOf(model_->other_node()), 1); 738 EXPECT_EQ(root->GetIndexOf(model_->other_node()), 1);
752 EXPECT_EQ(root->GetIndexOf(model_->mobile_node()), 2); 739 EXPECT_EQ(root->GetIndexOf(model_->mobile_node()), 2);
753 740
754 std::stack<int64_t> stack; 741 std::stack<int64_t> stack;
755 stack.push(bookmark_bar_id()); 742 stack.push(bookmark_bar_id());
756 while (!stack.empty()) { 743 while (!stack.empty()) {
757 int64_t id = stack.top(); 744 int64_t id = stack.top();
758 stack.pop(); 745 stack.pop();
759 if (!id) continue; 746 if (!id)
747 continue;
760 748
761 ExpectBrowserNodeMatching(trans, id); 749 ExpectBrowserNodeMatching(trans, id);
762 750
763 syncer::ReadNode gnode(trans); 751 syncer::ReadNode gnode(trans);
764 ASSERT_EQ(BaseNode::INIT_OK, gnode.InitByIdLookup(id)); 752 ASSERT_EQ(BaseNode::INIT_OK, gnode.InitByIdLookup(id));
765 stack.push(gnode.GetSuccessorId()); 753 stack.push(gnode.GetSuccessorId());
766 if (gnode.GetIsFolder()) 754 if (gnode.GetIsFolder())
767 stack.push(gnode.GetFirstChildId()); 755 stack.push(gnode.GetFirstChildId());
768 } 756 }
769 } 757 }
770 758
771 void ExpectModelMatch() { 759 void ExpectModelMatch() {
772 syncer::ReadTransaction trans(FROM_HERE, test_user_share_.user_share()); 760 syncer::ReadTransaction trans(FROM_HERE, test_user_share_.user_share());
773 ExpectModelMatch(&trans); 761 ExpectModelMatch(&trans);
774 } 762 }
775 763
776 int64_t mobile_bookmarks_id() { 764 int64_t mobile_bookmarks_id() {
777 return 765 return model_associator_->GetSyncIdFromChromeId(
778 model_associator_->GetSyncIdFromChromeId(model_->mobile_node()->id()); 766 model_->mobile_node()->id());
779 } 767 }
780 768
781 int64_t other_bookmarks_id() { 769 int64_t other_bookmarks_id() {
782 return 770 return model_associator_->GetSyncIdFromChromeId(model_->other_node()->id());
783 model_associator_->GetSyncIdFromChromeId(model_->other_node()->id());
784 } 771 }
785 772
786 int64_t bookmark_bar_id() { 773 int64_t bookmark_bar_id() {
787 return model_associator_->GetSyncIdFromChromeId( 774 return model_associator_->GetSyncIdFromChromeId(
788 model_->bookmark_bar_node()->id()); 775 model_->bookmark_bar_node()->id());
789 } 776 }
790 777
791 BookmarkModel* model() { return model_.get(); } 778 BookmarkModel* model() { return model_.get(); }
792 779
793 syncer::TestUserShare* test_user_share() { return &test_user_share_; } 780 syncer::TestUserShare* test_user_share() { return &test_user_share_; }
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 int64_t u1 = adds.AddURL("Some old site", "ftp://nifty.andrew.cmu.edu/", 1170 int64_t u1 = adds.AddURL("Some old site", "ftp://nifty.andrew.cmu.edu/",
1184 bookmark_bar_id(), f2); 1171 bookmark_bar_id(), f2);
1185 int64_t u2 = adds.AddURL("Nifty", "ftp://nifty.andrew.cmu.edu/", f1, 0); 1172 int64_t u2 = adds.AddURL("Nifty", "ftp://nifty.andrew.cmu.edu/", f1, 0);
1186 // u3 is a duplicate URL 1173 // u3 is a duplicate URL
1187 int64_t u3 = adds.AddURL("Nifty2", "ftp://nifty.andrew.cmu.edu/", f1, u2); 1174 int64_t u3 = adds.AddURL("Nifty2", "ftp://nifty.andrew.cmu.edu/", f1, u2);
1188 // u4 is a duplicate title, different URL. 1175 // u4 is a duplicate title, different URL.
1189 adds.AddURL("Some old site", "http://slog.thestranger.com/", 1176 adds.AddURL("Some old site", "http://slog.thestranger.com/",
1190 bookmark_bar_id(), u1); 1177 bookmark_bar_id(), u1);
1191 // u5 tests an empty-string title. 1178 // u5 tests an empty-string title.
1192 std::string javascript_url( 1179 std::string javascript_url(
1193 "javascript:(function(){var w=window.open(" \ 1180 "javascript:(function(){var w=window.open("
1194 "'about:blank','gnotesWin','location=0,menubar=0," \ 1181 "'about:blank','gnotesWin','location=0,menubar=0,"
1195 "scrollbars=0,status=0,toolbar=0,width=300," \ 1182 "scrollbars=0,status=0,toolbar=0,width=300,"
1196 "height=300,resizable');});"); 1183 "height=300,resizable');});");
1197 adds.AddURL(std::string(), javascript_url, other_bookmarks_id(), 0); 1184 adds.AddURL(std::string(), javascript_url, other_bookmarks_id(), 0);
1198 int64_t u6 = adds.AddURL("Sync1", "http://www.syncable.edu/", 1185 int64_t u6 = adds.AddURL("Sync1", "http://www.syncable.edu/",
1199 mobile_bookmarks_id(), 0); 1186 mobile_bookmarks_id(), 0);
1200 1187
1201 syncer::ChangeRecordList::const_iterator it; 1188 syncer::ChangeRecordList::const_iterator it;
1202 // The bookmark model shouldn't yet have seen any of the nodes of |adds|. 1189 // The bookmark model shouldn't yet have seen any of the nodes of |adds|.
1203 for (it = adds.changes().begin(); it != adds.changes().end(); ++it) 1190 for (it = adds.changes().begin(); it != adds.changes().end(); ++it)
1204 ExpectBrowserNodeUnknown(it->id); 1191 ExpectBrowserNodeUnknown(it->id);
1205 1192
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 // Now reboot the sync service, forcing a merge step. 1359 // Now reboot the sync service, forcing a merge step.
1373 StopSync(); 1360 StopSync();
1374 LoadBookmarkModel(LOAD_FROM_STORAGE, SAVE_TO_STORAGE); 1361 LoadBookmarkModel(LOAD_FROM_STORAGE, SAVE_TO_STORAGE);
1375 StartSync(); 1362 StartSync();
1376 1363
1377 // Things ought not to have changed. 1364 // Things ought not to have changed.
1378 EXPECT_EQ(model()->other_node()->child_count(), child_count); 1365 EXPECT_EQ(model()->other_node()->child_count(), child_count);
1379 ExpectModelMatch(); 1366 ExpectModelMatch();
1380 } 1367 }
1381 1368
1382
1383 // Test strings that might pose a problem if the titles ever became used as 1369 // Test strings that might pose a problem if the titles ever became used as
1384 // file names in the sync backend. 1370 // file names in the sync backend.
1385 TEST_F(ProfileSyncServiceBookmarkTest, CornerCaseNames) { 1371 TEST_F(ProfileSyncServiceBookmarkTest, CornerCaseNames) {
1386 // TODO(ncarter): Bug 1570238 explains the failure of this test. 1372 // TODO(ncarter): Bug 1570238 explains the failure of this test.
1387 LoadBookmarkModel(DELETE_EXISTING_STORAGE, SAVE_TO_STORAGE); 1373 LoadBookmarkModel(DELETE_EXISTING_STORAGE, SAVE_TO_STORAGE);
1388 StartSync(); 1374 StartSync();
1389 1375
1390 const char* names[] = { 1376 const char* names[] = {
1391 // The empty string. 1377 // The empty string.
1392 "", 1378 "",
1393 // Illegal Windows filenames. 1379 // Illegal Windows filenames.
1394 "CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", 1380 "CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5",
1395 "COM5", "COM6", "COM7", "COM8", "COM9", "LPT1", "LPT2", "LPT3", 1381 "COM6", "COM7", "COM8", "COM9", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5",
1396 "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9", 1382 "LPT6", "LPT7", "LPT8", "LPT9",
1397 // Current/parent directory markers. 1383 // Current/parent directory markers.
1398 ".", "..", "...", 1384 ".", "..", "...",
1399 // Files created automatically by the Windows shell. 1385 // Files created automatically by the Windows shell.
1400 "Thumbs.db", ".DS_Store", 1386 "Thumbs.db", ".DS_Store",
1401 // Names including Win32-illegal characters, and path separators. 1387 // Names including Win32-illegal characters, and path separators.
1402 "foo/bar", "foo\\bar", "foo?bar", "foo:bar", "foo|bar", "foo\"bar", 1388 "foo/bar", "foo\\bar", "foo?bar", "foo:bar", "foo|bar", "foo\"bar",
1403 "foo'bar", "foo<bar", "foo>bar", "foo%bar", "foo*bar", "foo]bar", 1389 "foo'bar", "foo<bar", "foo>bar", "foo%bar", "foo*bar", "foo]bar",
1404 "foo[bar", 1390 "foo[bar",
1405 // A name with title > 255 characters 1391 // A name with title > 255 characters
1406 "012345678901234567890123456789012345678901234567890123456789012345678901" 1392 "012345678901234567890123456789012345678901234567890123456789012345678901"
1407 "234567890123456789012345678901234567890123456789012345678901234567890123" 1393 "234567890123456789012345678901234567890123456789012345678901234567890123"
1408 "456789012345678901234567890123456789012345678901234567890123456789012345" 1394 "456789012345678901234567890123456789012345678901234567890123456789012345"
1409 "678901234567890123456789012345678901234567890123456789012345678901234567" 1395 "678901234567890123456789012345678901234567890123456789012345678901234567"
1410 "890123456789" 1396 "890123456789"};
1411 };
1412 // Create both folders and bookmarks using each name. 1397 // Create both folders and bookmarks using each name.
1413 GURL url("http://www.doublemint.com"); 1398 GURL url("http://www.doublemint.com");
1414 for (size_t i = 0; i < arraysize(names); ++i) { 1399 for (size_t i = 0; i < arraysize(names); ++i) {
1415 model()->AddFolder(model()->other_node(), 0, base::ASCIIToUTF16(names[i])); 1400 model()->AddFolder(model()->other_node(), 0, base::ASCIIToUTF16(names[i]));
1416 model()->AddURL(model()->other_node(), 0, base::ASCIIToUTF16(names[i]), 1401 model()->AddURL(model()->other_node(), 0, base::ASCIIToUTF16(names[i]),
1417 url); 1402 url);
1418 } 1403 }
1419 1404
1420 // Verify that the browser model matches the sync model. 1405 // Verify that the browser model matches the sync model.
1421 EXPECT_EQ(static_cast<size_t>(model()->other_node()->child_count()), 1406 EXPECT_EQ(static_cast<size_t>(model()->other_node()->child_count()),
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1696 // | 1681 // |
1697 // +-- Mobile bookmarks 1682 // +-- Mobile bookmarks
1698 // |-- f5 1683 // |-- f5
1699 // | |-- f5u1, http://www.f5u1.com/ 1684 // | |-- f5u1, http://www.f5u1.com/
1700 // |-- f6 1685 // |-- f6
1701 // | |-- f6u1, http://www.f6u1.com/ 1686 // | |-- f6u1, http://www.f6u1.com/
1702 // | |-- f6u2, http://www.f6u2.com/ 1687 // | |-- f6u2, http://www.f6u2.com/
1703 // +-- u5, http://www.u5.com/ 1688 // +-- u5, http://www.u5.com/
1704 1689
1705 static TestData kBookmarkBarChildren[] = { 1690 static TestData kBookmarkBarChildren[] = {
1706 { "u2", "http://www.u2.com/" }, 1691 {"u2", "http://www.u2.com/"},
1707 { "f1", NULL }, 1692 {"f1", NULL},
1708 { "u1", "http://www.u1.com/" }, 1693 {"u1", "http://www.u1.com/"},
1709 { "f2", NULL }, 1694 {"f2", NULL},
1710 }; 1695 };
1711 static TestData kF1Children[] = { 1696 static TestData kF1Children[] = {
1712 { "f1u4", "http://www.f1u4.com/" }, 1697 {"f1u4", "http://www.f1u4.com/"},
1713 { "f1u2", "http://www.f1u2.com/" }, 1698 {"f1u2", "http://www.f1u2.com/"},
1714 { "f1u3", "http://www.f1u3.com/" }, 1699 {"f1u3", "http://www.f1u3.com/"},
1715 { "f1u1", "http://www.f1u1.com/" }, 1700 {"f1u1", "http://www.f1u1.com/"},
1716 }; 1701 };
1717 static TestData kF2Children[] = { 1702 static TestData kF2Children[] = {
1718 { "f2u2", "http://www.f2u2.com/" }, 1703 {"f2u2", "http://www.f2u2.com/"},
1719 { "f2u4", "http://www.f2u4.com/" }, 1704 {"f2u4", "http://www.f2u4.com/"},
1720 { "f2u3", "http://www.f2u3.com/" }, 1705 {"f2u3", "http://www.f2u3.com/"},
1721 { "f2u1", "http://www.f2u1.com/" }, 1706 {"f2u1", "http://www.f2u1.com/"},
1722 }; 1707 };
1723 1708
1724 static TestData kOtherBookmarkChildren[] = { 1709 static TestData kOtherBookmarkChildren[] = {{"f3", NULL},
1725 { "f3", NULL }, 1710 {"u4", "http://www.u4.com/"},
1726 { "u4", "http://www.u4.com/" }, 1711 {"u3", "http://www.u3.com/"},
1727 { "u3", "http://www.u3.com/" }, 1712 {"f4", NULL},
1728 { "f4", NULL }, 1713 {"dup", NULL},
1729 { "dup", NULL }, 1714 {"dup", NULL},
1730 { "dup", NULL }, 1715 {" ls ", "http://www.ls.com/"}};
1731 { " ls ", "http://www.ls.com/" }
1732 };
1733 static TestData kF3Children[] = { 1716 static TestData kF3Children[] = {
1734 { "f3u4", "http://www.f3u4.com/" }, 1717 {"f3u4", "http://www.f3u4.com/"},
1735 { "f3u2", "http://www.f3u2.com/" }, 1718 {"f3u2", "http://www.f3u2.com/"},
1736 { "f3u3", "http://www.f3u3.com/" }, 1719 {"f3u3", "http://www.f3u3.com/"},
1737 { "f3u1", "http://www.f3u1.com/" }, 1720 {"f3u1", "http://www.f3u1.com/"},
1738 }; 1721 };
1739 static TestData kF4Children[] = { 1722 static TestData kF4Children[] = {
1740 { "f4u1", "http://www.f4u1.com/" }, 1723 {"f4u1", "http://www.f4u1.com/"},
1741 { "f4u2", "http://www.f4u2.com/" }, 1724 {"f4u2", "http://www.f4u2.com/"},
1742 { "f4u3", "http://www.f4u3.com/" }, 1725 {"f4u3", "http://www.f4u3.com/"},
1743 { "f4u4", "http://www.f4u4.com/" }, 1726 {"f4u4", "http://www.f4u4.com/"},
1744 }; 1727 };
1745 static TestData kDup1Children[] = { 1728 static TestData kDup1Children[] = {
1746 { "dupu1", "http://www.dupu1.com/" }, 1729 {"dupu1", "http://www.dupu1.com/"},
1747 }; 1730 };
1748 static TestData kDup2Children[] = { 1731 static TestData kDup2Children[] = {
1749 { "dupu2", "http://www.dupu2.com/" }, 1732 {"dupu2", "http://www.dupu2.com/"},
1750 }; 1733 };
1751 1734
1752 static TestData kMobileBookmarkChildren[] = { 1735 static TestData kMobileBookmarkChildren[] = {
1753 { "f5", NULL }, 1736 {"f5", NULL},
1754 { "f6", NULL }, 1737 {"f6", NULL},
1755 { "u5", "http://www.u5.com/" }, 1738 {"u5", "http://www.u5.com/"},
1756 }; 1739 };
1757 static TestData kF5Children[] = { 1740 static TestData kF5Children[] = {
1758 { "f5u1", "http://www.f5u1.com/" }, 1741 {"f5u1", "http://www.f5u1.com/"},
1759 { "f5u2", "http://www.f5u2.com/" }, 1742 {"f5u2", "http://www.f5u2.com/"},
1760 }; 1743 };
1761 static TestData kF6Children[] = { 1744 static TestData kF6Children[] = {
1762 { "f6u1", "http://www.f6u1.com/" }, 1745 {"f6u1", "http://www.f6u1.com/"},
1763 { "f6u2", "http://www.f6u2.com/" }, 1746 {"f6u2", "http://www.f6u2.com/"},
1764 }; 1747 };
1765 1748
1766 } // anonymous namespace. 1749 } // anonymous namespace.
1767 1750
1768 ProfileSyncServiceBookmarkTestWithData:: 1751 ProfileSyncServiceBookmarkTestWithData::ProfileSyncServiceBookmarkTestWithData()
1769 ProfileSyncServiceBookmarkTestWithData() 1752 : start_time_(base::Time::Now()) {}
1770 : start_time_(base::Time::Now()) {
1771 }
1772 1753
1773 void ProfileSyncServiceBookmarkTestWithData::PopulateFromTestData( 1754 void ProfileSyncServiceBookmarkTestWithData::PopulateFromTestData(
1774 const BookmarkNode* node, 1755 const BookmarkNode* node,
1775 const TestData* data, 1756 const TestData* data,
1776 int size, 1757 int size,
1777 int* running_count) { 1758 int* running_count) {
1778 DCHECK(node); 1759 DCHECK(node);
1779 DCHECK(data); 1760 DCHECK(data);
1780 DCHECK(node->is_folder()); 1761 DCHECK(node->is_folder());
1781 for (int i = 0; i < size; ++i) { 1762 for (int i = 0; i < size; ++i) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1823 } 1804 }
1824 (*running_count)++; 1805 (*running_count)++;
1825 } 1806 }
1826 } 1807 }
1827 1808
1828 // TODO(munjal): We should implement some way of generating random data and can 1809 // TODO(munjal): We should implement some way of generating random data and can
1829 // use the same seed to generate the same sequence. 1810 // use the same seed to generate the same sequence.
1830 void ProfileSyncServiceBookmarkTestWithData::WriteTestDataToBookmarkModel() { 1811 void ProfileSyncServiceBookmarkTestWithData::WriteTestDataToBookmarkModel() {
1831 const BookmarkNode* bookmarks_bar_node = model()->bookmark_bar_node(); 1812 const BookmarkNode* bookmarks_bar_node = model()->bookmark_bar_node();
1832 int count = 0; 1813 int count = 0;
1833 PopulateFromTestData(bookmarks_bar_node, 1814 PopulateFromTestData(bookmarks_bar_node, kBookmarkBarChildren,
1834 kBookmarkBarChildren, 1815 arraysize(kBookmarkBarChildren), &count);
1835 arraysize(kBookmarkBarChildren),
1836 &count);
1837 1816
1838 ASSERT_GE(bookmarks_bar_node->child_count(), 4); 1817 ASSERT_GE(bookmarks_bar_node->child_count(), 4);
1839 const BookmarkNode* f1_node = bookmarks_bar_node->GetChild(1); 1818 const BookmarkNode* f1_node = bookmarks_bar_node->GetChild(1);
1840 PopulateFromTestData(f1_node, kF1Children, arraysize(kF1Children), &count); 1819 PopulateFromTestData(f1_node, kF1Children, arraysize(kF1Children), &count);
1841 const BookmarkNode* f2_node = bookmarks_bar_node->GetChild(3); 1820 const BookmarkNode* f2_node = bookmarks_bar_node->GetChild(3);
1842 PopulateFromTestData(f2_node, kF2Children, arraysize(kF2Children), &count); 1821 PopulateFromTestData(f2_node, kF2Children, arraysize(kF2Children), &count);
1843 1822
1844 const BookmarkNode* other_bookmarks_node = model()->other_node(); 1823 const BookmarkNode* other_bookmarks_node = model()->other_node();
1845 PopulateFromTestData(other_bookmarks_node, 1824 PopulateFromTestData(other_bookmarks_node, kOtherBookmarkChildren,
1846 kOtherBookmarkChildren, 1825 arraysize(kOtherBookmarkChildren), &count);
1847 arraysize(kOtherBookmarkChildren),
1848 &count);
1849 1826
1850 ASSERT_GE(other_bookmarks_node->child_count(), 6); 1827 ASSERT_GE(other_bookmarks_node->child_count(), 6);
1851 const BookmarkNode* f3_node = other_bookmarks_node->GetChild(0); 1828 const BookmarkNode* f3_node = other_bookmarks_node->GetChild(0);
1852 PopulateFromTestData(f3_node, kF3Children, arraysize(kF3Children), &count); 1829 PopulateFromTestData(f3_node, kF3Children, arraysize(kF3Children), &count);
1853 const BookmarkNode* f4_node = other_bookmarks_node->GetChild(3); 1830 const BookmarkNode* f4_node = other_bookmarks_node->GetChild(3);
1854 PopulateFromTestData(f4_node, kF4Children, arraysize(kF4Children), &count); 1831 PopulateFromTestData(f4_node, kF4Children, arraysize(kF4Children), &count);
1855 const BookmarkNode* dup_node = other_bookmarks_node->GetChild(4); 1832 const BookmarkNode* dup_node = other_bookmarks_node->GetChild(4);
1856 PopulateFromTestData(dup_node, kDup1Children, arraysize(kDup1Children), 1833 PopulateFromTestData(dup_node, kDup1Children, arraysize(kDup1Children),
1857 &count); 1834 &count);
1858 dup_node = other_bookmarks_node->GetChild(5); 1835 dup_node = other_bookmarks_node->GetChild(5);
1859 PopulateFromTestData(dup_node, kDup2Children, arraysize(kDup2Children), 1836 PopulateFromTestData(dup_node, kDup2Children, arraysize(kDup2Children),
1860 &count); 1837 &count);
1861 1838
1862 const BookmarkNode* mobile_bookmarks_node = model()->mobile_node(); 1839 const BookmarkNode* mobile_bookmarks_node = model()->mobile_node();
1863 PopulateFromTestData(mobile_bookmarks_node, 1840 PopulateFromTestData(mobile_bookmarks_node, kMobileBookmarkChildren,
1864 kMobileBookmarkChildren, 1841 arraysize(kMobileBookmarkChildren), &count);
1865 arraysize(kMobileBookmarkChildren),
1866 &count);
1867 1842
1868 ASSERT_GE(mobile_bookmarks_node->child_count(), 3); 1843 ASSERT_GE(mobile_bookmarks_node->child_count(), 3);
1869 const BookmarkNode* f5_node = mobile_bookmarks_node->GetChild(0); 1844 const BookmarkNode* f5_node = mobile_bookmarks_node->GetChild(0);
1870 PopulateFromTestData(f5_node, kF5Children, arraysize(kF5Children), &count); 1845 PopulateFromTestData(f5_node, kF5Children, arraysize(kF5Children), &count);
1871 const BookmarkNode* f6_node = mobile_bookmarks_node->GetChild(1); 1846 const BookmarkNode* f6_node = mobile_bookmarks_node->GetChild(1);
1872 PopulateFromTestData(f6_node, kF6Children, arraysize(kF6Children), &count); 1847 PopulateFromTestData(f6_node, kF6Children, arraysize(kF6Children), &count);
1873 1848
1874 ExpectBookmarkModelMatchesTestData(); 1849 ExpectBookmarkModelMatchesTestData();
1875 } 1850 }
1876 1851
1877 void ProfileSyncServiceBookmarkTestWithData:: 1852 void ProfileSyncServiceBookmarkTestWithData::
1878 ExpectBookmarkModelMatchesTestData() { 1853 ExpectBookmarkModelMatchesTestData() {
1879 const BookmarkNode* bookmark_bar_node = model()->bookmark_bar_node(); 1854 const BookmarkNode* bookmark_bar_node = model()->bookmark_bar_node();
1880 int count = 0; 1855 int count = 0;
1881 CompareWithTestData(bookmark_bar_node, 1856 CompareWithTestData(bookmark_bar_node, kBookmarkBarChildren,
1882 kBookmarkBarChildren, 1857 arraysize(kBookmarkBarChildren), &count);
1883 arraysize(kBookmarkBarChildren),
1884 &count);
1885 1858
1886 ASSERT_GE(bookmark_bar_node->child_count(), 4); 1859 ASSERT_GE(bookmark_bar_node->child_count(), 4);
1887 const BookmarkNode* f1_node = bookmark_bar_node->GetChild(1); 1860 const BookmarkNode* f1_node = bookmark_bar_node->GetChild(1);
1888 CompareWithTestData(f1_node, kF1Children, arraysize(kF1Children), &count); 1861 CompareWithTestData(f1_node, kF1Children, arraysize(kF1Children), &count);
1889 const BookmarkNode* f2_node = bookmark_bar_node->GetChild(3); 1862 const BookmarkNode* f2_node = bookmark_bar_node->GetChild(3);
1890 CompareWithTestData(f2_node, kF2Children, arraysize(kF2Children), &count); 1863 CompareWithTestData(f2_node, kF2Children, arraysize(kF2Children), &count);
1891 1864
1892 const BookmarkNode* other_bookmarks_node = model()->other_node(); 1865 const BookmarkNode* other_bookmarks_node = model()->other_node();
1893 CompareWithTestData(other_bookmarks_node, 1866 CompareWithTestData(other_bookmarks_node, kOtherBookmarkChildren,
1894 kOtherBookmarkChildren, 1867 arraysize(kOtherBookmarkChildren), &count);
1895 arraysize(kOtherBookmarkChildren),
1896 &count);
1897 1868
1898 ASSERT_GE(other_bookmarks_node->child_count(), 6); 1869 ASSERT_GE(other_bookmarks_node->child_count(), 6);
1899 const BookmarkNode* f3_node = other_bookmarks_node->GetChild(0); 1870 const BookmarkNode* f3_node = other_bookmarks_node->GetChild(0);
1900 CompareWithTestData(f3_node, kF3Children, arraysize(kF3Children), &count); 1871 CompareWithTestData(f3_node, kF3Children, arraysize(kF3Children), &count);
1901 const BookmarkNode* f4_node = other_bookmarks_node->GetChild(3); 1872 const BookmarkNode* f4_node = other_bookmarks_node->GetChild(3);
1902 CompareWithTestData(f4_node, kF4Children, arraysize(kF4Children), &count); 1873 CompareWithTestData(f4_node, kF4Children, arraysize(kF4Children), &count);
1903 const BookmarkNode* dup_node = other_bookmarks_node->GetChild(4); 1874 const BookmarkNode* dup_node = other_bookmarks_node->GetChild(4);
1904 CompareWithTestData(dup_node, kDup1Children, arraysize(kDup1Children), 1875 CompareWithTestData(dup_node, kDup1Children, arraysize(kDup1Children),
1905 &count); 1876 &count);
1906 dup_node = other_bookmarks_node->GetChild(5); 1877 dup_node = other_bookmarks_node->GetChild(5);
1907 CompareWithTestData(dup_node, kDup2Children, arraysize(kDup2Children), 1878 CompareWithTestData(dup_node, kDup2Children, arraysize(kDup2Children),
1908 &count); 1879 &count);
1909 1880
1910 const BookmarkNode* mobile_bookmarks_node = model()->mobile_node(); 1881 const BookmarkNode* mobile_bookmarks_node = model()->mobile_node();
1911 CompareWithTestData(mobile_bookmarks_node, 1882 CompareWithTestData(mobile_bookmarks_node, kMobileBookmarkChildren,
1912 kMobileBookmarkChildren, 1883 arraysize(kMobileBookmarkChildren), &count);
1913 arraysize(kMobileBookmarkChildren),
1914 &count);
1915 1884
1916 ASSERT_GE(mobile_bookmarks_node->child_count(), 3); 1885 ASSERT_GE(mobile_bookmarks_node->child_count(), 3);
1917 const BookmarkNode* f5_node = mobile_bookmarks_node->GetChild(0); 1886 const BookmarkNode* f5_node = mobile_bookmarks_node->GetChild(0);
1918 CompareWithTestData(f5_node, kF5Children, arraysize(kF5Children), &count); 1887 CompareWithTestData(f5_node, kF5Children, arraysize(kF5Children), &count);
1919 const BookmarkNode* f6_node = mobile_bookmarks_node->GetChild(1); 1888 const BookmarkNode* f6_node = mobile_bookmarks_node->GetChild(1);
1920 CompareWithTestData(f6_node, kF6Children, arraysize(kF6Children), &count); 1889 CompareWithTestData(f6_node, kF6Children, arraysize(kF6Children), &count);
1921 } 1890 }
1922 1891
1923 // Tests persistence of the profile sync service by unloading the 1892 // Tests persistence of the profile sync service by unloading the
1924 // database and then reloading it from disk. 1893 // database and then reloading it from disk.
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
2618 EXPECT_EQ(syncer::kInvalidId, sync_id); 2587 EXPECT_EQ(syncer::kInvalidId, sync_id);
2619 2588
2620 // Verify that Sync ignores deleting this node. 2589 // Verify that Sync ignores deleting this node.
2621 model()->Remove(node); 2590 model()->Remove(node);
2622 EXPECT_EQ(sync_bookmark_count, GetSyncBookmarkCount()); 2591 EXPECT_EQ(sync_bookmark_count, GetSyncBookmarkCount());
2623 } 2592 }
2624 2593
2625 } // namespace 2594 } // namespace
2626 2595
2627 } // namespace browser_sync 2596 } // namespace browser_sync
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698