OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <set> | 5 #include <set> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 history::RedirectList redirects; | 85 history::RedirectList redirects; |
86 for (int i = 0; sequence[i] != NULL; ++i) | 86 for (int i = 0; sequence[i] != NULL; ++i) |
87 redirects.push_back(GURL(sequence[i])); | 87 redirects.push_back(GURL(sequence[i])); |
88 | 88 |
89 int int_scope = 1; | 89 int int_scope = 1; |
90 void* scope = 0; | 90 void* scope = 0; |
91 memcpy(&scope, &int_scope, sizeof(int_scope)); | 91 memcpy(&scope, &int_scope, sizeof(int_scope)); |
92 scoped_refptr<history::HistoryAddPageArgs> request( | 92 scoped_refptr<history::HistoryAddPageArgs> request( |
93 new history::HistoryAddPageArgs( | 93 new history::HistoryAddPageArgs( |
94 redirects.back(), Time::Now(), scope, page_id, GURL(), | 94 redirects.back(), Time::Now(), scope, page_id, GURL(), |
95 redirects, PageTransition::LINK, history::SOURCE_BROWSED, true)); | 95 redirects, content::PAGE_TRANSITION_LINK, history::SOURCE_BROWSED, |
| 96 true)); |
96 backend_->AddPage(request); | 97 backend_->AddPage(request); |
97 } | 98 } |
98 | 99 |
99 // Adds CLIENT_REDIRECT page transition. | 100 // Adds CLIENT_REDIRECT page transition. |
100 // |url1| is the source URL and |url2| is the destination. | 101 // |url1| is the source URL and |url2| is the destination. |
101 // |did_replace| is true if the transition is non-user initiated and the | 102 // |did_replace| is true if the transition is non-user initiated and the |
102 // navigation entry for |url2| has replaced that for |url1|. The possibly | 103 // navigation entry for |url2| has replaced that for |url1|. The possibly |
103 // updated transition code of the visit records for |url1| and |url2| is | 104 // updated transition code of the visit records for |url1| and |url2| is |
104 // returned by filling in |*transition1| and |*transition2|, respectively. | 105 // returned by filling in |*transition1| and |*transition2|, respectively. |
105 void AddClientRedirect(const GURL& url1, const GURL& url2, bool did_replace, | 106 void AddClientRedirect(const GURL& url1, const GURL& url2, bool did_replace, |
106 int* transition1, int* transition2) { | 107 int* transition1, int* transition2) { |
107 void* const dummy_scope = reinterpret_cast<void*>(0x87654321); | 108 void* const dummy_scope = reinterpret_cast<void*>(0x87654321); |
108 history::RedirectList redirects; | 109 history::RedirectList redirects; |
109 if (url1.is_valid()) | 110 if (url1.is_valid()) |
110 redirects.push_back(url1); | 111 redirects.push_back(url1); |
111 if (url2.is_valid()) | 112 if (url2.is_valid()) |
112 redirects.push_back(url2); | 113 redirects.push_back(url2); |
113 scoped_refptr<HistoryAddPageArgs> request( | 114 scoped_refptr<HistoryAddPageArgs> request( |
114 new HistoryAddPageArgs(url2, base::Time(), dummy_scope, 0, url1, | 115 new HistoryAddPageArgs(url2, base::Time(), dummy_scope, 0, url1, |
115 redirects, PageTransition::CLIENT_REDIRECT, | 116 redirects, content::PAGE_TRANSITION_CLIENT_REDIRECT, |
116 history::SOURCE_BROWSED, did_replace)); | 117 history::SOURCE_BROWSED, did_replace)); |
117 backend_->AddPage(request); | 118 backend_->AddPage(request); |
118 | 119 |
119 *transition1 = getTransition(url1); | 120 *transition1 = getTransition(url1); |
120 *transition2 = getTransition(url2); | 121 *transition2 = getTransition(url2); |
121 } | 122 } |
122 | 123 |
123 int getTransition(const GURL& url) { | 124 int getTransition(const GURL& url) { |
124 if (!url.is_valid()) | 125 if (!url.is_valid()) |
125 return 0; | 126 return 0; |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 // data for the visited page works. This can happen when clearing the history | 357 // data for the visited page works. This can happen when clearing the history |
357 // immediately after visiting a page. | 358 // immediately after visiting a page. |
358 TEST_F(HistoryBackendTest, DeleteAllThenAddData) { | 359 TEST_F(HistoryBackendTest, DeleteAllThenAddData) { |
359 ASSERT_TRUE(backend_.get()); | 360 ASSERT_TRUE(backend_.get()); |
360 | 361 |
361 Time visit_time = Time::Now(); | 362 Time visit_time = Time::Now(); |
362 GURL url("http://www.google.com/"); | 363 GURL url("http://www.google.com/"); |
363 scoped_refptr<HistoryAddPageArgs> request( | 364 scoped_refptr<HistoryAddPageArgs> request( |
364 new HistoryAddPageArgs(url, visit_time, NULL, 0, GURL(), | 365 new HistoryAddPageArgs(url, visit_time, NULL, 0, GURL(), |
365 history::RedirectList(), | 366 history::RedirectList(), |
366 PageTransition::KEYWORD_GENERATED, | 367 content::PAGE_TRANSITION_KEYWORD_GENERATED, |
367 history::SOURCE_BROWSED, false)); | 368 history::SOURCE_BROWSED, false)); |
368 backend_->AddPage(request); | 369 backend_->AddPage(request); |
369 | 370 |
370 // Check that a row was added. | 371 // Check that a row was added. |
371 URLRow outrow; | 372 URLRow outrow; |
372 EXPECT_TRUE(backend_->db_->GetRowForURL(url, &outrow)); | 373 EXPECT_TRUE(backend_->db_->GetRowForURL(url, &outrow)); |
373 | 374 |
374 // Check that the visit was added. | 375 // Check that the visit was added. |
375 VisitVector all_visits; | 376 VisitVector all_visits; |
376 backend_->db_->GetAllVisitsInRange(Time(), Time(), 0, &all_visits); | 377 backend_->db_->GetAllVisitsInRange(Time(), Time(), 0, &all_visits); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 // KEYWORD_GENERATED. | 509 // KEYWORD_GENERATED. |
509 TEST_F(HistoryBackendTest, KeywordGenerated) { | 510 TEST_F(HistoryBackendTest, KeywordGenerated) { |
510 ASSERT_TRUE(backend_.get()); | 511 ASSERT_TRUE(backend_.get()); |
511 | 512 |
512 GURL url("http://google.com"); | 513 GURL url("http://google.com"); |
513 | 514 |
514 Time visit_time = Time::Now() - base::TimeDelta::FromDays(1); | 515 Time visit_time = Time::Now() - base::TimeDelta::FromDays(1); |
515 scoped_refptr<HistoryAddPageArgs> request( | 516 scoped_refptr<HistoryAddPageArgs> request( |
516 new HistoryAddPageArgs(url, visit_time, NULL, 0, GURL(), | 517 new HistoryAddPageArgs(url, visit_time, NULL, 0, GURL(), |
517 history::RedirectList(), | 518 history::RedirectList(), |
518 PageTransition::KEYWORD_GENERATED, | 519 content::PAGE_TRANSITION_KEYWORD_GENERATED, |
519 history::SOURCE_BROWSED, false)); | 520 history::SOURCE_BROWSED, false)); |
520 backend_->AddPage(request); | 521 backend_->AddPage(request); |
521 | 522 |
522 // A row should have been added for the url. | 523 // A row should have been added for the url. |
523 URLRow row; | 524 URLRow row; |
524 URLID url_id = backend_->db()->GetRowForURL(url, &row); | 525 URLID url_id = backend_->db()->GetRowForURL(url, &row); |
525 ASSERT_NE(0, url_id); | 526 ASSERT_NE(0, url_id); |
526 | 527 |
527 // The typed count should be 1. | 528 // The typed count should be 1. |
528 ASSERT_EQ(1, row.typed_count()); | 529 ASSERT_EQ(1, row.typed_count()); |
(...skipping 29 matching lines...) Expand all Loading... |
558 | 559 |
559 TEST_F(HistoryBackendTest, ClientRedirect) { | 560 TEST_F(HistoryBackendTest, ClientRedirect) { |
560 ASSERT_TRUE(backend_.get()); | 561 ASSERT_TRUE(backend_.get()); |
561 | 562 |
562 int transition1; | 563 int transition1; |
563 int transition2; | 564 int transition2; |
564 | 565 |
565 // Initial transition to page A. | 566 // Initial transition to page A. |
566 GURL url_a("http://google.com/a"); | 567 GURL url_a("http://google.com/a"); |
567 AddClientRedirect(GURL(), url_a, false, &transition1, &transition2); | 568 AddClientRedirect(GURL(), url_a, false, &transition1, &transition2); |
568 EXPECT_TRUE(transition2 & PageTransition::CHAIN_END); | 569 EXPECT_TRUE(transition2 & content::PAGE_TRANSITION_CHAIN_END); |
569 | 570 |
570 // User initiated redirect to page B. | 571 // User initiated redirect to page B. |
571 GURL url_b("http://google.com/b"); | 572 GURL url_b("http://google.com/b"); |
572 AddClientRedirect(url_a, url_b, false, &transition1, &transition2); | 573 AddClientRedirect(url_a, url_b, false, &transition1, &transition2); |
573 EXPECT_TRUE(transition1 & PageTransition::CHAIN_END); | 574 EXPECT_TRUE(transition1 & content::PAGE_TRANSITION_CHAIN_END); |
574 EXPECT_TRUE(transition2 & PageTransition::CHAIN_END); | 575 EXPECT_TRUE(transition2 & content::PAGE_TRANSITION_CHAIN_END); |
575 | 576 |
576 // Non-user initiated redirect to page C. | 577 // Non-user initiated redirect to page C. |
577 GURL url_c("http://google.com/c"); | 578 GURL url_c("http://google.com/c"); |
578 AddClientRedirect(url_b, url_c, true, &transition1, &transition2); | 579 AddClientRedirect(url_b, url_c, true, &transition1, &transition2); |
579 EXPECT_FALSE(transition1 & PageTransition::CHAIN_END); | 580 EXPECT_FALSE(transition1 & content::PAGE_TRANSITION_CHAIN_END); |
580 EXPECT_TRUE(transition2 & PageTransition::CHAIN_END); | 581 EXPECT_TRUE(transition2 & content::PAGE_TRANSITION_CHAIN_END); |
581 } | 582 } |
582 | 583 |
583 TEST_F(HistoryBackendTest, ImportedFaviconsTest) { | 584 TEST_F(HistoryBackendTest, ImportedFaviconsTest) { |
584 // Setup test data - two Urls in the history, one with favicon assigned and | 585 // Setup test data - two Urls in the history, one with favicon assigned and |
585 // one without. | 586 // one without. |
586 GURL favicon_url1("http://www.google.com/favicon.ico"); | 587 GURL favicon_url1("http://www.google.com/favicon.ico"); |
587 FaviconID favicon1 = backend_->thumbnail_db_->AddFavicon(favicon_url1, | 588 FaviconID favicon1 = backend_->thumbnail_db_->AddFavicon(favicon_url1, |
588 FAVICON); | 589 FAVICON); |
589 std::vector<unsigned char> data; | 590 std::vector<unsigned char> data; |
590 data.push_back('1'); | 591 data.push_back('1'); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 ASSERT_TRUE(backend_.get()); | 651 ASSERT_TRUE(backend_.get()); |
651 | 652 |
652 GURL url("http://anyuser:anypass@www.google.com"); | 653 GURL url("http://anyuser:anypass@www.google.com"); |
653 GURL stripped_url("http://www.google.com"); | 654 GURL stripped_url("http://www.google.com"); |
654 | 655 |
655 // Clear all history. | 656 // Clear all history. |
656 backend_->DeleteAllHistory(); | 657 backend_->DeleteAllHistory(); |
657 | 658 |
658 // Visit the url with username, password. | 659 // Visit the url with username, password. |
659 backend_->AddPageVisit(url, base::Time::Now(), 0, | 660 backend_->AddPageVisit(url, base::Time::Now(), 0, |
660 PageTransition::GetQualifier(PageTransition::TYPED), | 661 content::PageTransitionFromInt( |
661 history::SOURCE_BROWSED); | 662 content::PageTransitionGetQualifier(content::PAGE_TRANSITION_TYPED)), |
| 663 history::SOURCE_BROWSED); |
662 | 664 |
663 // Fetch the row information about stripped url from history db. | 665 // Fetch the row information about stripped url from history db. |
664 VisitVector visits; | 666 VisitVector visits; |
665 URLID row_id = backend_->db_->GetRowForURL(stripped_url, NULL); | 667 URLID row_id = backend_->db_->GetRowForURL(stripped_url, NULL); |
666 backend_->db_->GetVisitsForURL(row_id, &visits); | 668 backend_->db_->GetVisitsForURL(row_id, &visits); |
667 | 669 |
668 // Check if stripped url is stored in database. | 670 // Check if stripped url is stored in database. |
669 ASSERT_EQ(1U, visits.size()); | 671 ASSERT_EQ(1U, visits.size()); |
670 } | 672 } |
671 | 673 |
672 TEST_F(HistoryBackendTest, AddPageVisitSource) { | 674 TEST_F(HistoryBackendTest, AddPageVisitSource) { |
673 ASSERT_TRUE(backend_.get()); | 675 ASSERT_TRUE(backend_.get()); |
674 | 676 |
675 GURL url("http://www.google.com"); | 677 GURL url("http://www.google.com"); |
676 | 678 |
677 // Clear all history. | 679 // Clear all history. |
678 backend_->DeleteAllHistory(); | 680 backend_->DeleteAllHistory(); |
679 | 681 |
680 // Assume visiting the url from an externsion. | 682 // Assume visiting the url from an externsion. |
681 backend_->AddPageVisit(url, base::Time::Now(), 0, PageTransition::TYPED, | 683 backend_->AddPageVisit( |
682 history::SOURCE_EXTENSION); | 684 url, base::Time::Now(), 0, content::PAGE_TRANSITION_TYPED, |
| 685 history::SOURCE_EXTENSION); |
683 // Assume the url is imported from Firefox. | 686 // Assume the url is imported from Firefox. |
684 backend_->AddPageVisit(url, base::Time::Now(), 0, PageTransition::TYPED, | 687 backend_->AddPageVisit(url, base::Time::Now(), 0, |
| 688 content::PAGE_TRANSITION_TYPED, |
685 history::SOURCE_FIREFOX_IMPORTED); | 689 history::SOURCE_FIREFOX_IMPORTED); |
686 // Assume this url is also synced. | 690 // Assume this url is also synced. |
687 backend_->AddPageVisit(url, base::Time::Now(), 0, PageTransition::TYPED, | 691 backend_->AddPageVisit(url, base::Time::Now(), 0, |
| 692 content::PAGE_TRANSITION_TYPED, |
688 history::SOURCE_SYNCED); | 693 history::SOURCE_SYNCED); |
689 | 694 |
690 // Fetch the row information about the url from history db. | 695 // Fetch the row information about the url from history db. |
691 VisitVector visits; | 696 VisitVector visits; |
692 URLID row_id = backend_->db_->GetRowForURL(url, NULL); | 697 URLID row_id = backend_->db_->GetRowForURL(url, NULL); |
693 backend_->db_->GetVisitsForURL(row_id, &visits); | 698 backend_->db_->GetVisitsForURL(row_id, &visits); |
694 | 699 |
695 // Check if all the visits to the url are stored in database. | 700 // Check if all the visits to the url are stored in database. |
696 ASSERT_EQ(3U, visits.size()); | 701 ASSERT_EQ(3U, visits.size()); |
697 VisitSourceMap visit_sources; | 702 VisitSourceMap visit_sources; |
(...skipping 19 matching lines...) Expand all Loading... |
717 | 722 |
718 TEST_F(HistoryBackendTest, AddPageArgsSource) { | 723 TEST_F(HistoryBackendTest, AddPageArgsSource) { |
719 ASSERT_TRUE(backend_.get()); | 724 ASSERT_TRUE(backend_.get()); |
720 | 725 |
721 GURL url("http://testpageargs.com"); | 726 GURL url("http://testpageargs.com"); |
722 | 727 |
723 // Assume this page is browsed by user. | 728 // Assume this page is browsed by user. |
724 scoped_refptr<HistoryAddPageArgs> request1( | 729 scoped_refptr<HistoryAddPageArgs> request1( |
725 new HistoryAddPageArgs(url, base::Time::Now(), NULL, 0, GURL(), | 730 new HistoryAddPageArgs(url, base::Time::Now(), NULL, 0, GURL(), |
726 history::RedirectList(), | 731 history::RedirectList(), |
727 PageTransition::KEYWORD_GENERATED, | 732 content::PAGE_TRANSITION_KEYWORD_GENERATED, |
728 history::SOURCE_BROWSED, false)); | 733 history::SOURCE_BROWSED, false)); |
729 backend_->AddPage(request1); | 734 backend_->AddPage(request1); |
730 // Assume this page is synced. | 735 // Assume this page is synced. |
731 scoped_refptr<HistoryAddPageArgs> request2( | 736 scoped_refptr<HistoryAddPageArgs> request2( |
732 new HistoryAddPageArgs(url, base::Time::Now(), NULL, 0, GURL(), | 737 new HistoryAddPageArgs(url, base::Time::Now(), NULL, 0, GURL(), |
733 history::RedirectList(), | 738 history::RedirectList(), |
734 PageTransition::LINK, | 739 content::PAGE_TRANSITION_LINK, |
735 history::SOURCE_SYNCED, false)); | 740 history::SOURCE_SYNCED, false)); |
736 backend_->AddPage(request2); | 741 backend_->AddPage(request2); |
737 // Assume this page is browsed again. | 742 // Assume this page is browsed again. |
738 scoped_refptr<HistoryAddPageArgs> request3( | 743 scoped_refptr<HistoryAddPageArgs> request3( |
739 new HistoryAddPageArgs(url, base::Time::Now(), NULL, 0, GURL(), | 744 new HistoryAddPageArgs(url, base::Time::Now(), NULL, 0, GURL(), |
740 history::RedirectList(), | 745 history::RedirectList(), |
741 PageTransition::TYPED, | 746 content::PAGE_TRANSITION_TYPED, |
742 history::SOURCE_BROWSED, false)); | 747 history::SOURCE_BROWSED, false)); |
743 backend_->AddPage(request3); | 748 backend_->AddPage(request3); |
744 | 749 |
745 // Three visits should be added with proper sources. | 750 // Three visits should be added with proper sources. |
746 VisitVector visits; | 751 VisitVector visits; |
747 URLRow row; | 752 URLRow row; |
748 URLID id = backend_->db()->GetRowForURL(url, &row); | 753 URLID id = backend_->db()->GetRowForURL(url, &row); |
749 ASSERT_TRUE(backend_->db()->GetVisitsForURL(id, &visits)); | 754 ASSERT_TRUE(backend_->db()->GetVisitsForURL(id, &visits)); |
750 ASSERT_EQ(3U, visits.size()); | 755 ASSERT_EQ(3U, visits.size()); |
751 VisitSourceMap visit_sources; | 756 VisitSourceMap visit_sources; |
752 backend_->db_->GetVisitsSource(visits, &visit_sources); | 757 backend_->db_->GetVisitsSource(visits, &visit_sources); |
753 ASSERT_EQ(1U, visit_sources.size()); | 758 ASSERT_EQ(1U, visit_sources.size()); |
754 EXPECT_EQ(history::SOURCE_SYNCED, visit_sources.begin()->second); | 759 EXPECT_EQ(history::SOURCE_SYNCED, visit_sources.begin()->second); |
755 } | 760 } |
756 | 761 |
757 TEST_F(HistoryBackendTest, AddVisitsSource) { | 762 TEST_F(HistoryBackendTest, AddVisitsSource) { |
758 ASSERT_TRUE(backend_.get()); | 763 ASSERT_TRUE(backend_.get()); |
759 | 764 |
760 GURL url1("http://www.cnn.com"); | 765 GURL url1("http://www.cnn.com"); |
761 std::vector<VisitInfo> visits1, visits2; | 766 std::vector<VisitInfo> visits1, visits2; |
762 visits1.push_back(VisitInfo( | 767 visits1.push_back(VisitInfo( |
763 Time::Now() - base::TimeDelta::FromDays(5), PageTransition::LINK)); | 768 Time::Now() - base::TimeDelta::FromDays(5), |
| 769 content::PAGE_TRANSITION_LINK)); |
764 visits1.push_back(VisitInfo( | 770 visits1.push_back(VisitInfo( |
765 Time::Now() - base::TimeDelta::FromDays(1), PageTransition::LINK)); | 771 Time::Now() - base::TimeDelta::FromDays(1), |
| 772 content::PAGE_TRANSITION_LINK)); |
766 visits1.push_back(VisitInfo( | 773 visits1.push_back(VisitInfo( |
767 Time::Now(), PageTransition::LINK)); | 774 Time::Now(), content::PAGE_TRANSITION_LINK)); |
768 | 775 |
769 GURL url2("http://www.example.com"); | 776 GURL url2("http://www.example.com"); |
770 visits2.push_back(VisitInfo( | 777 visits2.push_back(VisitInfo( |
771 Time::Now() - base::TimeDelta::FromDays(10), PageTransition::LINK)); | 778 Time::Now() - base::TimeDelta::FromDays(10), |
772 visits2.push_back(VisitInfo(Time::Now(), PageTransition::LINK)); | 779 content::PAGE_TRANSITION_LINK)); |
| 780 visits2.push_back(VisitInfo(Time::Now(), content::PAGE_TRANSITION_LINK)); |
773 | 781 |
774 // Clear all history. | 782 // Clear all history. |
775 backend_->DeleteAllHistory(); | 783 backend_->DeleteAllHistory(); |
776 | 784 |
777 // Add the visits. | 785 // Add the visits. |
778 backend_->AddVisits(url1, visits1, history::SOURCE_IE_IMPORTED); | 786 backend_->AddVisits(url1, visits1, history::SOURCE_IE_IMPORTED); |
779 backend_->AddVisits(url2, visits2, history::SOURCE_SYNCED); | 787 backend_->AddVisits(url2, visits2, history::SOURCE_SYNCED); |
780 | 788 |
781 // Verify the visits were added with their sources. | 789 // Verify the visits were added with their sources. |
782 VisitVector visits; | 790 VisitVector visits; |
(...skipping 14 matching lines...) Expand all Loading... |
797 for (int i = 0; i < 2; i++) | 805 for (int i = 0; i < 2; i++) |
798 EXPECT_EQ(history::SOURCE_SYNCED, visit_sources[visits[i].visit_id]); | 806 EXPECT_EQ(history::SOURCE_SYNCED, visit_sources[visits[i].visit_id]); |
799 } | 807 } |
800 | 808 |
801 TEST_F(HistoryBackendTest, GetMostRecentVisits) { | 809 TEST_F(HistoryBackendTest, GetMostRecentVisits) { |
802 ASSERT_TRUE(backend_.get()); | 810 ASSERT_TRUE(backend_.get()); |
803 | 811 |
804 GURL url1("http://www.cnn.com"); | 812 GURL url1("http://www.cnn.com"); |
805 std::vector<VisitInfo> visits1; | 813 std::vector<VisitInfo> visits1; |
806 visits1.push_back(VisitInfo( | 814 visits1.push_back(VisitInfo( |
807 Time::Now() - base::TimeDelta::FromDays(5), PageTransition::LINK)); | 815 Time::Now() - base::TimeDelta::FromDays(5), |
| 816 content::PAGE_TRANSITION_LINK)); |
808 visits1.push_back(VisitInfo( | 817 visits1.push_back(VisitInfo( |
809 Time::Now() - base::TimeDelta::FromDays(1), PageTransition::LINK)); | 818 Time::Now() - base::TimeDelta::FromDays(1), |
| 819 content::PAGE_TRANSITION_LINK)); |
810 visits1.push_back(VisitInfo( | 820 visits1.push_back(VisitInfo( |
811 Time::Now(), PageTransition::LINK)); | 821 Time::Now(), content::PAGE_TRANSITION_LINK)); |
812 | 822 |
813 // Clear all history. | 823 // Clear all history. |
814 backend_->DeleteAllHistory(); | 824 backend_->DeleteAllHistory(); |
815 | 825 |
816 // Add the visits. | 826 // Add the visits. |
817 backend_->AddVisits(url1, visits1, history::SOURCE_IE_IMPORTED); | 827 backend_->AddVisits(url1, visits1, history::SOURCE_IE_IMPORTED); |
818 | 828 |
819 // Verify the visits were added with their sources. | 829 // Verify the visits were added with their sources. |
820 VisitVector visits; | 830 VisitVector visits; |
821 URLRow row; | 831 URLRow row; |
822 URLID id = backend_->db()->GetRowForURL(url1, &row); | 832 URLID id = backend_->db()->GetRowForURL(url1, &row); |
823 ASSERT_TRUE(backend_->db()->GetMostRecentVisitsForURL(id, 1, &visits)); | 833 ASSERT_TRUE(backend_->db()->GetMostRecentVisitsForURL(id, 1, &visits)); |
824 ASSERT_EQ(1U, visits.size()); | 834 ASSERT_EQ(1U, visits.size()); |
825 EXPECT_EQ(visits1[2].first, visits[0].visit_time); | 835 EXPECT_EQ(visits1[2].first, visits[0].visit_time); |
826 } | 836 } |
827 | 837 |
828 TEST_F(HistoryBackendTest, RemoveVisitsTransitions) { | 838 TEST_F(HistoryBackendTest, RemoveVisitsTransitions) { |
829 ASSERT_TRUE(backend_.get()); | 839 ASSERT_TRUE(backend_.get()); |
830 | 840 |
831 // Clear all history. | 841 // Clear all history. |
832 backend_->DeleteAllHistory(); | 842 backend_->DeleteAllHistory(); |
833 | 843 |
834 GURL url1("http://www.cnn.com"); | 844 GURL url1("http://www.cnn.com"); |
835 VisitInfo typed_visit( | 845 VisitInfo typed_visit( |
836 Time::Now() - base::TimeDelta::FromDays(6), PageTransition::TYPED); | 846 Time::Now() - base::TimeDelta::FromDays(6), |
| 847 content::PAGE_TRANSITION_TYPED); |
837 VisitInfo reload_visit( | 848 VisitInfo reload_visit( |
838 Time::Now() - base::TimeDelta::FromDays(5), PageTransition::RELOAD); | 849 Time::Now() - base::TimeDelta::FromDays(5), |
| 850 content::PAGE_TRANSITION_RELOAD); |
839 VisitInfo link_visit( | 851 VisitInfo link_visit( |
840 Time::Now() - base::TimeDelta::FromDays(4), PageTransition::LINK); | 852 Time::Now() - base::TimeDelta::FromDays(4), |
| 853 content::PAGE_TRANSITION_LINK); |
841 std::vector<VisitInfo> visits_to_add; | 854 std::vector<VisitInfo> visits_to_add; |
842 visits_to_add.push_back(typed_visit); | 855 visits_to_add.push_back(typed_visit); |
843 visits_to_add.push_back(reload_visit); | 856 visits_to_add.push_back(reload_visit); |
844 visits_to_add.push_back(link_visit); | 857 visits_to_add.push_back(link_visit); |
845 | 858 |
846 // Add the visits. | 859 // Add the visits. |
847 backend_->AddVisits(url1, visits_to_add, history::SOURCE_SYNCED); | 860 backend_->AddVisits(url1, visits_to_add, history::SOURCE_SYNCED); |
848 | 861 |
849 // Verify that the various counts are what we expect. | 862 // Verify that the various counts are what we expect. |
850 VisitVector visits; | 863 VisitVector visits; |
(...skipping 25 matching lines...) Expand all Loading... |
876 ASSERT_TRUE(backend_->RemoveVisits(VisitVector(1, visits[0]))); | 889 ASSERT_TRUE(backend_->RemoveVisits(VisitVector(1, visits[0]))); |
877 ASSERT_EQ(0, backend_->db()->GetRowForURL(url1, &row)); | 890 ASSERT_EQ(0, backend_->db()->GetRowForURL(url1, &row)); |
878 } | 891 } |
879 | 892 |
880 TEST_F(HistoryBackendTest, RemoveVisitsSource) { | 893 TEST_F(HistoryBackendTest, RemoveVisitsSource) { |
881 ASSERT_TRUE(backend_.get()); | 894 ASSERT_TRUE(backend_.get()); |
882 | 895 |
883 GURL url1("http://www.cnn.com"); | 896 GURL url1("http://www.cnn.com"); |
884 std::vector<VisitInfo> visits1, visits2; | 897 std::vector<VisitInfo> visits1, visits2; |
885 visits1.push_back(VisitInfo( | 898 visits1.push_back(VisitInfo( |
886 Time::Now() - base::TimeDelta::FromDays(5), PageTransition::LINK)); | 899 Time::Now() - base::TimeDelta::FromDays(5), |
887 visits1.push_back(VisitInfo(Time::Now(), PageTransition::LINK)); | 900 content::PAGE_TRANSITION_LINK)); |
| 901 visits1.push_back(VisitInfo(Time::Now(), |
| 902 content::PAGE_TRANSITION_LINK)); |
888 | 903 |
889 GURL url2("http://www.example.com"); | 904 GURL url2("http://www.example.com"); |
890 visits2.push_back(VisitInfo( | 905 visits2.push_back(VisitInfo( |
891 Time::Now() - base::TimeDelta::FromDays(10), PageTransition::LINK)); | 906 Time::Now() - base::TimeDelta::FromDays(10), |
892 visits2.push_back(VisitInfo(Time::Now(), PageTransition::LINK)); | 907 content::PAGE_TRANSITION_LINK)); |
| 908 visits2.push_back(VisitInfo(Time::Now(), content::PAGE_TRANSITION_LINK)); |
893 | 909 |
894 // Clear all history. | 910 // Clear all history. |
895 backend_->DeleteAllHistory(); | 911 backend_->DeleteAllHistory(); |
896 | 912 |
897 // Add the visits. | 913 // Add the visits. |
898 backend_->AddVisits(url1, visits1, history::SOURCE_IE_IMPORTED); | 914 backend_->AddVisits(url1, visits1, history::SOURCE_IE_IMPORTED); |
899 backend_->AddVisits(url2, visits2, history::SOURCE_SYNCED); | 915 backend_->AddVisits(url2, visits2, history::SOURCE_SYNCED); |
900 | 916 |
901 // Verify the visits of url1 were added. | 917 // Verify the visits of url1 were added. |
902 VisitVector visits; | 918 VisitVector visits; |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 ASSERT_TRUE(backend_->GetFaviconFromDB(url, TOUCH_ICON, &favicon)); | 1128 ASSERT_TRUE(backend_->GetFaviconFromDB(url, TOUCH_ICON, &favicon)); |
1113 std::string touchicon_data( | 1129 std::string touchicon_data( |
1114 favicon.image_data->front(), | 1130 favicon.image_data->front(), |
1115 favicon.image_data->front() + favicon.image_data->size()); | 1131 favicon.image_data->front() + favicon.image_data->size()); |
1116 | 1132 |
1117 EXPECT_EQ(TOUCH_ICON, favicon.icon_type); | 1133 EXPECT_EQ(TOUCH_ICON, favicon.icon_type); |
1118 EXPECT_EQ(icon_url, favicon.icon_url); | 1134 EXPECT_EQ(icon_url, favicon.icon_url); |
1119 EXPECT_EQ(blob_data, touchicon_data); | 1135 EXPECT_EQ(blob_data, touchicon_data); |
1120 } | 1136 } |
1121 } // namespace history | 1137 } // namespace history |
OLD | NEW |