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

Side by Side Diff: chrome/browser/history/history_backend_unittest.cc

Issue 7104088: Changed typed url sync to no longer modify typed/visit_count. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated per review comments. Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/history/history_backend.cc ('k') | chrome/browser/history/history_types.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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<VisitInfo> visits1, visits2;
700 visits1.push_back(Time::Now() - base::TimeDelta::FromDays(5)); 700 visits1.push_back(VisitInfo(
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(VisitInfo(
703 Time::Now() - base::TimeDelta::FromDays(1), PageTransition::LINK));
704 visits1.push_back(VisitInfo(
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(VisitInfo(
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(VisitInfo(Time::Now(), PageTransition::LINK));
708 711
709 // Clear all history. 712 // Clear all history.
710 backend_->DeleteAllHistory(); 713 backend_->DeleteAllHistory();
711 714
712 // Add the visits. 715 // Add the visits.
713 backend_->AddVisits(url1, visits1, history::SOURCE_IE_IMPORTED); 716 backend_->AddVisits(url1, visits1, history::SOURCE_IE_IMPORTED);
714 backend_->AddVisits(url2, visits2, history::SOURCE_SYNCED); 717 backend_->AddVisits(url2, visits2, history::SOURCE_SYNCED);
715 718
716 // Verify the visits were added with their sources. 719 // Verify the visits were added with their sources.
717 VisitVector visits; 720 VisitVector visits;
(...skipping 12 matching lines...) Expand all
730 backend_->db_->GetVisitsSource(visits, &visit_sources); 733 backend_->db_->GetVisitsSource(visits, &visit_sources);
731 ASSERT_EQ(2U, visit_sources.size()); 734 ASSERT_EQ(2U, visit_sources.size());
732 for (int i = 0; i < 2; i++) 735 for (int i = 0; i < 2; i++)
733 EXPECT_EQ(history::SOURCE_SYNCED, visit_sources[visits[i].visit_id]); 736 EXPECT_EQ(history::SOURCE_SYNCED, visit_sources[visits[i].visit_id]);
734 } 737 }
735 738
736 TEST_F(HistoryBackendTest, RemoveVisitsSource) { 739 TEST_F(HistoryBackendTest, RemoveVisitsSource) {
737 ASSERT_TRUE(backend_.get()); 740 ASSERT_TRUE(backend_.get());
738 741
739 GURL url1("http://www.cnn.com"); 742 GURL url1("http://www.cnn.com");
740 std::vector<base::Time> visits1; 743 std::vector<VisitInfo> visits1, visits2;
741 visits1.push_back(Time::Now() - base::TimeDelta::FromDays(5)); 744 visits1.push_back(VisitInfo(
742 visits1.push_back(Time::Now()); 745 Time::Now() - base::TimeDelta::FromDays(5), PageTransition::LINK));
746 visits1.push_back(VisitInfo(Time::Now(), PageTransition::LINK));
743 747
744 GURL url2("http://www.example.com"); 748 GURL url2("http://www.example.com");
745 std::vector<base::Time> visits2; 749 visits2.push_back(VisitInfo(
746 visits2.push_back(Time::Now() - base::TimeDelta::FromDays(10)); 750 Time::Now() - base::TimeDelta::FromDays(10), PageTransition::LINK));
747 visits2.push_back(Time::Now()); 751 visits2.push_back(VisitInfo(Time::Now(), PageTransition::LINK));
748 752
749 // Clear all history. 753 // Clear all history.
750 backend_->DeleteAllHistory(); 754 backend_->DeleteAllHistory();
751 755
752 // Add the visits. 756 // Add the visits.
753 backend_->AddVisits(url1, visits1, history::SOURCE_IE_IMPORTED); 757 backend_->AddVisits(url1, visits1, history::SOURCE_IE_IMPORTED);
754 backend_->AddVisits(url2, visits2, history::SOURCE_SYNCED); 758 backend_->AddVisits(url2, visits2, history::SOURCE_SYNCED);
755 759
756 // Verify the visits of url1 were added. 760 // Verify the visits of url1 were added.
757 VisitVector visits; 761 VisitVector visits;
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 url, icon_id, FAVICON, &replaced)); 926 url, icon_id, FAVICON, &replaced));
923 EXPECT_EQ(0, replaced); 927 EXPECT_EQ(0, replaced);
924 928
925 std::vector<IconMapping> icon_mapping; 929 std::vector<IconMapping> icon_mapping;
926 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( 930 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL(
927 url, &icon_mapping)); 931 url, &icon_mapping));
928 EXPECT_EQ(1u, icon_mapping.size()); 932 EXPECT_EQ(1u, icon_mapping.size());
929 } 933 }
930 934
931 } // namespace history 935 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/history_backend.cc ('k') | chrome/browser/history/history_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698