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

Side by Side Diff: chrome/browser/autocomplete/history_quick_provider_unittest.cc

Issue 8275004: Revert 105300 - HQP Refactoring (in Preparation for SQLite Cache) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 2 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
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 "chrome/browser/autocomplete/history_quick_provider.h" 5 #include "chrome/browser/autocomplete/history_quick_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 FillData(); 135 FillData();
136 } 136 }
137 137
138 void HistoryQuickProviderTest::OnProviderUpdate(bool updated_matches) { 138 void HistoryQuickProviderTest::OnProviderUpdate(bool updated_matches) {
139 MessageLoop::current()->Quit(); 139 MessageLoop::current()->Quit();
140 } 140 }
141 141
142 void HistoryQuickProviderTest::FillData() { 142 void HistoryQuickProviderTest::FillData() {
143 history::URLDatabase* db = history_service_->InMemoryDatabase(); 143 history::URLDatabase* db = history_service_->InMemoryDatabase();
144 ASSERT_TRUE(db != NULL); 144 ASSERT_TRUE(db != NULL);
145
146 history::InMemoryURLIndex* index =
147 new history::InMemoryURLIndex(profile_.get(),
148 FilePath(FILE_PATH_LITERAL("/dummy")));
149 PrefService* prefs = profile_->GetPrefs();
150 std::string languages(prefs->GetString(prefs::kAcceptLanguages));
151 index->Init(db, languages);
152 for (size_t i = 0; i < arraysize(quick_test_db); ++i) { 145 for (size_t i = 0; i < arraysize(quick_test_db); ++i) {
153 const TestURLInfo& cur = quick_test_db[i]; 146 const TestURLInfo& cur = quick_test_db[i];
154 const GURL current_url(cur.url); 147 const GURL current_url(cur.url);
155 Time visit_time = Time::Now() - TimeDelta::FromDays(cur.days_from_now); 148 Time visit_time = Time::Now() - TimeDelta::FromDays(cur.days_from_now);
156 149
157 history::URLRow url_info(current_url); 150 history::URLRow url_info(current_url);
158 url_info.set_title(UTF8ToUTF16(cur.title)); 151 url_info.set_title(UTF8ToUTF16(cur.title));
159 url_info.set_visit_count(cur.visit_count); 152 url_info.set_visit_count(cur.visit_count);
160 url_info.set_typed_count(cur.typed_count); 153 url_info.set_typed_count(cur.typed_count);
161 url_info.set_last_visit(visit_time); 154 url_info.set_last_visit(visit_time);
162 url_info.set_hidden(false); 155 url_info.set_hidden(false);
163 url_info.set_id(i); 156 EXPECT_TRUE(db->AddURL(url_info));
164 index->UpdateURL(url_info); 157
158 history_service_->AddPageWithDetails(current_url, UTF8ToUTF16(cur.title),
159 cur.visit_count, cur.typed_count,
160 visit_time, false,
161 history::SOURCE_BROWSED);
165 } 162 }
166 163
167 provider_->set_index(index); 164 history::InMemoryURLIndex* index =
165 new history::InMemoryURLIndex(FilePath(FILE_PATH_LITERAL("/dummy")));
166 PrefService* prefs = profile_->GetPrefs();
167 std::string languages(prefs->GetString(prefs::kAcceptLanguages));
168 index->Init(db, languages);
169 provider_->SetIndexForTesting(index);
168 } 170 }
169 171
170 HistoryQuickProviderTest::SetShouldContain::SetShouldContain( 172 HistoryQuickProviderTest::SetShouldContain::SetShouldContain(
171 const ACMatches& matched_urls) { 173 const ACMatches& matched_urls) {
172 for (ACMatches::const_iterator iter = matched_urls.begin(); 174 for (ACMatches::const_iterator iter = matched_urls.begin();
173 iter != matched_urls.end(); ++iter) 175 iter != matched_urls.end(); ++iter)
174 matches_.insert(iter->destination_url.spec()); 176 matches_.insert(iter->destination_url.spec());
175 } 177 }
176 178
177 void HistoryQuickProviderTest::SetShouldContain::operator()( 179 void HistoryQuickProviderTest::SetShouldContain::operator()(
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 kMaxNonInliningScore - 1); 422 kMaxNonInliningScore - 1);
421 EXPECT_EQ(next_score, kMaxNonInliningScore - 2); 423 EXPECT_EQ(next_score, kMaxNonInliningScore - 2);
422 424
423 // Low score, can inline, not clamped. 425 // Low score, can inline, not clamped.
424 next_score = 1500; 426 next_score = 1500;
425 match.raw_score = 500; 427 match.raw_score = 500;
426 match.can_inline = true; 428 match.can_inline = true;
427 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), 500); 429 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), 500);
428 EXPECT_EQ(next_score, 499); 430 EXPECT_EQ(next_score, 499);
429 } 431 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/history_quick_provider.cc ('k') | chrome/browser/history/expire_history_backend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698