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

Side by Side Diff: components/browser_sync/profile_sync_service_typed_url_unittest.cc

Issue 1302233003: Replace gmock's deprecated SetArgumentPointee with SetArgPointee. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2017 Created 3 years, 7 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 30 matching lines...) Expand all
41 #include "components/sync/syncable/write_transaction.h" 41 #include "components/sync/syncable/write_transaction.h"
42 #include "testing/gmock/include/gmock/gmock.h" 42 #include "testing/gmock/include/gmock/gmock.h"
43 #include "testing/gtest/include/gtest/gtest.h" 43 #include "testing/gtest/include/gtest/gtest.h"
44 #include "url/gurl.h" 44 #include "url/gurl.h"
45 45
46 using history::HistoryBackend; 46 using history::HistoryBackend;
47 using history::HistoryBackendNotifier; 47 using history::HistoryBackendNotifier;
48 using history::TypedUrlSyncableService; 48 using history::TypedUrlSyncableService;
49 using testing::DoAll; 49 using testing::DoAll;
50 using testing::Return; 50 using testing::Return;
51 using testing::SetArgumentPointee; 51 using testing::SetArgPointee;
52 using testing::_; 52 using testing::_;
53 53
54 namespace browser_sync { 54 namespace browser_sync {
55 55
56 namespace { 56 namespace {
57 57
58 const char kDummySavingBrowserHistoryDisabled[] = "dummyPref"; 58 const char kDummySavingBrowserHistoryDisabled[] = "dummyPref";
59 59
60 // Visits with this timestamp are treated as expired. 60 // Visits with this timestamp are treated as expired.
61 static const int EXPIRED_VISIT = -1; 61 static const int EXPIRED_VISIT = -1;
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 ASSERT_EQ(0, syncable_service->GetErrorPercentage()); 412 ASSERT_EQ(0, syncable_service->GetErrorPercentage());
413 } 413 }
414 414
415 TEST_F(ProfileSyncServiceTypedUrlTest, HasNativeEmptySync) { 415 TEST_F(ProfileSyncServiceTypedUrlTest, HasNativeEmptySync) {
416 history::URLRows entries; 416 history::URLRows entries;
417 history::VisitVector visits; 417 history::VisitVector visits;
418 entries.push_back( 418 entries.push_back(
419 MakeTypedUrlEntry("http://foo.com", "bar", 2, 15, false, &visits)); 419 MakeTypedUrlEntry("http://foo.com", "bar", 2, 15, false, &visits));
420 420
421 EXPECT_CALL((history_backend()), GetAllTypedURLs(_)) 421 EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
422 .WillOnce(DoAll(SetArgumentPointee<0>(entries), Return(true))); 422 .WillOnce(DoAll(SetArgPointee<0>(entries), Return(true)));
423 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _)) 423 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
424 .WillRepeatedly(DoAll(SetArgumentPointee<2>(visits), Return(true))); 424 .WillRepeatedly(DoAll(SetArgPointee<2>(visits), Return(true)));
425 SetIdleChangeProcessorExpectations(); 425 SetIdleChangeProcessorExpectations();
426 CreateRootHelper create_root(this, syncer::TYPED_URLS); 426 CreateRootHelper create_root(this, syncer::TYPED_URLS);
427 TypedUrlSyncableService* syncable_service = 427 TypedUrlSyncableService* syncable_service =
428 StartSyncService(create_root.callback()); 428 StartSyncService(create_root.callback());
429 history::URLRows sync_entries; 429 history::URLRows sync_entries;
430 GetTypedUrlsFromSyncDB(&sync_entries); 430 GetTypedUrlsFromSyncDB(&sync_entries);
431 ASSERT_EQ(1U, sync_entries.size()); 431 ASSERT_EQ(1U, sync_entries.size());
432 EXPECT_TRUE(URLsEqual(entries[0], sync_entries[0])); 432 EXPECT_TRUE(URLsEqual(entries[0], sync_entries[0]));
433 ASSERT_EQ(0, syncable_service->GetErrorPercentage()); 433 ASSERT_EQ(0, syncable_service->GetErrorPercentage());
434 } 434 }
435 435
436 TEST_F(ProfileSyncServiceTypedUrlTest, HasNativeErrorReadingVisits) { 436 TEST_F(ProfileSyncServiceTypedUrlTest, HasNativeErrorReadingVisits) {
437 history::URLRows entries; 437 history::URLRows entries;
438 history::VisitVector visits; 438 history::VisitVector visits;
439 history::URLRow native_entry1( 439 history::URLRow native_entry1(
440 MakeTypedUrlEntry("http://foo.com", "bar", 2, 15, false, &visits)); 440 MakeTypedUrlEntry("http://foo.com", "bar", 2, 15, false, &visits));
441 history::URLRow native_entry2( 441 history::URLRow native_entry2(
442 MakeTypedUrlEntry("http://foo2.com", "bar", 3, 15, false, &visits)); 442 MakeTypedUrlEntry("http://foo2.com", "bar", 3, 15, false, &visits));
443 entries.push_back(native_entry1); 443 entries.push_back(native_entry1);
444 entries.push_back(native_entry2); 444 entries.push_back(native_entry2);
445 EXPECT_CALL((history_backend()), GetAllTypedURLs(_)) 445 EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
446 .WillOnce(DoAll(SetArgumentPointee<0>(entries), Return(true))); 446 .WillOnce(DoAll(SetArgPointee<0>(entries), Return(true)));
447 // Return an error from GetMostRecentVisitsForURL() for the second URL. 447 // Return an error from GetMostRecentVisitsForURL() for the second URL.
448 EXPECT_CALL((history_backend()), 448 EXPECT_CALL((history_backend()),
449 GetMostRecentVisitsForURL(native_entry1.id(), _, _)) 449 GetMostRecentVisitsForURL(native_entry1.id(), _, _))
450 .WillRepeatedly(Return(true)); 450 .WillRepeatedly(Return(true));
451 EXPECT_CALL((history_backend()), 451 EXPECT_CALL((history_backend()),
452 GetMostRecentVisitsForURL(native_entry2.id(), _, _)) 452 GetMostRecentVisitsForURL(native_entry2.id(), _, _))
453 .WillRepeatedly(Return(false)); 453 .WillRepeatedly(Return(false));
454 SetIdleChangeProcessorExpectations(); 454 SetIdleChangeProcessorExpectations();
455 CreateRootHelper create_root(this, syncer::TYPED_URLS); 455 CreateRootHelper create_root(this, syncer::TYPED_URLS);
456 StartSyncService(create_root.callback()); 456 StartSyncService(create_root.callback());
457 history::URLRows sync_entries; 457 history::URLRows sync_entries;
458 GetTypedUrlsFromSyncDB(&sync_entries); 458 GetTypedUrlsFromSyncDB(&sync_entries);
459 ASSERT_EQ(1U, sync_entries.size()); 459 ASSERT_EQ(1U, sync_entries.size());
460 EXPECT_TRUE(URLsEqual(native_entry1, sync_entries[0])); 460 EXPECT_TRUE(URLsEqual(native_entry1, sync_entries[0]));
461 } 461 }
462 462
463 TEST_F(ProfileSyncServiceTypedUrlTest, HasNativeWithBlankEmptySync) { 463 TEST_F(ProfileSyncServiceTypedUrlTest, HasNativeWithBlankEmptySync) {
464 std::vector<history::URLRow> entries; 464 std::vector<history::URLRow> entries;
465 history::VisitVector visits; 465 history::VisitVector visits;
466 // Add an empty URL. 466 // Add an empty URL.
467 entries.push_back(MakeTypedUrlEntry("", "bar", 2, 15, false, &visits)); 467 entries.push_back(MakeTypedUrlEntry("", "bar", 2, 15, false, &visits));
468 entries.push_back( 468 entries.push_back(
469 MakeTypedUrlEntry("http://foo.com", "bar", 2, 15, false, &visits)); 469 MakeTypedUrlEntry("http://foo.com", "bar", 2, 15, false, &visits));
470 EXPECT_CALL((history_backend()), GetAllTypedURLs(_)) 470 EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
471 .WillOnce(DoAll(SetArgumentPointee<0>(entries), Return(true))); 471 .WillOnce(DoAll(SetArgPointee<0>(entries), Return(true)));
472 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _)) 472 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
473 .WillRepeatedly(DoAll(SetArgumentPointee<2>(visits), Return(true))); 473 .WillRepeatedly(DoAll(SetArgPointee<2>(visits), Return(true)));
474 SetIdleChangeProcessorExpectations(); 474 SetIdleChangeProcessorExpectations();
475 CreateRootHelper create_root(this, syncer::TYPED_URLS); 475 CreateRootHelper create_root(this, syncer::TYPED_URLS);
476 StartSyncService(create_root.callback()); 476 StartSyncService(create_root.callback());
477 std::vector<history::URLRow> sync_entries; 477 std::vector<history::URLRow> sync_entries;
478 GetTypedUrlsFromSyncDB(&sync_entries); 478 GetTypedUrlsFromSyncDB(&sync_entries);
479 // The empty URL should be ignored. 479 // The empty URL should be ignored.
480 ASSERT_EQ(1U, sync_entries.size()); 480 ASSERT_EQ(1U, sync_entries.size());
481 EXPECT_TRUE(URLsEqual(entries[1], sync_entries[0])); 481 EXPECT_TRUE(URLsEqual(entries[1], sync_entries[0]));
482 } 482 }
483 483
484 TEST_F(ProfileSyncServiceTypedUrlTest, HasNativeHasSyncNoMerge) { 484 TEST_F(ProfileSyncServiceTypedUrlTest, HasNativeHasSyncNoMerge) {
485 history::VisitVector native_visits; 485 history::VisitVector native_visits;
486 history::VisitVector sync_visits; 486 history::VisitVector sync_visits;
487 history::URLRow native_entry(MakeTypedUrlEntry("http://native.com", "entry", 487 history::URLRow native_entry(MakeTypedUrlEntry("http://native.com", "entry",
488 2, 15, false, &native_visits)); 488 2, 15, false, &native_visits));
489 history::URLRow sync_entry(MakeTypedUrlEntry("http://sync.com", "entry", 3, 489 history::URLRow sync_entry(MakeTypedUrlEntry("http://sync.com", "entry", 3,
490 16, false, &sync_visits)); 490 16, false, &sync_visits));
491 491
492 history::URLRows native_entries; 492 history::URLRows native_entries;
493 native_entries.push_back(native_entry); 493 native_entries.push_back(native_entry);
494 EXPECT_CALL((history_backend()), GetAllTypedURLs(_)) 494 EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
495 .WillOnce(DoAll(SetArgumentPointee<0>(native_entries), Return(true))); 495 .WillOnce(DoAll(SetArgPointee<0>(native_entries), Return(true)));
496 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _)) 496 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
497 .WillRepeatedly( 497 .WillRepeatedly(DoAll(SetArgPointee<2>(native_visits), Return(true)));
498 DoAll(SetArgumentPointee<2>(native_visits), Return(true)));
499 EXPECT_CALL((history_backend()), AddVisits(_, _, history::SOURCE_SYNCED)) 498 EXPECT_CALL((history_backend()), AddVisits(_, _, history::SOURCE_SYNCED))
500 .WillRepeatedly(Return(true)); 499 .WillRepeatedly(Return(true));
501 500
502 history::URLRows sync_entries; 501 history::URLRows sync_entries;
503 sync_entries.push_back(sync_entry); 502 sync_entries.push_back(sync_entry);
504 503
505 EXPECT_CALL((history_backend()), UpdateURL(_, _)) 504 EXPECT_CALL((history_backend()), UpdateURL(_, _))
506 .WillRepeatedly(Return(true)); 505 .WillRepeatedly(Return(true));
507 StartSyncService(base::Bind(&AddTypedUrlEntries, this, sync_entries)); 506 StartSyncService(base::Bind(&AddTypedUrlEntries, this, sync_entries));
508 507
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 merged_visits.push_back( 545 merged_visits.push_back(
547 history::VisitRow(sync_entry.id(), base::Time::FromInternalValue(15), 0, 546 history::VisitRow(sync_entry.id(), base::Time::FromInternalValue(15), 0,
548 ui::PageTransitionFromInt(0), 0)); 547 ui::PageTransitionFromInt(0), 0));
549 548
550 history::URLRow merged_entry(MakeTypedUrlEntry("http://native.com", "name", 2, 549 history::URLRow merged_entry(MakeTypedUrlEntry("http://native.com", "name", 2,
551 17, false, &merged_visits)); 550 17, false, &merged_visits));
552 551
553 history::URLRows native_entries; 552 history::URLRows native_entries;
554 native_entries.push_back(native_entry); 553 native_entries.push_back(native_entry);
555 EXPECT_CALL((history_backend()), GetAllTypedURLs(_)) 554 EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
556 .WillOnce(DoAll(SetArgumentPointee<0>(native_entries), Return(true))); 555 .WillOnce(DoAll(SetArgPointee<0>(native_entries), Return(true)));
557 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _)) 556 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
558 .WillRepeatedly( 557 .WillRepeatedly(DoAll(SetArgPointee<2>(native_visits), Return(true)));
559 DoAll(SetArgumentPointee<2>(native_visits), Return(true)));
560 EXPECT_CALL((history_backend()), AddVisits(_, _, history::SOURCE_SYNCED)) 558 EXPECT_CALL((history_backend()), AddVisits(_, _, history::SOURCE_SYNCED))
561 .WillRepeatedly(Return(true)); 559 .WillRepeatedly(Return(true));
562 560
563 history::URLRows sync_entries; 561 history::URLRows sync_entries;
564 sync_entries.push_back(sync_entry); 562 sync_entries.push_back(sync_entry);
565 563
566 EXPECT_CALL((history_backend()), UpdateURL(_, _)) 564 EXPECT_CALL((history_backend()), UpdateURL(_, _))
567 .WillRepeatedly(Return(true)); 565 .WillRepeatedly(Return(true));
568 EXPECT_CALL((history_backend()), SetPageTitle(_, _)).WillRepeatedly(Return()); 566 EXPECT_CALL((history_backend()), SetPageTitle(_, _)).WillRepeatedly(Return());
569 StartSyncService(base::Bind(&AddTypedUrlEntries, this, sync_entries)); 567 StartSyncService(base::Bind(&AddTypedUrlEntries, this, sync_entries));
570 568
571 history::URLRows new_sync_entries; 569 history::URLRows new_sync_entries;
572 GetTypedUrlsFromSyncDB(&new_sync_entries); 570 GetTypedUrlsFromSyncDB(&new_sync_entries);
573 ASSERT_EQ(1U, new_sync_entries.size()); 571 ASSERT_EQ(1U, new_sync_entries.size());
574 EXPECT_TRUE(URLsEqual(merged_entry, new_sync_entries[0])); 572 EXPECT_TRUE(URLsEqual(merged_entry, new_sync_entries[0]));
575 } 573 }
576 574
577 TEST_F(ProfileSyncServiceTypedUrlTest, HasNativeWithErrorHasSyncMerge) { 575 TEST_F(ProfileSyncServiceTypedUrlTest, HasNativeWithErrorHasSyncMerge) {
578 history::VisitVector native_visits; 576 history::VisitVector native_visits;
579 history::URLRow native_entry(MakeTypedUrlEntry("http://native.com", "native", 577 history::URLRow native_entry(MakeTypedUrlEntry("http://native.com", "native",
580 2, 15, false, &native_visits)); 578 2, 15, false, &native_visits));
581 history::VisitVector sync_visits; 579 history::VisitVector sync_visits;
582 history::URLRow sync_entry(MakeTypedUrlEntry("http://native.com", "sync", 1, 580 history::URLRow sync_entry(MakeTypedUrlEntry("http://native.com", "sync", 1,
583 17, false, &sync_visits)); 581 17, false, &sync_visits));
584 582
585 history::URLRows native_entries; 583 history::URLRows native_entries;
586 native_entries.push_back(native_entry); 584 native_entries.push_back(native_entry);
587 EXPECT_CALL((history_backend()), GetAllTypedURLs(_)) 585 EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
588 .WillOnce(DoAll(SetArgumentPointee<0>(native_entries), Return(true))); 586 .WillOnce(DoAll(SetArgPointee<0>(native_entries), Return(true)));
589 // Return an error getting the visits for the native URL. 587 // Return an error getting the visits for the native URL.
590 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _)) 588 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
591 .WillRepeatedly(Return(false)); 589 .WillRepeatedly(Return(false));
592 EXPECT_CALL((history_backend()), GetURL(_, _)) 590 EXPECT_CALL((history_backend()), GetURL(_, _))
593 .WillRepeatedly(DoAll(SetArgumentPointee<1>(native_entry), Return(true))); 591 .WillRepeatedly(DoAll(SetArgPointee<1>(native_entry), Return(true)));
594 EXPECT_CALL((history_backend()), AddVisits(_, _, history::SOURCE_SYNCED)) 592 EXPECT_CALL((history_backend()), AddVisits(_, _, history::SOURCE_SYNCED))
595 .WillRepeatedly(Return(true)); 593 .WillRepeatedly(Return(true));
596 594
597 history::URLRows sync_entries; 595 history::URLRows sync_entries;
598 sync_entries.push_back(sync_entry); 596 sync_entries.push_back(sync_entry);
599 597
600 EXPECT_CALL((history_backend()), UpdateURL(_, _)) 598 EXPECT_CALL((history_backend()), UpdateURL(_, _))
601 .WillRepeatedly(Return(true)); 599 .WillRepeatedly(Return(true));
602 EXPECT_CALL((history_backend()), SetPageTitle(_, _)).WillRepeatedly(Return()); 600 EXPECT_CALL((history_backend()), SetPageTitle(_, _)).WillRepeatedly(Return());
603 StartSyncService(base::Bind(&AddTypedUrlEntries, this, sync_entries)); 601 StartSyncService(base::Bind(&AddTypedUrlEntries, this, sync_entries));
604 602
605 history::URLRows new_sync_entries; 603 history::URLRows new_sync_entries;
606 GetTypedUrlsFromSyncDB(&new_sync_entries); 604 GetTypedUrlsFromSyncDB(&new_sync_entries);
607 ASSERT_EQ(1U, new_sync_entries.size()); 605 ASSERT_EQ(1U, new_sync_entries.size());
608 EXPECT_TRUE(URLsEqual(sync_entry, new_sync_entries[0])); 606 EXPECT_TRUE(URLsEqual(sync_entry, new_sync_entries[0]));
609 } 607 }
610 608
611 TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserChangeAdd) { 609 TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserChangeAdd) {
612 history::VisitVector added_visits; 610 history::VisitVector added_visits;
613 history::URLRow added_entry(MakeTypedUrlEntry("http://added.com", "entry", 2, 611 history::URLRow added_entry(MakeTypedUrlEntry("http://added.com", "entry", 2,
614 15, false, &added_visits)); 612 15, false, &added_visits));
615 613
616 EXPECT_CALL((history_backend()), GetAllTypedURLs(_)).WillOnce(Return(true)); 614 EXPECT_CALL((history_backend()), GetAllTypedURLs(_)).WillOnce(Return(true));
617 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _)) 615 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
618 .WillOnce(DoAll(SetArgumentPointee<2>(added_visits), Return(true))); 616 .WillOnce(DoAll(SetArgPointee<2>(added_visits), Return(true)));
619 617
620 SetIdleChangeProcessorExpectations(); 618 SetIdleChangeProcessorExpectations();
621 CreateRootHelper create_root(this, syncer::TYPED_URLS); 619 CreateRootHelper create_root(this, syncer::TYPED_URLS);
622 StartSyncService(create_root.callback()); 620 StartSyncService(create_root.callback());
623 621
624 history::URLRows changed_urls; 622 history::URLRows changed_urls;
625 changed_urls.push_back(added_entry); 623 changed_urls.push_back(added_entry);
626 SendNotificationURLsModified(changed_urls); 624 SendNotificationURLsModified(changed_urls);
627 625
628 history::URLRows new_sync_entries; 626 history::URLRows new_sync_entries;
629 GetTypedUrlsFromSyncDB(&new_sync_entries); 627 GetTypedUrlsFromSyncDB(&new_sync_entries);
630 ASSERT_EQ(1U, new_sync_entries.size()); 628 ASSERT_EQ(1U, new_sync_entries.size());
631 EXPECT_TRUE(URLsEqual(added_entry, new_sync_entries[0])); 629 EXPECT_TRUE(URLsEqual(added_entry, new_sync_entries[0]));
632 } 630 }
633 631
634 TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserChangeAddWithBlank) { 632 TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserChangeAddWithBlank) {
635 history::VisitVector added_visits; 633 history::VisitVector added_visits;
636 history::URLRow empty_entry( 634 history::URLRow empty_entry(
637 MakeTypedUrlEntry("", "entry", 2, 15, false, &added_visits)); 635 MakeTypedUrlEntry("", "entry", 2, 15, false, &added_visits));
638 history::URLRow added_entry(MakeTypedUrlEntry("http://added.com", "entry", 2, 636 history::URLRow added_entry(MakeTypedUrlEntry("http://added.com", "entry", 2,
639 15, false, &added_visits)); 637 15, false, &added_visits));
640 638
641 EXPECT_CALL((history_backend()), GetAllTypedURLs(_)).WillOnce(Return(true)); 639 EXPECT_CALL((history_backend()), GetAllTypedURLs(_)).WillOnce(Return(true));
642 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _)) 640 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
643 .WillRepeatedly(DoAll(SetArgumentPointee<2>(added_visits), Return(true))); 641 .WillRepeatedly(DoAll(SetArgPointee<2>(added_visits), Return(true)));
644 642
645 SetIdleChangeProcessorExpectations(); 643 SetIdleChangeProcessorExpectations();
646 CreateRootHelper create_root(this, syncer::TYPED_URLS); 644 CreateRootHelper create_root(this, syncer::TYPED_URLS);
647 StartSyncService(create_root.callback()); 645 StartSyncService(create_root.callback());
648 646
649 history::URLRows changed_urls; 647 history::URLRows changed_urls;
650 changed_urls.push_back(empty_entry); 648 changed_urls.push_back(empty_entry);
651 changed_urls.push_back(added_entry); 649 changed_urls.push_back(added_entry);
652 SendNotificationURLsModified(changed_urls); 650 SendNotificationURLsModified(changed_urls);
653 651
654 std::vector<history::URLRow> new_sync_entries; 652 std::vector<history::URLRow> new_sync_entries;
655 GetTypedUrlsFromSyncDB(&new_sync_entries); 653 GetTypedUrlsFromSyncDB(&new_sync_entries);
656 ASSERT_EQ(1U, new_sync_entries.size()); 654 ASSERT_EQ(1U, new_sync_entries.size());
657 EXPECT_TRUE(URLsEqual(added_entry, new_sync_entries[0])); 655 EXPECT_TRUE(URLsEqual(added_entry, new_sync_entries[0]));
658 } 656 }
659 657
660 TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserChangeUpdate) { 658 TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserChangeUpdate) {
661 history::VisitVector original_visits; 659 history::VisitVector original_visits;
662 history::URLRow original_entry(MakeTypedUrlEntry( 660 history::URLRow original_entry(MakeTypedUrlEntry(
663 "http://mine.com", "entry", 2, 15, false, &original_visits)); 661 "http://mine.com", "entry", 2, 15, false, &original_visits));
664 history::URLRows original_entries; 662 history::URLRows original_entries;
665 original_entries.push_back(original_entry); 663 original_entries.push_back(original_entry);
666 664
667 EXPECT_CALL((history_backend()), GetAllTypedURLs(_)) 665 EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
668 .WillOnce(DoAll(SetArgumentPointee<0>(original_entries), Return(true))); 666 .WillOnce(DoAll(SetArgPointee<0>(original_entries), Return(true)));
669 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _)) 667 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
670 .WillOnce(DoAll(SetArgumentPointee<2>(original_visits), Return(true))); 668 .WillOnce(DoAll(SetArgPointee<2>(original_visits), Return(true)));
671 CreateRootHelper create_root(this, syncer::TYPED_URLS); 669 CreateRootHelper create_root(this, syncer::TYPED_URLS);
672 StartSyncService(create_root.callback()); 670 StartSyncService(create_root.callback());
673 671
674 history::VisitVector updated_visits; 672 history::VisitVector updated_visits;
675 history::URLRow updated_entry(MakeTypedUrlEntry("http://mine.com", "entry", 7, 673 history::URLRow updated_entry(MakeTypedUrlEntry("http://mine.com", "entry", 7,
676 17, false, &updated_visits)); 674 17, false, &updated_visits));
677 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _)) 675 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
678 .WillOnce(DoAll(SetArgumentPointee<2>(updated_visits), Return(true))); 676 .WillOnce(DoAll(SetArgPointee<2>(updated_visits), Return(true)));
679 677
680 history::URLRows changed_urls; 678 history::URLRows changed_urls;
681 changed_urls.push_back(updated_entry); 679 changed_urls.push_back(updated_entry);
682 SendNotificationURLsModified(changed_urls); 680 SendNotificationURLsModified(changed_urls);
683 681
684 history::URLRows new_sync_entries; 682 history::URLRows new_sync_entries;
685 GetTypedUrlsFromSyncDB(&new_sync_entries); 683 GetTypedUrlsFromSyncDB(&new_sync_entries);
686 ASSERT_EQ(1U, new_sync_entries.size()); 684 ASSERT_EQ(1U, new_sync_entries.size());
687 EXPECT_TRUE(URLsEqual(updated_entry, new_sync_entries[0])); 685 EXPECT_TRUE(URLsEqual(updated_entry, new_sync_entries[0]));
688 } 686 }
689 687
690 TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserChangeAddFromVisit) { 688 TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserChangeAddFromVisit) {
691 history::VisitVector added_visits; 689 history::VisitVector added_visits;
692 history::URLRow added_entry(MakeTypedUrlEntry("http://added.com", "entry", 2, 690 history::URLRow added_entry(MakeTypedUrlEntry("http://added.com", "entry", 2,
693 15, false, &added_visits)); 691 15, false, &added_visits));
694 692
695 EXPECT_CALL((history_backend()), GetAllTypedURLs(_)).WillOnce(Return(true)); 693 EXPECT_CALL((history_backend()), GetAllTypedURLs(_)).WillOnce(Return(true));
696 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _)) 694 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
697 .WillOnce(DoAll(SetArgumentPointee<2>(added_visits), Return(true))); 695 .WillOnce(DoAll(SetArgPointee<2>(added_visits), Return(true)));
698 696
699 SetIdleChangeProcessorExpectations(); 697 SetIdleChangeProcessorExpectations();
700 CreateRootHelper create_root(this, syncer::TYPED_URLS); 698 CreateRootHelper create_root(this, syncer::TYPED_URLS);
701 StartSyncService(create_root.callback()); 699 StartSyncService(create_root.callback());
702 700
703 SendNotificationURLVisited(ui::PAGE_TRANSITION_TYPED, added_entry); 701 SendNotificationURLVisited(ui::PAGE_TRANSITION_TYPED, added_entry);
704 702
705 history::URLRows new_sync_entries; 703 history::URLRows new_sync_entries;
706 GetTypedUrlsFromSyncDB(&new_sync_entries); 704 GetTypedUrlsFromSyncDB(&new_sync_entries);
707 ASSERT_EQ(1U, new_sync_entries.size()); 705 ASSERT_EQ(1U, new_sync_entries.size());
708 EXPECT_TRUE(URLsEqual(added_entry, new_sync_entries[0])); 706 EXPECT_TRUE(URLsEqual(added_entry, new_sync_entries[0]));
709 } 707 }
710 708
711 TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserChangeUpdateFromVisit) { 709 TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserChangeUpdateFromVisit) {
712 history::VisitVector original_visits; 710 history::VisitVector original_visits;
713 history::URLRow original_entry(MakeTypedUrlEntry( 711 history::URLRow original_entry(MakeTypedUrlEntry(
714 "http://mine.com", "entry", 2, 15, false, &original_visits)); 712 "http://mine.com", "entry", 2, 15, false, &original_visits));
715 history::URLRows original_entries; 713 history::URLRows original_entries;
716 original_entries.push_back(original_entry); 714 original_entries.push_back(original_entry);
717 715
718 EXPECT_CALL((history_backend()), GetAllTypedURLs(_)) 716 EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
719 .WillOnce(DoAll(SetArgumentPointee<0>(original_entries), Return(true))); 717 .WillOnce(DoAll(SetArgPointee<0>(original_entries), Return(true)));
720 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _)) 718 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
721 .WillOnce(DoAll(SetArgumentPointee<2>(original_visits), Return(true))); 719 .WillOnce(DoAll(SetArgPointee<2>(original_visits), Return(true)));
722 CreateRootHelper create_root(this, syncer::TYPED_URLS); 720 CreateRootHelper create_root(this, syncer::TYPED_URLS);
723 StartSyncService(create_root.callback()); 721 StartSyncService(create_root.callback());
724 722
725 history::VisitVector updated_visits; 723 history::VisitVector updated_visits;
726 history::URLRow updated_entry(MakeTypedUrlEntry("http://mine.com", "entry", 7, 724 history::URLRow updated_entry(MakeTypedUrlEntry("http://mine.com", "entry", 7,
727 17, false, &updated_visits)); 725 17, false, &updated_visits));
728 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _)) 726 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
729 .WillOnce(DoAll(SetArgumentPointee<2>(updated_visits), Return(true))); 727 .WillOnce(DoAll(SetArgPointee<2>(updated_visits), Return(true)));
730 728
731 SendNotificationURLVisited(ui::PAGE_TRANSITION_TYPED, updated_entry); 729 SendNotificationURLVisited(ui::PAGE_TRANSITION_TYPED, updated_entry);
732 730
733 history::URLRows new_sync_entries; 731 history::URLRows new_sync_entries;
734 GetTypedUrlsFromSyncDB(&new_sync_entries); 732 GetTypedUrlsFromSyncDB(&new_sync_entries);
735 ASSERT_EQ(1U, new_sync_entries.size()); 733 ASSERT_EQ(1U, new_sync_entries.size());
736 EXPECT_TRUE(URLsEqual(updated_entry, new_sync_entries[0])); 734 EXPECT_TRUE(URLsEqual(updated_entry, new_sync_entries[0]));
737 } 735 }
738 736
739 TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserIgnoreChangeUpdateFromVisit) { 737 TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserIgnoreChangeUpdateFromVisit) {
740 history::VisitVector original_visits; 738 history::VisitVector original_visits;
741 history::URLRow original_entry(MakeTypedUrlEntry( 739 history::URLRow original_entry(MakeTypedUrlEntry(
742 "http://mine.com", "entry", 2, 15, false, &original_visits)); 740 "http://mine.com", "entry", 2, 15, false, &original_visits));
743 history::URLRows original_entries; 741 history::URLRows original_entries;
744 original_entries.push_back(original_entry); 742 original_entries.push_back(original_entry);
745 743
746 EXPECT_CALL((history_backend()), GetAllTypedURLs(_)) 744 EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
747 .WillOnce(DoAll(SetArgumentPointee<0>(original_entries), Return(true))); 745 .WillOnce(DoAll(SetArgPointee<0>(original_entries), Return(true)));
748 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _)) 746 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
749 .WillRepeatedly( 747 .WillRepeatedly(DoAll(SetArgPointee<2>(original_visits), Return(true)));
750 DoAll(SetArgumentPointee<2>(original_visits), Return(true)));
751 CreateRootHelper create_root(this, syncer::TYPED_URLS); 748 CreateRootHelper create_root(this, syncer::TYPED_URLS);
752 StartSyncService(create_root.callback()); 749 StartSyncService(create_root.callback());
753 history::URLRows new_sync_entries; 750 history::URLRows new_sync_entries;
754 GetTypedUrlsFromSyncDB(&new_sync_entries); 751 GetTypedUrlsFromSyncDB(&new_sync_entries);
755 ASSERT_EQ(1U, new_sync_entries.size()); 752 ASSERT_EQ(1U, new_sync_entries.size());
756 EXPECT_TRUE(URLsEqual(original_entry, new_sync_entries[0])); 753 EXPECT_TRUE(URLsEqual(original_entry, new_sync_entries[0]));
757 754
758 history::VisitVector updated_visits; 755 history::VisitVector updated_visits;
759 history::URLRow updated_entry(MakeTypedUrlEntry("http://mine.com", "entry", 7, 756 history::URLRow updated_entry(MakeTypedUrlEntry("http://mine.com", "entry", 7,
760 15, false, &updated_visits)); 757 15, false, &updated_visits));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 history::URLRow original_entry1(MakeTypedUrlEntry( 791 history::URLRow original_entry1(MakeTypedUrlEntry(
795 "http://mine.com", "entry", 2, 15, false, &original_visits1)); 792 "http://mine.com", "entry", 2, 15, false, &original_visits1));
796 history::VisitVector original_visits2; 793 history::VisitVector original_visits2;
797 history::URLRow original_entry2(MakeTypedUrlEntry( 794 history::URLRow original_entry2(MakeTypedUrlEntry(
798 "http://mine2.com", "entry2", 3, 15, false, &original_visits2)); 795 "http://mine2.com", "entry2", 3, 15, false, &original_visits2));
799 history::URLRows original_entries; 796 history::URLRows original_entries;
800 original_entries.push_back(original_entry1); 797 original_entries.push_back(original_entry1);
801 original_entries.push_back(original_entry2); 798 original_entries.push_back(original_entry2);
802 799
803 EXPECT_CALL((history_backend()), GetAllTypedURLs(_)) 800 EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
804 .WillOnce(DoAll(SetArgumentPointee<0>(original_entries), Return(true))); 801 .WillOnce(DoAll(SetArgPointee<0>(original_entries), Return(true)));
805 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _)) 802 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
806 .WillRepeatedly( 803 .WillRepeatedly(DoAll(SetArgPointee<2>(original_visits1), Return(true)));
807 DoAll(SetArgumentPointee<2>(original_visits1), Return(true)));
808 CreateRootHelper create_root(this, syncer::TYPED_URLS); 804 CreateRootHelper create_root(this, syncer::TYPED_URLS);
809 StartSyncService(create_root.callback()); 805 StartSyncService(create_root.callback());
810 806
811 history::URLRows rows; 807 history::URLRows rows;
812 rows.push_back(history::URLRow(GURL("http://mine.com"))); 808 rows.push_back(history::URLRow(GURL("http://mine.com")));
813 SendNotificationURLsDeleted(false, false, rows, std::set<GURL>()); 809 SendNotificationURLsDeleted(false, false, rows, std::set<GURL>());
814 history::URLRows new_sync_entries; 810 history::URLRows new_sync_entries;
815 GetTypedUrlsFromSyncDB(&new_sync_entries); 811 GetTypedUrlsFromSyncDB(&new_sync_entries);
816 ASSERT_EQ(1U, new_sync_entries.size()); 812 ASSERT_EQ(1U, new_sync_entries.size());
817 EXPECT_TRUE(URLsEqual(original_entry2, new_sync_entries[0])); 813 EXPECT_TRUE(URLsEqual(original_entry2, new_sync_entries[0]));
818 } 814 }
819 815
820 TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserChangeRemoveExpired) { 816 TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserChangeRemoveExpired) {
821 history::VisitVector original_visits1; 817 history::VisitVector original_visits1;
822 history::URLRow original_entry1(MakeTypedUrlEntry( 818 history::URLRow original_entry1(MakeTypedUrlEntry(
823 "http://mine.com", "entry", 2, 15, false, &original_visits1)); 819 "http://mine.com", "entry", 2, 15, false, &original_visits1));
824 history::VisitVector original_visits2; 820 history::VisitVector original_visits2;
825 history::URLRow original_entry2(MakeTypedUrlEntry( 821 history::URLRow original_entry2(MakeTypedUrlEntry(
826 "http://mine2.com", "entry2", 3, 15, false, &original_visits2)); 822 "http://mine2.com", "entry2", 3, 15, false, &original_visits2));
827 history::URLRows original_entries; 823 history::URLRows original_entries;
828 original_entries.push_back(original_entry1); 824 original_entries.push_back(original_entry1);
829 original_entries.push_back(original_entry2); 825 original_entries.push_back(original_entry2);
830 826
831 EXPECT_CALL((history_backend()), GetAllTypedURLs(_)) 827 EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
832 .WillOnce(DoAll(SetArgumentPointee<0>(original_entries), Return(true))); 828 .WillOnce(DoAll(SetArgPointee<0>(original_entries), Return(true)));
833 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _)) 829 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
834 .WillRepeatedly( 830 .WillRepeatedly(DoAll(SetArgPointee<2>(original_visits1), Return(true)));
835 DoAll(SetArgumentPointee<2>(original_visits1), Return(true)));
836 CreateRootHelper create_root(this, syncer::TYPED_URLS); 831 CreateRootHelper create_root(this, syncer::TYPED_URLS);
837 StartSyncService(create_root.callback()); 832 StartSyncService(create_root.callback());
838 833
839 // Setting expired=true should cause the sync code to ignore this deletion. 834 // Setting expired=true should cause the sync code to ignore this deletion.
840 history::URLRows rows; 835 history::URLRows rows;
841 rows.push_back(history::URLRow(GURL("http://mine.com"))); 836 rows.push_back(history::URLRow(GURL("http://mine.com")));
842 SendNotificationURLsDeleted(false, true, rows, std::set<GURL>()); 837 SendNotificationURLsDeleted(false, true, rows, std::set<GURL>());
843 history::URLRows new_sync_entries; 838 history::URLRows new_sync_entries;
844 GetTypedUrlsFromSyncDB(&new_sync_entries); 839 GetTypedUrlsFromSyncDB(&new_sync_entries);
845 // Both URLs should still be there. 840 // Both URLs should still be there.
846 ASSERT_EQ(2U, new_sync_entries.size()); 841 ASSERT_EQ(2U, new_sync_entries.size());
847 } 842 }
848 843
849 TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserChangeRemoveAll) { 844 TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserChangeRemoveAll) {
850 history::VisitVector original_visits1; 845 history::VisitVector original_visits1;
851 history::URLRow original_entry1(MakeTypedUrlEntry( 846 history::URLRow original_entry1(MakeTypedUrlEntry(
852 "http://mine.com", "entry", 2, 15, false, &original_visits1)); 847 "http://mine.com", "entry", 2, 15, false, &original_visits1));
853 history::VisitVector original_visits2; 848 history::VisitVector original_visits2;
854 history::URLRow original_entry2(MakeTypedUrlEntry( 849 history::URLRow original_entry2(MakeTypedUrlEntry(
855 "http://mine2.com", "entry2", 3, 15, false, &original_visits2)); 850 "http://mine2.com", "entry2", 3, 15, false, &original_visits2));
856 history::URLRows original_entries; 851 history::URLRows original_entries;
857 original_entries.push_back(original_entry1); 852 original_entries.push_back(original_entry1);
858 original_entries.push_back(original_entry2); 853 original_entries.push_back(original_entry2);
859 854
860 EXPECT_CALL((history_backend()), GetAllTypedURLs(_)) 855 EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
861 .WillOnce(DoAll(SetArgumentPointee<0>(original_entries), Return(true))); 856 .WillOnce(DoAll(SetArgPointee<0>(original_entries), Return(true)));
862 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _)) 857 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
863 .WillRepeatedly( 858 .WillRepeatedly(DoAll(SetArgPointee<2>(original_visits1), Return(true)));
864 DoAll(SetArgumentPointee<2>(original_visits1), Return(true)));
865 CreateRootHelper create_root(this, syncer::TYPED_URLS); 859 CreateRootHelper create_root(this, syncer::TYPED_URLS);
866 StartSyncService(create_root.callback()); 860 StartSyncService(create_root.callback());
867 861
868 history::URLRows new_sync_entries; 862 history::URLRows new_sync_entries;
869 GetTypedUrlsFromSyncDB(&new_sync_entries); 863 GetTypedUrlsFromSyncDB(&new_sync_entries);
870 ASSERT_EQ(2U, new_sync_entries.size()); 864 ASSERT_EQ(2U, new_sync_entries.size());
871 865
872 SendNotificationURLsDeleted(true, false, history::URLRows(), 866 SendNotificationURLsDeleted(true, false, history::URLRows(),
873 std::set<GURL>()); 867 std::set<GURL>());
874 868
875 GetTypedUrlsFromSyncDB(&new_sync_entries); 869 GetTypedUrlsFromSyncDB(&new_sync_entries);
876 ASSERT_EQ(0U, new_sync_entries.size()); 870 ASSERT_EQ(0U, new_sync_entries.size());
877 } 871 }
878 872
879 TEST_F(ProfileSyncServiceTypedUrlTest, FailWriteToHistoryBackend) { 873 TEST_F(ProfileSyncServiceTypedUrlTest, FailWriteToHistoryBackend) {
880 history::VisitVector native_visits; 874 history::VisitVector native_visits;
881 history::VisitVector sync_visits; 875 history::VisitVector sync_visits;
882 history::URLRow native_entry(MakeTypedUrlEntry("http://native.com", "entry", 876 history::URLRow native_entry(MakeTypedUrlEntry("http://native.com", "entry",
883 2, 15, false, &native_visits)); 877 2, 15, false, &native_visits));
884 history::URLRow sync_entry(MakeTypedUrlEntry("http://sync.com", "entry", 3, 878 history::URLRow sync_entry(MakeTypedUrlEntry("http://sync.com", "entry", 3,
885 16, false, &sync_visits)); 879 16, false, &sync_visits));
886 880
887 history::URLRows native_entries; 881 history::URLRows native_entries;
888 native_entries.push_back(native_entry); 882 native_entries.push_back(native_entry);
889 EXPECT_CALL((history_backend()), GetAllTypedURLs(_)) 883 EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
890 .WillOnce(DoAll(SetArgumentPointee<0>(native_entries), Return(true))); 884 .WillOnce(DoAll(SetArgPointee<0>(native_entries), Return(true)));
891 EXPECT_CALL((history_backend()), GetURL(_, _)) 885 EXPECT_CALL((history_backend()), GetURL(_, _))
892 .WillOnce(DoAll(SetArgumentPointee<1>(native_entry), Return(false))); 886 .WillOnce(DoAll(SetArgPointee<1>(native_entry), Return(false)));
893 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _)) 887 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
894 .WillRepeatedly( 888 .WillRepeatedly(DoAll(SetArgPointee<2>(native_visits), Return(true)));
895 DoAll(SetArgumentPointee<2>(native_visits), Return(true)));
896 EXPECT_CALL((history_backend()), AddVisits(_, _, history::SOURCE_SYNCED)) 889 EXPECT_CALL((history_backend()), AddVisits(_, _, history::SOURCE_SYNCED))
897 .WillRepeatedly(Return(false)); 890 .WillRepeatedly(Return(false));
898 891
899 history::URLRows sync_entries; 892 history::URLRows sync_entries;
900 sync_entries.push_back(sync_entry); 893 sync_entries.push_back(sync_entry);
901 894
902 EXPECT_CALL((history_backend()), UpdateURL(_, _)) 895 EXPECT_CALL((history_backend()), UpdateURL(_, _))
903 .WillRepeatedly(Return(false)); 896 .WillRepeatedly(Return(false));
904 TypedUrlSyncableService* syncable_service = 897 TypedUrlSyncableService* syncable_service =
905 StartSyncService(base::Bind(&AddTypedUrlEntries, this, sync_entries)); 898 StartSyncService(base::Bind(&AddTypedUrlEntries, this, sync_entries));
(...skipping 11 matching lines...) Expand all
917 history::VisitVector native_visits; 910 history::VisitVector native_visits;
918 history::VisitVector sync_visits; 911 history::VisitVector sync_visits;
919 history::URLRow native_entry(MakeTypedUrlEntry("http://native.com", "entry", 912 history::URLRow native_entry(MakeTypedUrlEntry("http://native.com", "entry",
920 2, 15, false, &native_visits)); 913 2, 15, false, &native_visits));
921 history::URLRow sync_entry(MakeTypedUrlEntry("http://sync.com", "entry", 3, 914 history::URLRow sync_entry(MakeTypedUrlEntry("http://sync.com", "entry", 3,
922 16, false, &sync_visits)); 915 16, false, &sync_visits));
923 916
924 history::URLRows native_entries; 917 history::URLRows native_entries;
925 native_entries.push_back(native_entry); 918 native_entries.push_back(native_entry);
926 EXPECT_CALL((history_backend()), GetAllTypedURLs(_)) 919 EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
927 .WillOnce(DoAll(SetArgumentPointee<0>(native_entries), Return(false))); 920 .WillOnce(DoAll(SetArgPointee<0>(native_entries), Return(false)));
928 921
929 history::URLRows sync_entries; 922 history::URLRows sync_entries;
930 sync_entries.push_back(sync_entry); 923 sync_entries.push_back(sync_entry);
931 924
932 StartSyncService(base::Bind(&AddTypedUrlEntries, this, sync_entries)); 925 StartSyncService(base::Bind(&AddTypedUrlEntries, this, sync_entries));
933 // Errors getting typed URLs will cause an unrecoverable error (since we can 926 // Errors getting typed URLs will cause an unrecoverable error (since we can
934 // do *nothing* in that case). 927 // do *nothing* in that case).
935 ASSERT_TRUE(sync_service()->data_type_status_table().GetFailedTypes().Has( 928 ASSERT_TRUE(sync_service()->data_type_status_table().GetFailedTypes().Has(
936 syncer::TYPED_URLS)); 929 syncer::TYPED_URLS));
937 ASSERT_EQ(1u, 930 ASSERT_EQ(1u,
938 sync_service()->data_type_status_table().GetFailedTypes().Size()); 931 sync_service()->data_type_status_table().GetFailedTypes().Size());
939 // Can't check GetErrorPercentage(), because generating an unrecoverable 932 // Can't check GetErrorPercentage(), because generating an unrecoverable
940 // error will free the model associator. 933 // error will free the model associator.
941 } 934 }
942 935
943 TEST_F(ProfileSyncServiceTypedUrlTest, IgnoreLocalFileURL) { 936 TEST_F(ProfileSyncServiceTypedUrlTest, IgnoreLocalFileURL) {
944 history::VisitVector original_visits; 937 history::VisitVector original_visits;
945 // Create http and file url. 938 // Create http and file url.
946 history::URLRow url_entry(MakeTypedUrlEntry("http://yey.com", "yey", 12, 15, 939 history::URLRow url_entry(MakeTypedUrlEntry("http://yey.com", "yey", 12, 15,
947 false, &original_visits)); 940 false, &original_visits));
948 history::URLRow file_entry(MakeTypedUrlEntry( 941 history::URLRow file_entry(MakeTypedUrlEntry(
949 "file:///kitty.jpg", "kitteh", 12, 15, false, &original_visits)); 942 "file:///kitty.jpg", "kitteh", 12, 15, false, &original_visits));
950 943
951 history::URLRows original_entries; 944 history::URLRows original_entries;
952 original_entries.push_back(url_entry); 945 original_entries.push_back(url_entry);
953 original_entries.push_back(file_entry); 946 original_entries.push_back(file_entry);
954 947
955 EXPECT_CALL((history_backend()), GetAllTypedURLs(_)) 948 EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
956 .WillRepeatedly( 949 .WillRepeatedly(DoAll(SetArgPointee<0>(original_entries), Return(true)));
957 DoAll(SetArgumentPointee<0>(original_entries), Return(true)));
958 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _)) 950 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
959 .WillRepeatedly( 951 .WillRepeatedly(DoAll(SetArgPointee<2>(original_visits), Return(true)));
960 DoAll(SetArgumentPointee<2>(original_visits), Return(true)));
961 CreateRootHelper create_root(this, syncer::TYPED_URLS); 952 CreateRootHelper create_root(this, syncer::TYPED_URLS);
962 StartSyncService(create_root.callback()); 953 StartSyncService(create_root.callback());
963 954
964 history::VisitVector updated_visits; 955 history::VisitVector updated_visits;
965 // Create updates for the previous urls + a new file one. 956 // Create updates for the previous urls + a new file one.
966 history::URLRow updated_url_entry(MakeTypedUrlEntry( 957 history::URLRow updated_url_entry(MakeTypedUrlEntry(
967 "http://yey.com", "yey", 20, 15, false, &updated_visits)); 958 "http://yey.com", "yey", 20, 15, false, &updated_visits));
968 history::URLRow updated_file_entry(MakeTypedUrlEntry( 959 history::URLRow updated_file_entry(MakeTypedUrlEntry(
969 "file:///cat.jpg", "cat", 20, 15, false, &updated_visits)); 960 "file:///cat.jpg", "cat", 20, 15, false, &updated_visits));
970 history::URLRow new_file_entry(MakeTypedUrlEntry("file:///dog.jpg", "dog", 20, 961 history::URLRow new_file_entry(MakeTypedUrlEntry("file:///dog.jpg", "dog", 20,
(...skipping 20 matching lines...) Expand all
991 history::URLRow url_entry(MakeTypedUrlEntry("http://yey.com", "yey", 12, 15, 982 history::URLRow url_entry(MakeTypedUrlEntry("http://yey.com", "yey", 12, 15,
992 false, &original_visits)); 983 false, &original_visits));
993 history::URLRow localhost_entry(MakeTypedUrlEntry( 984 history::URLRow localhost_entry(MakeTypedUrlEntry(
994 "http://localhost", "localhost", 12, 15, false, &original_visits)); 985 "http://localhost", "localhost", 12, 15, false, &original_visits));
995 986
996 history::URLRows original_entries; 987 history::URLRows original_entries;
997 original_entries.push_back(url_entry); 988 original_entries.push_back(url_entry);
998 original_entries.push_back(localhost_entry); 989 original_entries.push_back(localhost_entry);
999 990
1000 EXPECT_CALL((history_backend()), GetAllTypedURLs(_)) 991 EXPECT_CALL((history_backend()), GetAllTypedURLs(_))
1001 .WillRepeatedly( 992 .WillRepeatedly(DoAll(SetArgPointee<0>(original_entries), Return(true)));
1002 DoAll(SetArgumentPointee<0>(original_entries), Return(true)));
1003 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _)) 993 EXPECT_CALL((history_backend()), GetMostRecentVisitsForURL(_, _, _))
1004 .WillRepeatedly( 994 .WillRepeatedly(DoAll(SetArgPointee<2>(original_visits), Return(true)));
1005 DoAll(SetArgumentPointee<2>(original_visits), Return(true)));
1006 CreateRootHelper create_root(this, syncer::TYPED_URLS); 995 CreateRootHelper create_root(this, syncer::TYPED_URLS);
1007 StartSyncService(create_root.callback()); 996 StartSyncService(create_root.callback());
1008 997
1009 history::VisitVector updated_visits; 998 history::VisitVector updated_visits;
1010 // Update the previous entries and add a new localhost. 999 // Update the previous entries and add a new localhost.
1011 history::URLRow updated_url_entry(MakeTypedUrlEntry( 1000 history::URLRow updated_url_entry(MakeTypedUrlEntry(
1012 "http://yey.com", "yey", 20, 15, false, &updated_visits)); 1001 "http://yey.com", "yey", 20, 15, false, &updated_visits));
1013 history::URLRow updated_localhost_entry(MakeTypedUrlEntry( 1002 history::URLRow updated_localhost_entry(MakeTypedUrlEntry(
1014 "http://localhost:80", "localhost", 20, 15, false, &original_visits)); 1003 "http://localhost:80", "localhost", 20, 15, false, &original_visits));
1015 history::URLRow localhost_ip_entry(MakeTypedUrlEntry( 1004 history::URLRow localhost_ip_entry(MakeTypedUrlEntry(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 SendNotificationURLsModified(changed_urls); 1036 SendNotificationURLsModified(changed_urls);
1048 1037
1049 history::URLRows new_sync_entries; 1038 history::URLRows new_sync_entries;
1050 GetTypedUrlsFromSyncDB(&new_sync_entries); 1039 GetTypedUrlsFromSyncDB(&new_sync_entries);
1051 1040
1052 // The change should be ignored. 1041 // The change should be ignored.
1053 ASSERT_EQ(0U, new_sync_entries.size()); 1042 ASSERT_EQ(0U, new_sync_entries.size());
1054 } 1043 }
1055 1044
1056 } // namespace browser_sync 1045 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698