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

Side by Side Diff: chrome/browser/sync/test/integration/bookmarks_helper.cc

Issue 12315071: Revert 184352 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 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 | 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 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" 5 #include "chrome/browser/sync/test/integration/bookmarks_helper.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 const BookmarkNode* parent, 419 const BookmarkNode* parent,
420 int index, 420 int index,
421 const std::wstring& title, 421 const std::wstring& title,
422 const GURL& url) { 422 const GURL& url) {
423 if (GetBookmarkModel(profile)->GetNodeByID(parent->id()) != parent) { 423 if (GetBookmarkModel(profile)->GetNodeByID(parent->id()) != parent) {
424 LOG(ERROR) << "Node " << parent->GetTitle() << " does not belong to " 424 LOG(ERROR) << "Node " << parent->GetTitle() << " does not belong to "
425 << "Profile " << profile; 425 << "Profile " << profile;
426 return NULL; 426 return NULL;
427 } 427 }
428 const BookmarkNode* result = GetBookmarkModel(profile)-> 428 const BookmarkNode* result = GetBookmarkModel(profile)->
429 AddURL(parent, index, base::WideToUTF16(title), url); 429 AddURL(parent, index, WideToUTF16(title), url);
430 if (!result) { 430 if (!result) {
431 LOG(ERROR) << "Could not add bookmark " << title << " to Profile " 431 LOG(ERROR) << "Could not add bookmark " << title << " to Profile "
432 << profile; 432 << profile;
433 return NULL; 433 return NULL;
434 } 434 }
435 if (test()->use_verifier()) { 435 if (test()->use_verifier()) {
436 const BookmarkNode* v_parent = NULL; 436 const BookmarkNode* v_parent = NULL;
437 FindNodeInVerifier(GetBookmarkModel(profile), parent, &v_parent); 437 FindNodeInVerifier(GetBookmarkModel(profile), parent, &v_parent);
438 const BookmarkNode* v_node = GetVerifierBookmarkModel()-> 438 const BookmarkNode* v_node = GetVerifierBookmarkModel()->
439 AddURL(v_parent, index, base::WideToUTF16(title), url); 439 AddURL(v_parent, index, WideToUTF16(title), url);
440 if (!v_node) { 440 if (!v_node) {
441 LOG(ERROR) << "Could not add bookmark " << title << " to the verifier"; 441 LOG(ERROR) << "Could not add bookmark " << title << " to the verifier";
442 return NULL; 442 return NULL;
443 } 443 }
444 EXPECT_TRUE(NodesMatch(v_node, result)); 444 EXPECT_TRUE(NodesMatch(v_node, result));
445 } 445 }
446 return result; 446 return result;
447 } 447 }
448 448
449 const BookmarkNode* AddFolder(int profile, 449 const BookmarkNode* AddFolder(int profile,
(...skipping 10 matching lines...) Expand all
460 const BookmarkNode* AddFolder(int profile, 460 const BookmarkNode* AddFolder(int profile,
461 const BookmarkNode* parent, 461 const BookmarkNode* parent,
462 int index, 462 int index,
463 const std::wstring& title) { 463 const std::wstring& title) {
464 if (GetBookmarkModel(profile)->GetNodeByID(parent->id()) != parent) { 464 if (GetBookmarkModel(profile)->GetNodeByID(parent->id()) != parent) {
465 LOG(ERROR) << "Node " << parent->GetTitle() << " does not belong to " 465 LOG(ERROR) << "Node " << parent->GetTitle() << " does not belong to "
466 << "Profile " << profile; 466 << "Profile " << profile;
467 return NULL; 467 return NULL;
468 } 468 }
469 const BookmarkNode* result = 469 const BookmarkNode* result =
470 GetBookmarkModel(profile)->AddFolder(parent, index, 470 GetBookmarkModel(profile)->AddFolder(parent, index, WideToUTF16(title));
471 base::WideToUTF16(title));
472 EXPECT_TRUE(result); 471 EXPECT_TRUE(result);
473 if (!result) { 472 if (!result) {
474 LOG(ERROR) << "Could not add folder " << title << " to Profile " 473 LOG(ERROR) << "Could not add folder " << title << " to Profile "
475 << profile; 474 << profile;
476 return NULL; 475 return NULL;
477 } 476 }
478 if (test()->use_verifier()) { 477 if (test()->use_verifier()) {
479 const BookmarkNode* v_parent = NULL; 478 const BookmarkNode* v_parent = NULL;
480 FindNodeInVerifier(GetBookmarkModel(profile), parent, &v_parent); 479 FindNodeInVerifier(GetBookmarkModel(profile), parent, &v_parent);
481 const BookmarkNode* v_node = GetVerifierBookmarkModel()->AddFolder( 480 const BookmarkNode* v_node = GetVerifierBookmarkModel()->AddFolder(
482 v_parent, index, base::WideToUTF16(title)); 481 v_parent, index, WideToUTF16(title));
483 if (!v_node) { 482 if (!v_node) {
484 LOG(ERROR) << "Could not add folder " << title << " to the verifier"; 483 LOG(ERROR) << "Could not add folder " << title << " to the verifier";
485 return NULL; 484 return NULL;
486 } 485 }
487 EXPECT_TRUE(NodesMatch(v_node, result)); 486 EXPECT_TRUE(NodesMatch(v_node, result));
488 } 487 }
489 return result; 488 return result;
490 } 489 }
491 490
492 void SetTitle(int profile, 491 void SetTitle(int profile,
493 const BookmarkNode* node, 492 const BookmarkNode* node,
494 const std::wstring& new_title) { 493 const std::wstring& new_title) {
495 ASSERT_EQ(GetBookmarkModel(profile)->GetNodeByID(node->id()), node) 494 ASSERT_EQ(GetBookmarkModel(profile)->GetNodeByID(node->id()), node)
496 << "Node " << node->GetTitle() << " does not belong to " 495 << "Node " << node->GetTitle() << " does not belong to "
497 << "Profile " << profile; 496 << "Profile " << profile;
498 if (test()->use_verifier()) { 497 if (test()->use_verifier()) {
499 const BookmarkNode* v_node = NULL; 498 const BookmarkNode* v_node = NULL;
500 FindNodeInVerifier(GetBookmarkModel(profile), node, &v_node); 499 FindNodeInVerifier(GetBookmarkModel(profile), node, &v_node);
501 GetVerifierBookmarkModel()->SetTitle(v_node, base::WideToUTF16(new_title)); 500 GetVerifierBookmarkModel()->SetTitle(v_node, WideToUTF16(new_title));
502 } 501 }
503 GetBookmarkModel(profile)->SetTitle(node, base::WideToUTF16(new_title)); 502 GetBookmarkModel(profile)->SetTitle(node, WideToUTF16(new_title));
504 } 503 }
505 504
506 void SetFavicon(int profile, 505 void SetFavicon(int profile,
507 const BookmarkNode* node, 506 const BookmarkNode* node,
508 const GURL& icon_url, 507 const GURL& icon_url,
509 const gfx::Image& image, 508 const gfx::Image& image,
510 FaviconSource favicon_source) { 509 FaviconSource favicon_source) {
511 ASSERT_EQ(GetBookmarkModel(profile)->GetNodeByID(node->id()), node) 510 ASSERT_EQ(GetBookmarkModel(profile)->GetNodeByID(node->id()), node)
512 << "Node " << node->GetTitle() << " does not belong to " 511 << "Node " << node->GetTitle() << " does not belong to "
513 << "Profile " << profile; 512 << "Profile " << profile;
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 GetBookmarkModel(profile)->GetNodesByURL(url, &nodes); 684 GetBookmarkModel(profile)->GetNodesByURL(url, &nodes);
686 EXPECT_EQ(1U, nodes.size()); 685 EXPECT_EQ(1U, nodes.size());
687 if (nodes.empty()) 686 if (nodes.empty())
688 return NULL; 687 return NULL;
689 return nodes[0]; 688 return nodes[0];
690 } 689 }
691 690
692 int CountBookmarksWithTitlesMatching(int profile, const std::wstring& title) { 691 int CountBookmarksWithTitlesMatching(int profile, const std::wstring& title) {
693 return CountNodesWithTitlesMatching(GetBookmarkModel(profile), 692 return CountNodesWithTitlesMatching(GetBookmarkModel(profile),
694 BookmarkNode::URL, 693 BookmarkNode::URL,
695 base::WideToUTF16(title)); 694 WideToUTF16(title));
696 } 695 }
697 696
698 int CountFoldersWithTitlesMatching(int profile, const std::wstring& title) { 697 int CountFoldersWithTitlesMatching(int profile, const std::wstring& title) {
699 return CountNodesWithTitlesMatching(GetBookmarkModel(profile), 698 return CountNodesWithTitlesMatching(GetBookmarkModel(profile),
700 BookmarkNode::FOLDER, 699 BookmarkNode::FOLDER,
701 base::WideToUTF16(title)); 700 WideToUTF16(title));
702 } 701 }
703 702
704 gfx::Image CreateFavicon(SkColor color) { 703 gfx::Image CreateFavicon(SkColor color) {
705 const int dip_width = 16; 704 const int dip_width = 16;
706 const int dip_height = 16; 705 const int dip_height = 16;
707 std::vector<ui::ScaleFactor> favicon_scale_factors = 706 std::vector<ui::ScaleFactor> favicon_scale_factors =
708 FaviconUtil::GetFaviconScaleFactors(); 707 FaviconUtil::GetFaviconScaleFactors();
709 gfx::ImageSkia favicon; 708 gfx::ImageSkia favicon;
710 for (size_t i = 0; i < favicon_scale_factors.size(); ++i) { 709 for (size_t i = 0; i < favicon_scale_factors.size(); ++i) {
711 float scale = ui::GetScaleFactorScale(favicon_scale_factors[i]); 710 float scale = ui::GetScaleFactorScale(favicon_scale_factors[i]);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 749
751 std::wstring IndexedSubfolderName(int i) { 750 std::wstring IndexedSubfolderName(int i) {
752 return StringPrintf(L"Subfolder Name %d", i); 751 return StringPrintf(L"Subfolder Name %d", i);
753 } 752 }
754 753
755 std::wstring IndexedSubsubfolderName(int i) { 754 std::wstring IndexedSubsubfolderName(int i) {
756 return StringPrintf(L"Subsubfolder Name %d", i); 755 return StringPrintf(L"Subsubfolder Name %d", i);
757 } 756 }
758 757
759 } // namespace bookmarks_helper 758 } // namespace bookmarks_helper
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698