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

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

Issue 8662035: Revert 111378 - HQP Refactoring (in Preparation for SQLite Cache) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years 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 EXPECT_TRUE(history_service_); 135 EXPECT_TRUE(history_service_);
136 provider_ = new HistoryQuickProvider(this, profile_.get()); 136 provider_ = new HistoryQuickProvider(this, profile_.get());
137 FillData(); 137 FillData();
138 } 138 }
139 139
140 void HistoryQuickProviderTest::OnProviderUpdate(bool updated_matches) { 140 void HistoryQuickProviderTest::OnProviderUpdate(bool updated_matches) {
141 MessageLoop::current()->Quit(); 141 MessageLoop::current()->Quit();
142 } 142 }
143 143
144 void HistoryQuickProviderTest::FillData() { 144 void HistoryQuickProviderTest::FillData() {
145 history::URLDatabase* db = history_service_->InMemoryDatabase();
146 ASSERT_TRUE(db != NULL);
147
145 history::InMemoryURLIndex* index = 148 history::InMemoryURLIndex* index =
146 new history::InMemoryURLIndex(profile_.get(), FilePath()); 149 new history::InMemoryURLIndex(FilePath());
147 PrefService* prefs = profile_->GetPrefs(); 150 PrefService* prefs = profile_->GetPrefs();
148 std::string languages(prefs->GetString(prefs::kAcceptLanguages)); 151 std::string languages(prefs->GetString(prefs::kAcceptLanguages));
149 index->Init(languages); 152 index->Init(db, languages);
150 for (size_t i = 0; i < arraysize(quick_test_db); ++i) { 153 for (size_t i = 0; i < arraysize(quick_test_db); ++i) {
151 const TestURLInfo& cur = quick_test_db[i]; 154 const TestURLInfo& cur = quick_test_db[i];
152 const GURL current_url(cur.url); 155 const GURL current_url(cur.url);
153 Time visit_time = Time::Now() - TimeDelta::FromDays(cur.days_from_now); 156 Time visit_time = Time::Now() - TimeDelta::FromDays(cur.days_from_now);
154 157
155 history::URLRow url_info(current_url); 158 history::URLRow url_info(current_url);
156 url_info.set_title(UTF8ToUTF16(cur.title)); 159 url_info.set_title(UTF8ToUTF16(cur.title));
157 url_info.set_visit_count(cur.visit_count); 160 url_info.set_visit_count(cur.visit_count);
158 url_info.set_typed_count(cur.typed_count); 161 url_info.set_typed_count(cur.typed_count);
159 url_info.set_last_visit(visit_time); 162 url_info.set_last_visit(visit_time);
160 url_info.set_hidden(false); 163 url_info.set_hidden(false);
161 url_info.set_id(i); 164 index->UpdateURL(i, url_info);
162 index->UpdateURL(url_info);
163 } 165 }
164 166
165 provider_->set_index(index); 167 provider_->set_index(index);
166 } 168 }
167 169
168 HistoryQuickProviderTest::SetShouldContain::SetShouldContain( 170 HistoryQuickProviderTest::SetShouldContain::SetShouldContain(
169 const ACMatches& matched_urls) { 171 const ACMatches& matched_urls) {
170 for (ACMatches::const_iterator iter = matched_urls.begin(); 172 for (ACMatches::const_iterator iter = matched_urls.begin();
171 iter != matched_urls.end(); ++iter) 173 iter != matched_urls.end(); ++iter)
172 matches_.insert(iter->destination_url.spec()); 174 matches_.insert(iter->destination_url.spec());
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 kMaxNonInliningScore - 1); 420 kMaxNonInliningScore - 1);
419 EXPECT_EQ(next_score, kMaxNonInliningScore - 2); 421 EXPECT_EQ(next_score, kMaxNonInliningScore - 2);
420 422
421 // Low score, can inline, not clamped. 423 // Low score, can inline, not clamped.
422 next_score = 1500; 424 next_score = 1500;
423 match.raw_score = 500; 425 match.raw_score = 500;
424 match.can_inline = true; 426 match.can_inline = true;
425 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), 500); 427 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), 500);
426 EXPECT_EQ(next_score, 499); 428 EXPECT_EQ(next_score, 499);
427 } 429 }
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