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 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 VisitSourceMap visit_sources; | 689 VisitSourceMap visit_sources; |
690 backend_->db_->GetVisitsSource(visits, &visit_sources); | 690 backend_->db_->GetVisitsSource(visits, &visit_sources); |
691 ASSERT_EQ(1U, visit_sources.size()); | 691 ASSERT_EQ(1U, visit_sources.size()); |
692 EXPECT_EQ(history::SOURCE_SYNCED, visit_sources.begin()->second); | 692 EXPECT_EQ(history::SOURCE_SYNCED, visit_sources.begin()->second); |
693 } | 693 } |
694 | 694 |
695 TEST_F(HistoryBackendTest, AddVisitsSource) { | 695 TEST_F(HistoryBackendTest, AddVisitsSource) { |
696 ASSERT_TRUE(backend_.get()); | 696 ASSERT_TRUE(backend_.get()); |
697 | 697 |
698 GURL url1("http://www.cnn.com"); | 698 GURL url1("http://www.cnn.com"); |
699 std::vector<base::Time> visits1; | 699 std::vector<std::pair<base::Time, PageTransition::Type> > visits1, visits2; |
700 visits1.push_back(Time::Now() - base::TimeDelta::FromDays(5)); | 700 visits1.push_back(std::pair<base::Time, PageTransition::Type>( |
701 visits1.push_back(Time::Now() - base::TimeDelta::FromDays(1)); | 701 Time::Now() - base::TimeDelta::FromDays(5), PageTransition::LINK)); |
702 visits1.push_back(Time::Now()); | 702 visits1.push_back(std::pair<base::Time, PageTransition::Type>( |
| 703 Time::Now() - base::TimeDelta::FromDays(1), PageTransition::LINK)); |
| 704 visits1.push_back(std::pair<base::Time, PageTransition::Type>( |
| 705 Time::Now(), PageTransition::LINK)); |
703 | 706 |
704 GURL url2("http://www.example.com"); | 707 GURL url2("http://www.example.com"); |
705 std::vector<base::Time> visits2; | 708 visits2.push_back(std::pair<base::Time, PageTransition::Type>( |
706 visits2.push_back(Time::Now() - base::TimeDelta::FromDays(10)); | 709 Time::Now() - base::TimeDelta::FromDays(10), PageTransition::LINK)); |
707 visits2.push_back(Time::Now()); | 710 visits2.push_back(std::pair<base::Time, PageTransition::Type>( |
| 711 Time::Now(), PageTransition::LINK)); |
708 | 712 |
709 // Clear all history. | 713 // Clear all history. |
710 backend_->DeleteAllHistory(); | 714 backend_->DeleteAllHistory(); |
711 | 715 |
712 // Add the visits. | 716 // Add the visits. |
713 backend_->AddVisits(url1, visits1, history::SOURCE_IE_IMPORTED); | 717 backend_->AddVisits(url1, visits1, history::SOURCE_IE_IMPORTED); |
714 backend_->AddVisits(url2, visits2, history::SOURCE_SYNCED); | 718 backend_->AddVisits(url2, visits2, history::SOURCE_SYNCED); |
715 | 719 |
716 // Verify the visits were added with their sources. | 720 // Verify the visits were added with their sources. |
717 VisitVector visits; | 721 VisitVector visits; |
(...skipping 12 matching lines...) Expand all Loading... |
730 backend_->db_->GetVisitsSource(visits, &visit_sources); | 734 backend_->db_->GetVisitsSource(visits, &visit_sources); |
731 ASSERT_EQ(2U, visit_sources.size()); | 735 ASSERT_EQ(2U, visit_sources.size()); |
732 for (int i = 0; i < 2; i++) | 736 for (int i = 0; i < 2; i++) |
733 EXPECT_EQ(history::SOURCE_SYNCED, visit_sources[visits[i].visit_id]); | 737 EXPECT_EQ(history::SOURCE_SYNCED, visit_sources[visits[i].visit_id]); |
734 } | 738 } |
735 | 739 |
736 TEST_F(HistoryBackendTest, RemoveVisitsSource) { | 740 TEST_F(HistoryBackendTest, RemoveVisitsSource) { |
737 ASSERT_TRUE(backend_.get()); | 741 ASSERT_TRUE(backend_.get()); |
738 | 742 |
739 GURL url1("http://www.cnn.com"); | 743 GURL url1("http://www.cnn.com"); |
740 std::vector<base::Time> visits1; | 744 std::vector<std::pair<base::Time, PageTransition::Type> > visits1, visits2; |
741 visits1.push_back(Time::Now() - base::TimeDelta::FromDays(5)); | 745 visits1.push_back(std::pair<base::Time, PageTransition::Type>( |
742 visits1.push_back(Time::Now()); | 746 Time::Now() - base::TimeDelta::FromDays(5), PageTransition::LINK)); |
| 747 visits1.push_back(std::pair<base::Time, PageTransition::Type>( |
| 748 Time::Now(), PageTransition::LINK)); |
743 | 749 |
744 GURL url2("http://www.example.com"); | 750 GURL url2("http://www.example.com"); |
745 std::vector<base::Time> visits2; | 751 visits2.push_back(std::pair<base::Time, PageTransition::Type>( |
746 visits2.push_back(Time::Now() - base::TimeDelta::FromDays(10)); | 752 Time::Now() - base::TimeDelta::FromDays(10), PageTransition::LINK)); |
747 visits2.push_back(Time::Now()); | 753 visits2.push_back(std::pair<base::Time, PageTransition::Type>( |
| 754 Time::Now(), PageTransition::LINK)); |
748 | 755 |
749 // Clear all history. | 756 // Clear all history. |
750 backend_->DeleteAllHistory(); | 757 backend_->DeleteAllHistory(); |
751 | 758 |
752 // Add the visits. | 759 // Add the visits. |
753 backend_->AddVisits(url1, visits1, history::SOURCE_IE_IMPORTED); | 760 backend_->AddVisits(url1, visits1, history::SOURCE_IE_IMPORTED); |
754 backend_->AddVisits(url2, visits2, history::SOURCE_SYNCED); | 761 backend_->AddVisits(url2, visits2, history::SOURCE_SYNCED); |
755 | 762 |
756 // Verify the visits of url1 were added. | 763 // Verify the visits of url1 were added. |
757 VisitVector visits; | 764 VisitVector visits; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 url, icon_id, FAVICON, &replaced)); | 929 url, icon_id, FAVICON, &replaced)); |
923 EXPECT_EQ(0, replaced); | 930 EXPECT_EQ(0, replaced); |
924 | 931 |
925 std::vector<IconMapping> icon_mapping; | 932 std::vector<IconMapping> icon_mapping; |
926 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( | 933 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( |
927 url, &icon_mapping)); | 934 url, &icon_mapping)); |
928 EXPECT_EQ(1u, icon_mapping.size()); | 935 EXPECT_EQ(1u, icon_mapping.size()); |
929 } | 936 } |
930 | 937 |
931 } // namespace history | 938 } // namespace history |
OLD | NEW |