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

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

Issue 242693003: Introduce BookmarkClient interface to abstract embedder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Work around STL android bug Created 6 years, 8 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
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 17 matching lines...) Expand all
28 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" 28 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
29 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" 29 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
30 #include "chrome/browser/sync/test/integration/sync_test.h" 30 #include "chrome/browser/sync/test/integration/sync_test.h"
31 #include "chrome/common/chrome_paths.h" 31 #include "chrome/common/chrome_paths.h"
32 #include "chrome/test/base/ui_test_utils.h" 32 #include "chrome/test/base/ui_test_utils.h"
33 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
34 #include "third_party/skia/include/core/SkBitmap.h" 34 #include "third_party/skia/include/core/SkBitmap.h"
35 #include "ui/base/models/tree_node_iterator.h" 35 #include "ui/base/models/tree_node_iterator.h"
36 #include "ui/gfx/image/image_skia.h" 36 #include "ui/gfx/image/image_skia.h"
37 37
38 using sync_datatype_helper::test;
39
40 namespace { 38 namespace {
41 39
42 // History task which runs all pending tasks on the history thread and 40 // History task which runs all pending tasks on the history thread and
43 // signals when the tasks have completed. 41 // signals when the tasks have completed.
44 class HistoryEmptyTask : public history::HistoryDBTask { 42 class HistoryEmptyTask : public history::HistoryDBTask {
45 public: 43 public:
46 explicit HistoryEmptyTask(base::WaitableEvent* done) : done_(done) {} 44 explicit HistoryEmptyTask(base::WaitableEvent* done) : done_(done) {}
47 45
48 virtual bool RunOnDBThread(history::HistoryBackend* backend, 46 virtual bool RunOnDBThread(history::HistoryBackend* backend,
49 history::HistoryDatabase* db) OVERRIDE { 47 history::HistoryDatabase* db) OVERRIDE {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 241
244 // Wait for all currently scheduled tasks on the history thread for all 242 // Wait for all currently scheduled tasks on the history thread for all
245 // profiles to complete and any notifications sent to the UI thread to have 243 // profiles to complete and any notifications sent to the UI thread to have
246 // finished processing. 244 // finished processing.
247 void WaitForHistoryToProcessPendingTasks() { 245 void WaitForHistoryToProcessPendingTasks() {
248 // Skip waiting for history to complete for tests without favicons. 246 // Skip waiting for history to complete for tests without favicons.
249 if (!urls_with_favicons_) 247 if (!urls_with_favicons_)
250 return; 248 return;
251 249
252 std::vector<Profile*> profiles_which_need_to_wait; 250 std::vector<Profile*> profiles_which_need_to_wait;
253 if (test()->use_verifier()) 251 if (sync_datatype_helper::test()->use_verifier())
254 profiles_which_need_to_wait.push_back(test()->verifier()); 252 profiles_which_need_to_wait.push_back(
255 for (int i = 0; i < test()->num_clients(); ++i) 253 sync_datatype_helper::test()->verifier());
256 profiles_which_need_to_wait.push_back(test()->GetProfile(i)); 254 for (int i = 0; i < sync_datatype_helper::test()->num_clients(); ++i)
255 profiles_which_need_to_wait.push_back(
256 sync_datatype_helper::test()->GetProfile(i));
257 257
258 for (size_t i = 0; i < profiles_which_need_to_wait.size(); ++i) { 258 for (size_t i = 0; i < profiles_which_need_to_wait.size(); ++i) {
259 Profile* profile = profiles_which_need_to_wait[i]; 259 Profile* profile = profiles_which_need_to_wait[i];
260 HistoryService* history_service = 260 HistoryService* history_service =
261 HistoryServiceFactory::GetForProfileWithoutCreating(profile); 261 HistoryServiceFactory::GetForProfileWithoutCreating(profile);
262 base::WaitableEvent done(false, false); 262 base::WaitableEvent done(false, false);
263 CancelableRequestConsumer request_consumer; 263 CancelableRequestConsumer request_consumer;
264 history_service->ScheduleDBTask(new HistoryEmptyTask(&done), 264 history_service->ScheduleDBTask(new HistoryEmptyTask(&done),
265 &request_consumer); 265 &request_consumer);
266 done.Wait(); 266 done.Wait();
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 ASSERT_TRUE(NodesMatch(foreign_node, walker)); 378 ASSERT_TRUE(NodesMatch(foreign_node, walker));
379 *result = walker; 379 *result = walker;
380 } 380 }
381 381
382 } // namespace 382 } // namespace
383 383
384 384
385 namespace bookmarks_helper { 385 namespace bookmarks_helper {
386 386
387 BookmarkModel* GetBookmarkModel(int index) { 387 BookmarkModel* GetBookmarkModel(int index) {
388 return BookmarkModelFactory::GetForProfile(test()->GetProfile(index)); 388 return BookmarkModelFactory::GetForProfile(
389 sync_datatype_helper::test()->GetProfile(index));
389 } 390 }
390 391
391 const BookmarkNode* GetBookmarkBarNode(int index) { 392 const BookmarkNode* GetBookmarkBarNode(int index) {
392 return GetBookmarkModel(index)->bookmark_bar_node(); 393 return GetBookmarkModel(index)->bookmark_bar_node();
393 } 394 }
394 395
395 const BookmarkNode* GetOtherNode(int index) { 396 const BookmarkNode* GetOtherNode(int index) {
396 return GetBookmarkModel(index)->other_node(); 397 return GetBookmarkModel(index)->other_node();
397 } 398 }
398 399
399 const BookmarkNode* GetSyncedBookmarksNode(int index) { 400 const BookmarkNode* GetSyncedBookmarksNode(int index) {
400 return GetBookmarkModel(index)->mobile_node(); 401 return GetBookmarkModel(index)->mobile_node();
401 } 402 }
402 403
403 BookmarkModel* GetVerifierBookmarkModel() { 404 BookmarkModel* GetVerifierBookmarkModel() {
404 return BookmarkModelFactory::GetForProfile(test()->verifier()); 405 return BookmarkModelFactory::GetForProfile(
406 sync_datatype_helper::test()->verifier());
405 } 407 }
406 408
407 const BookmarkNode* AddURL(int profile, 409 const BookmarkNode* AddURL(int profile,
408 const std::wstring& title, 410 const std::wstring& title,
409 const GURL& url) { 411 const GURL& url) {
410 return AddURL(profile, GetBookmarkBarNode(profile), 0, title, url); 412 return AddURL(profile, GetBookmarkBarNode(profile), 0, title, url);
411 } 413 }
412 414
413 const BookmarkNode* AddURL(int profile, 415 const BookmarkNode* AddURL(int profile,
414 int index, 416 int index,
(...skipping 13 matching lines...) Expand all
428 << "Profile " << profile; 430 << "Profile " << profile;
429 return NULL; 431 return NULL;
430 } 432 }
431 const BookmarkNode* result = 433 const BookmarkNode* result =
432 model->AddURL(parent, index, base::WideToUTF16(title), url); 434 model->AddURL(parent, index, base::WideToUTF16(title), url);
433 if (!result) { 435 if (!result) {
434 LOG(ERROR) << "Could not add bookmark " << title << " to Profile " 436 LOG(ERROR) << "Could not add bookmark " << title << " to Profile "
435 << profile; 437 << profile;
436 return NULL; 438 return NULL;
437 } 439 }
438 if (test()->use_verifier()) { 440 if (sync_datatype_helper::test()->use_verifier()) {
439 const BookmarkNode* v_parent = NULL; 441 const BookmarkNode* v_parent = NULL;
440 FindNodeInVerifier(model, parent, &v_parent); 442 FindNodeInVerifier(model, parent, &v_parent);
441 const BookmarkNode* v_node = GetVerifierBookmarkModel()->AddURL( 443 const BookmarkNode* v_node = GetVerifierBookmarkModel()->AddURL(
442 v_parent, index, base::WideToUTF16(title), url); 444 v_parent, index, base::WideToUTF16(title), url);
443 if (!v_node) { 445 if (!v_node) {
444 LOG(ERROR) << "Could not add bookmark " << title << " to the verifier"; 446 LOG(ERROR) << "Could not add bookmark " << title << " to the verifier";
445 return NULL; 447 return NULL;
446 } 448 }
447 EXPECT_TRUE(NodesMatch(v_node, result)); 449 EXPECT_TRUE(NodesMatch(v_node, result));
448 } 450 }
(...skipping 22 matching lines...) Expand all
471 return NULL; 473 return NULL;
472 } 474 }
473 const BookmarkNode* result = 475 const BookmarkNode* result =
474 model->AddFolder(parent, index, base::WideToUTF16(title)); 476 model->AddFolder(parent, index, base::WideToUTF16(title));
475 EXPECT_TRUE(result); 477 EXPECT_TRUE(result);
476 if (!result) { 478 if (!result) {
477 LOG(ERROR) << "Could not add folder " << title << " to Profile " 479 LOG(ERROR) << "Could not add folder " << title << " to Profile "
478 << profile; 480 << profile;
479 return NULL; 481 return NULL;
480 } 482 }
481 if (test()->use_verifier()) { 483 if (sync_datatype_helper::test()->use_verifier()) {
482 const BookmarkNode* v_parent = NULL; 484 const BookmarkNode* v_parent = NULL;
483 FindNodeInVerifier(model, parent, &v_parent); 485 FindNodeInVerifier(model, parent, &v_parent);
484 const BookmarkNode* v_node = GetVerifierBookmarkModel()->AddFolder( 486 const BookmarkNode* v_node = GetVerifierBookmarkModel()->AddFolder(
485 v_parent, index, base::WideToUTF16(title)); 487 v_parent, index, base::WideToUTF16(title));
486 if (!v_node) { 488 if (!v_node) {
487 LOG(ERROR) << "Could not add folder " << title << " to the verifier"; 489 LOG(ERROR) << "Could not add folder " << title << " to the verifier";
488 return NULL; 490 return NULL;
489 } 491 }
490 EXPECT_TRUE(NodesMatch(v_node, result)); 492 EXPECT_TRUE(NodesMatch(v_node, result));
491 } 493 }
492 return result; 494 return result;
493 } 495 }
494 496
495 void SetTitle(int profile, 497 void SetTitle(int profile,
496 const BookmarkNode* node, 498 const BookmarkNode* node,
497 const std::wstring& new_title) { 499 const std::wstring& new_title) {
498 BookmarkModel* model = GetBookmarkModel(profile); 500 BookmarkModel* model = GetBookmarkModel(profile);
499 ASSERT_EQ(GetBookmarkNodeByID(model, node->id()), node) 501 ASSERT_EQ(GetBookmarkNodeByID(model, node->id()), node)
500 << "Node " << node->GetTitle() << " does not belong to " 502 << "Node " << node->GetTitle() << " does not belong to "
501 << "Profile " << profile; 503 << "Profile " << profile;
502 if (test()->use_verifier()) { 504 if (sync_datatype_helper::test()->use_verifier()) {
503 const BookmarkNode* v_node = NULL; 505 const BookmarkNode* v_node = NULL;
504 FindNodeInVerifier(model, node, &v_node); 506 FindNodeInVerifier(model, node, &v_node);
505 GetVerifierBookmarkModel()->SetTitle(v_node, base::WideToUTF16(new_title)); 507 GetVerifierBookmarkModel()->SetTitle(v_node, base::WideToUTF16(new_title));
506 } 508 }
507 model->SetTitle(node, base::WideToUTF16(new_title)); 509 model->SetTitle(node, base::WideToUTF16(new_title));
508 } 510 }
509 511
510 void SetFavicon(int profile, 512 void SetFavicon(int profile,
511 const BookmarkNode* node, 513 const BookmarkNode* node,
512 const GURL& icon_url, 514 const GURL& icon_url,
513 const gfx::Image& image, 515 const gfx::Image& image,
514 FaviconSource favicon_source) { 516 FaviconSource favicon_source) {
515 BookmarkModel* model = GetBookmarkModel(profile); 517 BookmarkModel* model = GetBookmarkModel(profile);
516 ASSERT_EQ(GetBookmarkNodeByID(model, node->id()), node) 518 ASSERT_EQ(GetBookmarkNodeByID(model, node->id()), node)
517 << "Node " << node->GetTitle() << " does not belong to " 519 << "Node " << node->GetTitle() << " does not belong to "
518 << "Profile " << profile; 520 << "Profile " << profile;
519 ASSERT_EQ(BookmarkNode::URL, node->type()) << "Node " << node->GetTitle() 521 ASSERT_EQ(BookmarkNode::URL, node->type()) << "Node " << node->GetTitle()
520 << " must be a url."; 522 << " must be a url.";
521 if (urls_with_favicons_ == NULL) 523 if (urls_with_favicons_ == NULL)
522 urls_with_favicons_ = new std::set<GURL>(); 524 urls_with_favicons_ = new std::set<GURL>();
523 urls_with_favicons_->insert(node->url()); 525 urls_with_favicons_->insert(node->url());
524 if (test()->use_verifier()) { 526 if (sync_datatype_helper::test()->use_verifier()) {
525 const BookmarkNode* v_node = NULL; 527 const BookmarkNode* v_node = NULL;
526 FindNodeInVerifier(model, node, &v_node); 528 FindNodeInVerifier(model, node, &v_node);
527 SetFaviconImpl(test()->verifier(), v_node, icon_url, image, favicon_source); 529 SetFaviconImpl(sync_datatype_helper::test()->verifier(),
530 v_node,
531 icon_url,
532 image,
533 favicon_source);
528 } 534 }
529 SetFaviconImpl(test()->GetProfile(profile), node, icon_url, image, 535 SetFaviconImpl(sync_datatype_helper::test()->GetProfile(profile),
536 node,
537 icon_url,
538 image,
530 favicon_source); 539 favicon_source);
531 } 540 }
532 541
533 const BookmarkNode* SetURL(int profile, 542 const BookmarkNode* SetURL(int profile,
534 const BookmarkNode* node, 543 const BookmarkNode* node,
535 const GURL& new_url) { 544 const GURL& new_url) {
536 BookmarkModel* model = GetBookmarkModel(profile); 545 BookmarkModel* model = GetBookmarkModel(profile);
537 if (GetBookmarkNodeByID(model, node->id()) != node) { 546 if (GetBookmarkNodeByID(model, node->id()) != node) {
538 LOG(ERROR) << "Node " << node->GetTitle() << " does not belong to " 547 LOG(ERROR) << "Node " << node->GetTitle() << " does not belong to "
539 << "Profile " << profile; 548 << "Profile " << profile;
540 return NULL; 549 return NULL;
541 } 550 }
542 if (test()->use_verifier()) { 551 if (sync_datatype_helper::test()->use_verifier()) {
543 const BookmarkNode* v_node = NULL; 552 const BookmarkNode* v_node = NULL;
544 FindNodeInVerifier(model, node, &v_node); 553 FindNodeInVerifier(model, node, &v_node);
545 if (v_node->is_url()) 554 if (v_node->is_url())
546 GetVerifierBookmarkModel()->SetURL(v_node, new_url); 555 GetVerifierBookmarkModel()->SetURL(v_node, new_url);
547 } 556 }
548 if (node->is_url()) 557 if (node->is_url())
549 model->SetURL(node, new_url); 558 model->SetURL(node, new_url);
550 return node; 559 return node;
551 } 560 }
552 561
553 void Move(int profile, 562 void Move(int profile,
554 const BookmarkNode* node, 563 const BookmarkNode* node,
555 const BookmarkNode* new_parent, 564 const BookmarkNode* new_parent,
556 int index) { 565 int index) {
557 BookmarkModel* model = GetBookmarkModel(profile); 566 BookmarkModel* model = GetBookmarkModel(profile);
558 ASSERT_EQ(GetBookmarkNodeByID(model, node->id()), node) 567 ASSERT_EQ(GetBookmarkNodeByID(model, node->id()), node)
559 << "Node " << node->GetTitle() << " does not belong to " 568 << "Node " << node->GetTitle() << " does not belong to "
560 << "Profile " << profile; 569 << "Profile " << profile;
561 if (test()->use_verifier()) { 570 if (sync_datatype_helper::test()->use_verifier()) {
562 const BookmarkNode* v_new_parent = NULL; 571 const BookmarkNode* v_new_parent = NULL;
563 const BookmarkNode* v_node = NULL; 572 const BookmarkNode* v_node = NULL;
564 FindNodeInVerifier(model, new_parent, &v_new_parent); 573 FindNodeInVerifier(model, new_parent, &v_new_parent);
565 FindNodeInVerifier(model, node, &v_node); 574 FindNodeInVerifier(model, node, &v_node);
566 GetVerifierBookmarkModel()->Move(v_node, v_new_parent, index); 575 GetVerifierBookmarkModel()->Move(v_node, v_new_parent, index);
567 } 576 }
568 model->Move(node, new_parent, index); 577 model->Move(node, new_parent, index);
569 } 578 }
570 579
571 void Remove(int profile, const BookmarkNode* parent, int index) { 580 void Remove(int profile, const BookmarkNode* parent, int index) {
572 BookmarkModel* model = GetBookmarkModel(profile); 581 BookmarkModel* model = GetBookmarkModel(profile);
573 ASSERT_EQ(GetBookmarkNodeByID(model, parent->id()), parent) 582 ASSERT_EQ(GetBookmarkNodeByID(model, parent->id()), parent)
574 << "Node " << parent->GetTitle() << " does not belong to " 583 << "Node " << parent->GetTitle() << " does not belong to "
575 << "Profile " << profile; 584 << "Profile " << profile;
576 if (test()->use_verifier()) { 585 if (sync_datatype_helper::test()->use_verifier()) {
577 const BookmarkNode* v_parent = NULL; 586 const BookmarkNode* v_parent = NULL;
578 FindNodeInVerifier(model, parent, &v_parent); 587 FindNodeInVerifier(model, parent, &v_parent);
579 ASSERT_TRUE(NodesMatch(parent->GetChild(index), v_parent->GetChild(index))); 588 ASSERT_TRUE(NodesMatch(parent->GetChild(index), v_parent->GetChild(index)));
580 GetVerifierBookmarkModel()->Remove(v_parent, index); 589 GetVerifierBookmarkModel()->Remove(v_parent, index);
581 } 590 }
582 model->Remove(parent, index); 591 model->Remove(parent, index);
583 } 592 }
584 593
585 void RemoveAll(int profile) { 594 void RemoveAll(int profile) {
586 if (test()->use_verifier()) { 595 if (sync_datatype_helper::test()->use_verifier()) {
587 const BookmarkNode* root_node = GetVerifierBookmarkModel()->root_node(); 596 const BookmarkNode* root_node = GetVerifierBookmarkModel()->root_node();
588 for (int i = 0; i < root_node->child_count(); ++i) { 597 for (int i = 0; i < root_node->child_count(); ++i) {
589 const BookmarkNode* permanent_node = root_node->GetChild(i); 598 const BookmarkNode* permanent_node = root_node->GetChild(i);
590 for (int j = permanent_node->child_count() - 1; j >= 0; --j) { 599 for (int j = permanent_node->child_count() - 1; j >= 0; --j) {
591 GetVerifierBookmarkModel()->Remove(permanent_node, j); 600 GetVerifierBookmarkModel()->Remove(permanent_node, j);
592 } 601 }
593 } 602 }
594 } 603 }
595 GetBookmarkModel(profile)->RemoveAll(); 604 GetBookmarkModel(profile)->RemoveAll();
596 } 605 }
597 606
598 void SortChildren(int profile, const BookmarkNode* parent) { 607 void SortChildren(int profile, const BookmarkNode* parent) {
599 BookmarkModel* model = GetBookmarkModel(profile); 608 BookmarkModel* model = GetBookmarkModel(profile);
600 ASSERT_EQ(GetBookmarkNodeByID(model, parent->id()), parent) 609 ASSERT_EQ(GetBookmarkNodeByID(model, parent->id()), parent)
601 << "Node " << parent->GetTitle() << " does not belong to " 610 << "Node " << parent->GetTitle() << " does not belong to "
602 << "Profile " << profile; 611 << "Profile " << profile;
603 if (test()->use_verifier()) { 612 if (sync_datatype_helper::test()->use_verifier()) {
604 const BookmarkNode* v_parent = NULL; 613 const BookmarkNode* v_parent = NULL;
605 FindNodeInVerifier(model, parent, &v_parent); 614 FindNodeInVerifier(model, parent, &v_parent);
606 GetVerifierBookmarkModel()->SortChildren(v_parent); 615 GetVerifierBookmarkModel()->SortChildren(v_parent);
607 } 616 }
608 model->SortChildren(parent); 617 model->SortChildren(parent);
609 } 618 }
610 619
611 void ReverseChildOrder(int profile, const BookmarkNode* parent) { 620 void ReverseChildOrder(int profile, const BookmarkNode* parent) {
612 ASSERT_EQ(GetBookmarkNodeByID(GetBookmarkModel(profile), parent->id()), 621 ASSERT_EQ(GetBookmarkNodeByID(GetBookmarkModel(profile), parent->id()),
613 parent) 622 parent)
614 << "Node " << parent->GetTitle() << " does not belong to " 623 << "Node " << parent->GetTitle() << " does not belong to "
615 << "Profile " << profile; 624 << "Profile " << profile;
616 int child_count = parent->child_count(); 625 int child_count = parent->child_count();
617 if (child_count <= 0) 626 if (child_count <= 0)
618 return; 627 return;
619 for (int index = 0; index < child_count; ++index) { 628 for (int index = 0; index < child_count; ++index) {
620 Move(profile, parent->GetChild(index), parent, child_count - index); 629 Move(profile, parent->GetChild(index), parent, child_count - index);
621 } 630 }
622 } 631 }
623 632
624 bool ModelMatchesVerifier(int profile) { 633 bool ModelMatchesVerifier(int profile) {
625 if (!test()->use_verifier()) { 634 if (!sync_datatype_helper::test()->use_verifier()) {
626 LOG(ERROR) << "Illegal to call ModelMatchesVerifier() after " 635 LOG(ERROR) << "Illegal to call ModelMatchesVerifier() after "
627 << "DisableVerifier(). Use ModelsMatch() instead."; 636 << "DisableVerifier(). Use ModelsMatch() instead.";
628 return false; 637 return false;
629 } 638 }
630 return BookmarkModelsMatch(GetVerifierBookmarkModel(), 639 return BookmarkModelsMatch(GetVerifierBookmarkModel(),
631 GetBookmarkModel(profile)); 640 GetBookmarkModel(profile));
632 } 641 }
633 642
634 bool AllModelsMatchVerifier() { 643 bool AllModelsMatchVerifier() {
635 // Ensure that all tasks have finished processing on the history thread 644 // Ensure that all tasks have finished processing on the history thread
636 // and that any notifications the history thread may have sent have been 645 // and that any notifications the history thread may have sent have been
637 // processed before comparing models. 646 // processed before comparing models.
638 WaitForHistoryToProcessPendingTasks(); 647 WaitForHistoryToProcessPendingTasks();
639 648
640 for (int i = 0; i < test()->num_clients(); ++i) { 649 for (int i = 0; i < sync_datatype_helper::test()->num_clients(); ++i) {
641 if (!ModelMatchesVerifier(i)) { 650 if (!ModelMatchesVerifier(i)) {
642 LOG(ERROR) << "Model " << i << " does not match the verifier."; 651 LOG(ERROR) << "Model " << i << " does not match the verifier.";
643 return false; 652 return false;
644 } 653 }
645 } 654 }
646 return true; 655 return true;
647 } 656 }
648 657
649 bool ModelsMatch(int profile_a, int profile_b) { 658 bool ModelsMatch(int profile_a, int profile_b) {
650 return BookmarkModelsMatch(GetBookmarkModel(profile_a), 659 return BookmarkModelsMatch(GetBookmarkModel(profile_a),
651 GetBookmarkModel(profile_b)); 660 GetBookmarkModel(profile_b));
652 } 661 }
653 662
654 bool AllModelsMatch() { 663 bool AllModelsMatch() {
655 // Ensure that all tasks have finished processing on the history thread 664 // Ensure that all tasks have finished processing on the history thread
656 // and that any notifications the history thread may have sent have been 665 // and that any notifications the history thread may have sent have been
657 // processed before comparing models. 666 // processed before comparing models.
658 WaitForHistoryToProcessPendingTasks(); 667 WaitForHistoryToProcessPendingTasks();
659 668
660 for (int i = 1; i < test()->num_clients(); ++i) { 669 for (int i = 1; i < sync_datatype_helper::test()->num_clients(); ++i) {
661 if (!ModelsMatch(0, i)) { 670 if (!ModelsMatch(0, i)) {
662 LOG(ERROR) << "Model " << i << " does not match Model 0."; 671 LOG(ERROR) << "Model " << i << " does not match Model 0.";
663 return false; 672 return false;
664 } 673 }
665 } 674 }
666 return true; 675 return true;
667 } 676 }
668 677
669 namespace { 678 namespace {
670 679
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 810
802 std::wstring IndexedSubfolderName(int i) { 811 std::wstring IndexedSubfolderName(int i) {
803 return base::StringPrintf(L"Subfolder Name %d", i); 812 return base::StringPrintf(L"Subfolder Name %d", i);
804 } 813 }
805 814
806 std::wstring IndexedSubsubfolderName(int i) { 815 std::wstring IndexedSubsubfolderName(int i) {
807 return base::StringPrintf(L"Subsubfolder Name %d", i); 816 return base::StringPrintf(L"Subsubfolder Name %d", i);
808 } 817 }
809 818
810 } // namespace bookmarks_helper 819 } // namespace bookmarks_helper
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698