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

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

Issue 10669038: base: Remove dereference structure operator (i.e ->) from ScopedVector. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 5 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/importer/importer_list.cc » ('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) 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 // History unit tests come in two flavors: 5 // History unit tests come in two flavors:
6 // 6 //
7 // 1. The more complicated style is that the unit test creates a full history 7 // 1. The more complicated style is that the unit test creates a full history
8 // service. This spawns a background thread for the history backend, and 8 // service. This spawns a background thread for the history backend, and
9 // all communication is asynchronous. This is useful for testing more 9 // all communication is asynchronous. This is useful for testing more
10 // complicated things or end-to-end behavior. 10 // complicated things or end-to-end behavior.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 backend_ = new HistoryBackend(history_dir_, 0, new BackendDelegate(this), 120 backend_ = new HistoryBackend(history_dir_, 0, new BackendDelegate(this),
121 NULL); 121 NULL);
122 backend_->Init(std::string(), false); 122 backend_->Init(std::string(), false);
123 db_ = backend_->db_.get(); 123 db_ = backend_->db_.get();
124 DCHECK(in_mem_backend_.get()) << "Mem backend should have been set by " 124 DCHECK(in_mem_backend_.get()) << "Mem backend should have been set by "
125 "HistoryBackend::Init"; 125 "HistoryBackend::Init";
126 } 126 }
127 127
128 void OnSegmentUsageAvailable(CancelableRequestProvider::Handle handle, 128 void OnSegmentUsageAvailable(CancelableRequestProvider::Handle handle,
129 std::vector<PageUsageData*>* data) { 129 std::vector<PageUsageData*>* data) {
130 page_usage_data_->swap(*data); 130 page_usage_data_.swap(*data);
131 MessageLoop::current()->Quit(); 131 MessageLoop::current()->Quit();
132 } 132 }
133 133
134 void OnDeleteURLsDone(CancelableRequestProvider::Handle handle) { 134 void OnDeleteURLsDone(CancelableRequestProvider::Handle handle) {
135 MessageLoop::current()->Quit(); 135 MessageLoop::current()->Quit();
136 } 136 }
137 137
138 void OnMostVisitedURLsAvailable(CancelableRequestProvider::Handle handle, 138 void OnMostVisitedURLsAvailable(CancelableRequestProvider::Handle handle,
139 MostVisitedURLList url_list) { 139 MostVisitedURLList url_list) {
140 most_visited_urls_.swap(url_list); 140 most_visited_urls_.swap(url_list);
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 716
717 // Make sure a segment was created. 717 // Make sure a segment was created.
718 history->QuerySegmentUsageSince( 718 history->QuerySegmentUsageSince(
719 &consumer_, Time::Now() - TimeDelta::FromDays(1), 10, 719 &consumer_, Time::Now() - TimeDelta::FromDays(1), 10,
720 base::Bind(&HistoryTest::OnSegmentUsageAvailable, 720 base::Bind(&HistoryTest::OnSegmentUsageAvailable,
721 base::Unretained(this))); 721 base::Unretained(this)));
722 722
723 // Wait for processing. 723 // Wait for processing.
724 MessageLoop::current()->Run(); 724 MessageLoop::current()->Run();
725 725
726 ASSERT_EQ(1U, page_usage_data_->size()); 726 ASSERT_EQ(1U, page_usage_data_.size());
727 EXPECT_TRUE(page_usage_data_[0]->GetURL() == existing_url); 727 EXPECT_TRUE(page_usage_data_[0]->GetURL() == existing_url);
728 EXPECT_DOUBLE_EQ(3.0, page_usage_data_[0]->GetScore()); 728 EXPECT_DOUBLE_EQ(3.0, page_usage_data_[0]->GetScore());
729 729
730 // Add a URL which doesn't create a segment. 730 // Add a URL which doesn't create a segment.
731 const GURL link_url("http://yahoo.com/"); 731 const GURL link_url("http://yahoo.com/");
732 history->AddPage(link_url, scope, 0, GURL(), 732 history->AddPage(link_url, scope, 0, GURL(),
733 content::PAGE_TRANSITION_LINK, history::RedirectList(), 733 content::PAGE_TRANSITION_LINK, history::RedirectList(),
734 history::SOURCE_BROWSED, false); 734 history::SOURCE_BROWSED, false);
735 735
736 // Query again 736 // Query again
737 history->QuerySegmentUsageSince( 737 history->QuerySegmentUsageSince(
738 &consumer_, Time::Now() - TimeDelta::FromDays(1), 10, 738 &consumer_, Time::Now() - TimeDelta::FromDays(1), 10,
739 base::Bind(&HistoryTest::OnSegmentUsageAvailable, 739 base::Bind(&HistoryTest::OnSegmentUsageAvailable,
740 base::Unretained(this))); 740 base::Unretained(this)));
741 741
742 // Wait for processing. 742 // Wait for processing.
743 MessageLoop::current()->Run(); 743 MessageLoop::current()->Run();
744 744
745 // Make sure we still have one segment. 745 // Make sure we still have one segment.
746 ASSERT_EQ(1U, page_usage_data_->size()); 746 ASSERT_EQ(1U, page_usage_data_.size());
747 EXPECT_TRUE(page_usage_data_[0]->GetURL() == existing_url); 747 EXPECT_TRUE(page_usage_data_[0]->GetURL() == existing_url);
748 748
749 // Add a page linked from existing_url. 749 // Add a page linked from existing_url.
750 history->AddPage(GURL("http://www.google.com/foo"), scope, 3, existing_url, 750 history->AddPage(GURL("http://www.google.com/foo"), scope, 3, existing_url,
751 content::PAGE_TRANSITION_LINK, history::RedirectList(), 751 content::PAGE_TRANSITION_LINK, history::RedirectList(),
752 history::SOURCE_BROWSED, false); 752 history::SOURCE_BROWSED, false);
753 753
754 // Query again 754 // Query again
755 history->QuerySegmentUsageSince( 755 history->QuerySegmentUsageSince(
756 &consumer_, Time::Now() - TimeDelta::FromDays(1), 10, 756 &consumer_, Time::Now() - TimeDelta::FromDays(1), 10,
757 base::Bind(&HistoryTest::OnSegmentUsageAvailable, 757 base::Bind(&HistoryTest::OnSegmentUsageAvailable,
758 base::Unretained(this))); 758 base::Unretained(this)));
759 759
760 // Wait for processing. 760 // Wait for processing.
761 MessageLoop::current()->Run(); 761 MessageLoop::current()->Run();
762 762
763 // Make sure we still have one segment. 763 // Make sure we still have one segment.
764 ASSERT_EQ(1U, page_usage_data_->size()); 764 ASSERT_EQ(1U, page_usage_data_.size());
765 EXPECT_TRUE(page_usage_data_[0]->GetURL() == existing_url); 765 EXPECT_TRUE(page_usage_data_[0]->GetURL() == existing_url);
766 766
767 // However, the score should have increased. 767 // However, the score should have increased.
768 EXPECT_GT(page_usage_data_[0]->GetScore(), 5.0); 768 EXPECT_GT(page_usage_data_[0]->GetScore(), 5.0);
769 } 769 }
770 770
771 TEST_F(HistoryTest, MostVisitedURLs) { 771 TEST_F(HistoryTest, MostVisitedURLs) {
772 scoped_refptr<HistoryService> history(new HistoryService); 772 scoped_refptr<HistoryService> history(new HistoryService);
773 history_service_ = history; 773 history_service_ = history;
774 ASSERT_TRUE(history->Init(history_dir_, NULL)); 774 ASSERT_TRUE(history->Init(history_dir_, NULL));
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 history_service_ = history; 956 history_service_ = history;
957 history->ScheduleDBTask(task.get(), &request_consumer); 957 history->ScheduleDBTask(task.get(), &request_consumer);
958 request_consumer.CancelAllRequests(); 958 request_consumer.CancelAllRequests();
959 CleanupHistoryService(); 959 CleanupHistoryService();
960 // WARNING: history has now been deleted. 960 // WARNING: history has now been deleted.
961 history = NULL; 961 history = NULL;
962 ASSERT_FALSE(task->done_invoked); 962 ASSERT_FALSE(task->done_invoked);
963 } 963 }
964 964
965 } // namespace history 965 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/history_backend.cc ('k') | chrome/browser/importer/importer_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698