| 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 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" | 5 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" | 
| 6 | 6 | 
| 7 #include <stddef.h> | 7 #include <stddef.h> | 
| 8 | 8 | 
| 9 #include <memory> | 9 #include <memory> | 
| 10 #include <set> | 10 #include <set> | 
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 135   BookmarkModel* model_; | 135   BookmarkModel* model_; | 
| 136   const BookmarkNode* node_; | 136   const BookmarkNode* node_; | 
| 137   bool wait_for_load_; | 137   bool wait_for_load_; | 
| 138   DISALLOW_COPY_AND_ASSIGN(FaviconChangeObserver); | 138   DISALLOW_COPY_AND_ASSIGN(FaviconChangeObserver); | 
| 139 }; | 139 }; | 
| 140 | 140 | 
| 141 // A collection of URLs for which we have added favicons. Since loading a | 141 // A collection of URLs for which we have added favicons. Since loading a | 
| 142 // favicon is an asynchronous operation and doesn't necessarily invoke a | 142 // favicon is an asynchronous operation and doesn't necessarily invoke a | 
| 143 // callback, this collection is used to determine if we must wait for a URL's | 143 // callback, this collection is used to determine if we must wait for a URL's | 
| 144 // favicon to load or not. | 144 // favicon to load or not. | 
| 145 std::set<GURL>* urls_with_favicons_ = NULL; | 145 std::set<GURL>* urls_with_favicons_ = nullptr; | 
| 146 | 146 | 
| 147 // Returns the number of nodes of node type |node_type| in |model| whose | 147 // Returns the number of nodes of node type |node_type| in |model| whose | 
| 148 // titles match the string |title|. | 148 // titles match the string |title|. | 
| 149 int CountNodesWithTitlesMatching(BookmarkModel* model, | 149 int CountNodesWithTitlesMatching(BookmarkModel* model, | 
| 150                                  BookmarkNode::Type node_type, | 150                                  BookmarkNode::Type node_type, | 
| 151                                  const base::string16& title) { | 151                                  const base::string16& title) { | 
| 152   ui::TreeNodeIterator<const BookmarkNode> iterator(model->root_node()); | 152   ui::TreeNodeIterator<const BookmarkNode> iterator(model->root_node()); | 
| 153   // Walk through the model tree looking for bookmark nodes of node type | 153   // Walk through the model tree looking for bookmark nodes of node type | 
| 154   // |node_type| whose titles match |title|. | 154   // |node_type| whose titles match |title|. | 
| 155   int count = 0; | 155   int count = 0; | 
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 348   SkBitmap bitmap_a = image_a.AsImageSkia().GetRepresentation( | 348   SkBitmap bitmap_a = image_a.AsImageSkia().GetRepresentation( | 
| 349       1.0f).sk_bitmap(); | 349       1.0f).sk_bitmap(); | 
| 350   SkBitmap bitmap_b = image_b.AsImageSkia().GetRepresentation( | 350   SkBitmap bitmap_b = image_b.AsImageSkia().GetRepresentation( | 
| 351       1.0f).sk_bitmap(); | 351       1.0f).sk_bitmap(); | 
| 352   return FaviconRawBitmapsMatch(bitmap_a, bitmap_b); | 352   return FaviconRawBitmapsMatch(bitmap_a, bitmap_b); | 
| 353 } | 353 } | 
| 354 | 354 | 
| 355 // Does a deep comparison of BookmarkNode fields in |model_a| and |model_b|. | 355 // Does a deep comparison of BookmarkNode fields in |model_a| and |model_b|. | 
| 356 // Returns true if they are all equal. | 356 // Returns true if they are all equal. | 
| 357 bool NodesMatch(const BookmarkNode* node_a, const BookmarkNode* node_b) { | 357 bool NodesMatch(const BookmarkNode* node_a, const BookmarkNode* node_b) { | 
| 358   if (node_a == NULL || node_b == NULL) | 358   if (node_a == nullptr || node_b == nullptr) | 
| 359     return node_a == node_b; | 359     return node_a == node_b; | 
| 360   if (node_a->is_folder() != node_b->is_folder()) { | 360   if (node_a->is_folder() != node_b->is_folder()) { | 
| 361     LOG(ERROR) << "Cannot compare folder with bookmark"; | 361     LOG(ERROR) << "Cannot compare folder with bookmark"; | 
| 362     return false; | 362     return false; | 
| 363   } | 363   } | 
| 364   if (node_a->GetTitle() != node_b->GetTitle()) { | 364   if (node_a->GetTitle() != node_b->GetTitle()) { | 
| 365     LOG(ERROR) << "Title mismatch: " << node_a->GetTitle() << " vs. " | 365     LOG(ERROR) << "Title mismatch: " << node_a->GetTitle() << " vs. " | 
| 366                << node_b->GetTitle(); | 366                << node_b->GetTitle(); | 
| 367     return false; | 367     return false; | 
| 368   } | 368   } | 
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 489 | 489 | 
| 490 const BookmarkNode* AddURL(int profile, | 490 const BookmarkNode* AddURL(int profile, | 
| 491                            const BookmarkNode* parent, | 491                            const BookmarkNode* parent, | 
| 492                            int index, | 492                            int index, | 
| 493                            const std::string& title, | 493                            const std::string& title, | 
| 494                            const GURL& url) { | 494                            const GURL& url) { | 
| 495   BookmarkModel* model = GetBookmarkModel(profile); | 495   BookmarkModel* model = GetBookmarkModel(profile); | 
| 496   if (bookmarks::GetBookmarkNodeByID(model, parent->id()) != parent) { | 496   if (bookmarks::GetBookmarkNodeByID(model, parent->id()) != parent) { | 
| 497     LOG(ERROR) << "Node " << parent->GetTitle() << " does not belong to " | 497     LOG(ERROR) << "Node " << parent->GetTitle() << " does not belong to " | 
| 498                << "Profile " << profile; | 498                << "Profile " << profile; | 
| 499     return NULL; | 499     return nullptr; | 
| 500   } | 500   } | 
| 501   const BookmarkNode* result = | 501   const BookmarkNode* result = | 
| 502       model->AddURL(parent, index, base::UTF8ToUTF16(title), url); | 502       model->AddURL(parent, index, base::UTF8ToUTF16(title), url); | 
| 503   if (!result) { | 503   if (!result) { | 
| 504     LOG(ERROR) << "Could not add bookmark " << title << " to Profile " | 504     LOG(ERROR) << "Could not add bookmark " << title << " to Profile " | 
| 505                << profile; | 505                << profile; | 
| 506     return NULL; | 506     return nullptr; | 
| 507   } | 507   } | 
| 508   if (sync_datatype_helper::test()->use_verifier()) { | 508   if (sync_datatype_helper::test()->use_verifier()) { | 
| 509     const BookmarkNode* v_parent = NULL; | 509     const BookmarkNode* v_parent = nullptr; | 
| 510     FindNodeInVerifier(model, parent, &v_parent); | 510     FindNodeInVerifier(model, parent, &v_parent); | 
| 511     const BookmarkNode* v_node = GetVerifierBookmarkModel()->AddURL( | 511     const BookmarkNode* v_node = GetVerifierBookmarkModel()->AddURL( | 
| 512         v_parent, index, base::UTF8ToUTF16(title), url); | 512         v_parent, index, base::UTF8ToUTF16(title), url); | 
| 513     if (!v_node) { | 513     if (!v_node) { | 
| 514       LOG(ERROR) << "Could not add bookmark " << title << " to the verifier"; | 514       LOG(ERROR) << "Could not add bookmark " << title << " to the verifier"; | 
| 515       return NULL; | 515       return nullptr; | 
| 516     } | 516     } | 
| 517     EXPECT_TRUE(NodesMatch(v_node, result)); | 517     EXPECT_TRUE(NodesMatch(v_node, result)); | 
| 518   } | 518   } | 
| 519   return result; | 519   return result; | 
| 520 } | 520 } | 
| 521 | 521 | 
| 522 const BookmarkNode* AddFolder(int profile, | 522 const BookmarkNode* AddFolder(int profile, | 
| 523                               const std::string& title) { | 523                               const std::string& title) { | 
| 524   return AddFolder(profile, GetBookmarkBarNode(profile), 0, title); | 524   return AddFolder(profile, GetBookmarkBarNode(profile), 0, title); | 
| 525 } | 525 } | 
| 526 | 526 | 
| 527 const BookmarkNode* AddFolder(int profile, | 527 const BookmarkNode* AddFolder(int profile, | 
| 528                               int index, | 528                               int index, | 
| 529                               const std::string& title) { | 529                               const std::string& title) { | 
| 530   return AddFolder(profile, GetBookmarkBarNode(profile), index, title); | 530   return AddFolder(profile, GetBookmarkBarNode(profile), index, title); | 
| 531 } | 531 } | 
| 532 | 532 | 
| 533 const BookmarkNode* AddFolder(int profile, | 533 const BookmarkNode* AddFolder(int profile, | 
| 534                               const BookmarkNode* parent, | 534                               const BookmarkNode* parent, | 
| 535                               int index, | 535                               int index, | 
| 536                               const std::string& title) { | 536                               const std::string& title) { | 
| 537   BookmarkModel* model = GetBookmarkModel(profile); | 537   BookmarkModel* model = GetBookmarkModel(profile); | 
| 538   if (bookmarks::GetBookmarkNodeByID(model, parent->id()) != parent) { | 538   if (bookmarks::GetBookmarkNodeByID(model, parent->id()) != parent) { | 
| 539     LOG(ERROR) << "Node " << parent->GetTitle() << " does not belong to " | 539     LOG(ERROR) << "Node " << parent->GetTitle() << " does not belong to " | 
| 540                << "Profile " << profile; | 540                << "Profile " << profile; | 
| 541     return NULL; | 541     return nullptr; | 
| 542   } | 542   } | 
| 543   const BookmarkNode* result = | 543   const BookmarkNode* result = | 
| 544       model->AddFolder(parent, index, base::UTF8ToUTF16(title)); | 544       model->AddFolder(parent, index, base::UTF8ToUTF16(title)); | 
| 545   EXPECT_TRUE(result); | 545   EXPECT_TRUE(result); | 
| 546   if (!result) { | 546   if (!result) { | 
| 547     LOG(ERROR) << "Could not add folder " << title << " to Profile " | 547     LOG(ERROR) << "Could not add folder " << title << " to Profile " | 
| 548                << profile; | 548                << profile; | 
| 549     return NULL; | 549     return nullptr; | 
| 550   } | 550   } | 
| 551   if (sync_datatype_helper::test()->use_verifier()) { | 551   if (sync_datatype_helper::test()->use_verifier()) { | 
| 552     const BookmarkNode* v_parent = NULL; | 552     const BookmarkNode* v_parent = nullptr; | 
| 553     FindNodeInVerifier(model, parent, &v_parent); | 553     FindNodeInVerifier(model, parent, &v_parent); | 
| 554     const BookmarkNode* v_node = GetVerifierBookmarkModel()->AddFolder( | 554     const BookmarkNode* v_node = GetVerifierBookmarkModel()->AddFolder( | 
| 555         v_parent, index, base::UTF8ToUTF16(title)); | 555         v_parent, index, base::UTF8ToUTF16(title)); | 
| 556     if (!v_node) { | 556     if (!v_node) { | 
| 557       LOG(ERROR) << "Could not add folder " << title << " to the verifier"; | 557       LOG(ERROR) << "Could not add folder " << title << " to the verifier"; | 
| 558       return NULL; | 558       return nullptr; | 
| 559     } | 559     } | 
| 560     EXPECT_TRUE(NodesMatch(v_node, result)); | 560     EXPECT_TRUE(NodesMatch(v_node, result)); | 
| 561   } | 561   } | 
| 562   return result; | 562   return result; | 
| 563 } | 563 } | 
| 564 | 564 | 
| 565 void SetTitle(int profile, | 565 void SetTitle(int profile, | 
| 566               const BookmarkNode* node, | 566               const BookmarkNode* node, | 
| 567               const std::string& new_title) { | 567               const std::string& new_title) { | 
| 568   BookmarkModel* model = GetBookmarkModel(profile); | 568   BookmarkModel* model = GetBookmarkModel(profile); | 
| 569   ASSERT_EQ(bookmarks::GetBookmarkNodeByID(model, node->id()), node) | 569   ASSERT_EQ(bookmarks::GetBookmarkNodeByID(model, node->id()), node) | 
| 570       << "Node " << node->GetTitle() << " does not belong to " | 570       << "Node " << node->GetTitle() << " does not belong to " | 
| 571       << "Profile " << profile; | 571       << "Profile " << profile; | 
| 572   if (sync_datatype_helper::test()->use_verifier()) { | 572   if (sync_datatype_helper::test()->use_verifier()) { | 
| 573     const BookmarkNode* v_node = NULL; | 573     const BookmarkNode* v_node = nullptr; | 
| 574     FindNodeInVerifier(model, node, &v_node); | 574     FindNodeInVerifier(model, node, &v_node); | 
| 575     GetVerifierBookmarkModel()->SetTitle(v_node, base::UTF8ToUTF16(new_title)); | 575     GetVerifierBookmarkModel()->SetTitle(v_node, base::UTF8ToUTF16(new_title)); | 
| 576   } | 576   } | 
| 577   model->SetTitle(node, base::UTF8ToUTF16(new_title)); | 577   model->SetTitle(node, base::UTF8ToUTF16(new_title)); | 
| 578 } | 578 } | 
| 579 | 579 | 
| 580 void SetFavicon(int profile, | 580 void SetFavicon(int profile, | 
| 581                 const BookmarkNode* node, | 581                 const BookmarkNode* node, | 
| 582                 const GURL& icon_url, | 582                 const GURL& icon_url, | 
| 583                 const gfx::Image& image, | 583                 const gfx::Image& image, | 
| 584                 FaviconSource favicon_source) { | 584                 FaviconSource favicon_source) { | 
| 585   BookmarkModel* model = GetBookmarkModel(profile); | 585   BookmarkModel* model = GetBookmarkModel(profile); | 
| 586   ASSERT_EQ(bookmarks::GetBookmarkNodeByID(model, node->id()), node) | 586   ASSERT_EQ(bookmarks::GetBookmarkNodeByID(model, node->id()), node) | 
| 587       << "Node " << node->GetTitle() << " does not belong to " | 587       << "Node " << node->GetTitle() << " does not belong to " | 
| 588       << "Profile " << profile; | 588       << "Profile " << profile; | 
| 589   ASSERT_EQ(BookmarkNode::URL, node->type()) << "Node " << node->GetTitle() | 589   ASSERT_EQ(BookmarkNode::URL, node->type()) << "Node " << node->GetTitle() | 
| 590                                              << " must be a url."; | 590                                              << " must be a url."; | 
| 591   if (urls_with_favicons_ == NULL) | 591   if (urls_with_favicons_ == nullptr) | 
| 592     urls_with_favicons_ = new std::set<GURL>(); | 592     urls_with_favicons_ = new std::set<GURL>(); | 
| 593   urls_with_favicons_->insert(node->url()); | 593   urls_with_favicons_->insert(node->url()); | 
| 594   if (sync_datatype_helper::test()->use_verifier()) { | 594   if (sync_datatype_helper::test()->use_verifier()) { | 
| 595     const BookmarkNode* v_node = NULL; | 595     const BookmarkNode* v_node = nullptr; | 
| 596     FindNodeInVerifier(model, node, &v_node); | 596     FindNodeInVerifier(model, node, &v_node); | 
| 597     SetFaviconImpl(sync_datatype_helper::test()->verifier(), | 597     SetFaviconImpl(sync_datatype_helper::test()->verifier(), | 
| 598                    v_node, | 598                    v_node, | 
| 599                    icon_url, | 599                    icon_url, | 
| 600                    image, | 600                    image, | 
| 601                    favicon_source); | 601                    favicon_source); | 
| 602   } | 602   } | 
| 603   SetFaviconImpl(sync_datatype_helper::test()->GetProfile(profile), | 603   SetFaviconImpl(sync_datatype_helper::test()->GetProfile(profile), | 
| 604                  node, | 604                  node, | 
| 605                  icon_url, | 605                  icon_url, | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 642   run_loop.Run(); | 642   run_loop.Run(); | 
| 643 } | 643 } | 
| 644 | 644 | 
| 645 const BookmarkNode* SetURL(int profile, | 645 const BookmarkNode* SetURL(int profile, | 
| 646                            const BookmarkNode* node, | 646                            const BookmarkNode* node, | 
| 647                            const GURL& new_url) { | 647                            const GURL& new_url) { | 
| 648   BookmarkModel* model = GetBookmarkModel(profile); | 648   BookmarkModel* model = GetBookmarkModel(profile); | 
| 649   if (bookmarks::GetBookmarkNodeByID(model, node->id()) != node) { | 649   if (bookmarks::GetBookmarkNodeByID(model, node->id()) != node) { | 
| 650     LOG(ERROR) << "Node " << node->GetTitle() << " does not belong to " | 650     LOG(ERROR) << "Node " << node->GetTitle() << " does not belong to " | 
| 651                << "Profile " << profile; | 651                << "Profile " << profile; | 
| 652     return NULL; | 652     return nullptr; | 
| 653   } | 653   } | 
| 654   if (sync_datatype_helper::test()->use_verifier()) { | 654   if (sync_datatype_helper::test()->use_verifier()) { | 
| 655     const BookmarkNode* v_node = NULL; | 655     const BookmarkNode* v_node = nullptr; | 
| 656     FindNodeInVerifier(model, node, &v_node); | 656     FindNodeInVerifier(model, node, &v_node); | 
| 657     if (v_node->is_url()) | 657     if (v_node->is_url()) | 
| 658       GetVerifierBookmarkModel()->SetURL(v_node, new_url); | 658       GetVerifierBookmarkModel()->SetURL(v_node, new_url); | 
| 659   } | 659   } | 
| 660   if (node->is_url()) | 660   if (node->is_url()) | 
| 661     model->SetURL(node, new_url); | 661     model->SetURL(node, new_url); | 
| 662   return node; | 662   return node; | 
| 663 } | 663 } | 
| 664 | 664 | 
| 665 void Move(int profile, | 665 void Move(int profile, | 
| 666           const BookmarkNode* node, | 666           const BookmarkNode* node, | 
| 667           const BookmarkNode* new_parent, | 667           const BookmarkNode* new_parent, | 
| 668           int index) { | 668           int index) { | 
| 669   BookmarkModel* model = GetBookmarkModel(profile); | 669   BookmarkModel* model = GetBookmarkModel(profile); | 
| 670   ASSERT_EQ(bookmarks::GetBookmarkNodeByID(model, node->id()), node) | 670   ASSERT_EQ(bookmarks::GetBookmarkNodeByID(model, node->id()), node) | 
| 671       << "Node " << node->GetTitle() << " does not belong to " | 671       << "Node " << node->GetTitle() << " does not belong to " | 
| 672       << "Profile " << profile; | 672       << "Profile " << profile; | 
| 673   if (sync_datatype_helper::test()->use_verifier()) { | 673   if (sync_datatype_helper::test()->use_verifier()) { | 
| 674     const BookmarkNode* v_new_parent = NULL; | 674     const BookmarkNode* v_new_parent = nullptr; | 
| 675     const BookmarkNode* v_node = NULL; | 675     const BookmarkNode* v_node = nullptr; | 
| 676     FindNodeInVerifier(model, new_parent, &v_new_parent); | 676     FindNodeInVerifier(model, new_parent, &v_new_parent); | 
| 677     FindNodeInVerifier(model, node, &v_node); | 677     FindNodeInVerifier(model, node, &v_node); | 
| 678     GetVerifierBookmarkModel()->Move(v_node, v_new_parent, index); | 678     GetVerifierBookmarkModel()->Move(v_node, v_new_parent, index); | 
| 679   } | 679   } | 
| 680   model->Move(node, new_parent, index); | 680   model->Move(node, new_parent, index); | 
| 681 } | 681 } | 
| 682 | 682 | 
| 683 void Remove(int profile, const BookmarkNode* parent, int index) { | 683 void Remove(int profile, const BookmarkNode* parent, int index) { | 
| 684   BookmarkModel* model = GetBookmarkModel(profile); | 684   BookmarkModel* model = GetBookmarkModel(profile); | 
| 685   ASSERT_EQ(bookmarks::GetBookmarkNodeByID(model, parent->id()), parent) | 685   ASSERT_EQ(bookmarks::GetBookmarkNodeByID(model, parent->id()), parent) | 
| 686       << "Node " << parent->GetTitle() << " does not belong to " | 686       << "Node " << parent->GetTitle() << " does not belong to " | 
| 687       << "Profile " << profile; | 687       << "Profile " << profile; | 
| 688   if (sync_datatype_helper::test()->use_verifier()) { | 688   if (sync_datatype_helper::test()->use_verifier()) { | 
| 689     const BookmarkNode* v_parent = NULL; | 689     const BookmarkNode* v_parent = nullptr; | 
| 690     FindNodeInVerifier(model, parent, &v_parent); | 690     FindNodeInVerifier(model, parent, &v_parent); | 
| 691     ASSERT_TRUE(NodesMatch(parent->GetChild(index), v_parent->GetChild(index))); | 691     ASSERT_TRUE(NodesMatch(parent->GetChild(index), v_parent->GetChild(index))); | 
| 692     GetVerifierBookmarkModel()->Remove(v_parent->GetChild(index)); | 692     GetVerifierBookmarkModel()->Remove(v_parent->GetChild(index)); | 
| 693   } | 693   } | 
| 694   model->Remove(parent->GetChild(index)); | 694   model->Remove(parent->GetChild(index)); | 
| 695 } | 695 } | 
| 696 | 696 | 
| 697 void RemoveAll(int profile) { | 697 void RemoveAll(int profile) { | 
| 698   if (sync_datatype_helper::test()->use_verifier()) { | 698   if (sync_datatype_helper::test()->use_verifier()) { | 
| 699     const BookmarkNode* root_node = GetVerifierBookmarkModel()->root_node(); | 699     const BookmarkNode* root_node = GetVerifierBookmarkModel()->root_node(); | 
| 700     for (int i = 0; i < root_node->child_count(); ++i) { | 700     for (int i = 0; i < root_node->child_count(); ++i) { | 
| 701       const BookmarkNode* permanent_node = root_node->GetChild(i); | 701       const BookmarkNode* permanent_node = root_node->GetChild(i); | 
| 702       for (int j = permanent_node->child_count() - 1; j >= 0; --j) { | 702       for (int j = permanent_node->child_count() - 1; j >= 0; --j) { | 
| 703         GetVerifierBookmarkModel()->Remove(permanent_node->GetChild(j)); | 703         GetVerifierBookmarkModel()->Remove(permanent_node->GetChild(j)); | 
| 704       } | 704       } | 
| 705     } | 705     } | 
| 706   } | 706   } | 
| 707   GetBookmarkModel(profile)->RemoveAllUserBookmarks(); | 707   GetBookmarkModel(profile)->RemoveAllUserBookmarks(); | 
| 708 } | 708 } | 
| 709 | 709 | 
| 710 void SortChildren(int profile, const BookmarkNode* parent) { | 710 void SortChildren(int profile, const BookmarkNode* parent) { | 
| 711   BookmarkModel* model = GetBookmarkModel(profile); | 711   BookmarkModel* model = GetBookmarkModel(profile); | 
| 712   ASSERT_EQ(bookmarks::GetBookmarkNodeByID(model, parent->id()), parent) | 712   ASSERT_EQ(bookmarks::GetBookmarkNodeByID(model, parent->id()), parent) | 
| 713       << "Node " << parent->GetTitle() << " does not belong to " | 713       << "Node " << parent->GetTitle() << " does not belong to " | 
| 714       << "Profile " << profile; | 714       << "Profile " << profile; | 
| 715   if (sync_datatype_helper::test()->use_verifier()) { | 715   if (sync_datatype_helper::test()->use_verifier()) { | 
| 716     const BookmarkNode* v_parent = NULL; | 716     const BookmarkNode* v_parent = nullptr; | 
| 717     FindNodeInVerifier(model, parent, &v_parent); | 717     FindNodeInVerifier(model, parent, &v_parent); | 
| 718     GetVerifierBookmarkModel()->SortChildren(v_parent); | 718     GetVerifierBookmarkModel()->SortChildren(v_parent); | 
| 719   } | 719   } | 
| 720   model->SortChildren(parent); | 720   model->SortChildren(parent); | 
| 721 } | 721 } | 
| 722 | 722 | 
| 723 void ReverseChildOrder(int profile, const BookmarkNode* parent) { | 723 void ReverseChildOrder(int profile, const BookmarkNode* parent) { | 
| 724   ASSERT_EQ( | 724   ASSERT_EQ( | 
| 725       bookmarks::GetBookmarkNodeByID(GetBookmarkModel(profile), parent->id()), | 725       bookmarks::GetBookmarkNodeByID(GetBookmarkModel(profile), parent->id()), | 
| 726       parent) | 726       parent) | 
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 805   std::vector<const BookmarkNode*> nodes; | 805   std::vector<const BookmarkNode*> nodes; | 
| 806   GetBookmarkModel(profile)->GetNodesByURL(url, &nodes); | 806   GetBookmarkModel(profile)->GetNodesByURL(url, &nodes); | 
| 807   return !nodes.empty(); | 807   return !nodes.empty(); | 
| 808 } | 808 } | 
| 809 | 809 | 
| 810 const BookmarkNode* GetUniqueNodeByURL(int profile, const GURL& url) { | 810 const BookmarkNode* GetUniqueNodeByURL(int profile, const GURL& url) { | 
| 811   std::vector<const BookmarkNode*> nodes; | 811   std::vector<const BookmarkNode*> nodes; | 
| 812   GetBookmarkModel(profile)->GetNodesByURL(url, &nodes); | 812   GetBookmarkModel(profile)->GetNodesByURL(url, &nodes); | 
| 813   EXPECT_EQ(1U, nodes.size()); | 813   EXPECT_EQ(1U, nodes.size()); | 
| 814   if (nodes.empty()) | 814   if (nodes.empty()) | 
| 815     return NULL; | 815     return nullptr; | 
| 816   return nodes[0]; | 816   return nodes[0]; | 
| 817 } | 817 } | 
| 818 | 818 | 
| 819 int CountAllBookmarks(int profile) { | 819 int CountAllBookmarks(int profile) { | 
| 820   return CountNodes(GetBookmarkModel(profile), BookmarkNode::URL); | 820   return CountNodes(GetBookmarkModel(profile), BookmarkNode::URL); | 
| 821 } | 821 } | 
| 822 | 822 | 
| 823 int CountBookmarksWithTitlesMatching(int profile, const std::string& title) { | 823 int CountBookmarksWithTitlesMatching(int profile, const std::string& title) { | 
| 824   return CountNodesWithTitlesMatching(GetBookmarkModel(profile), | 824   return CountNodesWithTitlesMatching(GetBookmarkModel(profile), | 
| 825                                       BookmarkNode::URL, | 825                                       BookmarkNode::URL, | 
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 945 }  // namespace | 945 }  // namespace | 
| 946 | 946 | 
| 947 BookmarksUrlChecker::BookmarksUrlChecker(int profile, | 947 BookmarksUrlChecker::BookmarksUrlChecker(int profile, | 
| 948                                          const GURL& url, | 948                                          const GURL& url, | 
| 949                                          int expected_count) | 949                                          int expected_count) | 
| 950     : AwaitMatchStatusChangeChecker(base::Bind(BookmarkCountsByUrlMatch, | 950     : AwaitMatchStatusChangeChecker(base::Bind(BookmarkCountsByUrlMatch, | 
| 951                                                profile, | 951                                                profile, | 
| 952                                                base::ConstRef(url), | 952                                                base::ConstRef(url), | 
| 953                                                expected_count), | 953                                                expected_count), | 
| 954                                     "Bookmark URL counts match.") {} | 954                                     "Bookmark URL counts match.") {} | 
| OLD | NEW | 
|---|