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

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

Issue 8359019: Create Private Data for InMemoryURLIndex (in Preparation for SQLite Cache) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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(FilePath());
148 PrefService* prefs = profile_->GetPrefs();
149 std::string languages(prefs->GetString(prefs::kAcceptLanguages));
150 index->Init(db, languages);
145 for (size_t i = 0; i < arraysize(quick_test_db); ++i) { 151 for (size_t i = 0; i < arraysize(quick_test_db); ++i) {
146 const TestURLInfo& cur = quick_test_db[i]; 152 const TestURLInfo& cur = quick_test_db[i];
147 const GURL current_url(cur.url); 153 const GURL current_url(cur.url);
148 Time visit_time = Time::Now() - TimeDelta::FromDays(cur.days_from_now); 154 Time visit_time = Time::Now() - TimeDelta::FromDays(cur.days_from_now);
149 155
150 history::URLRow url_info(current_url); 156 history::URLRow url_info(current_url);
151 url_info.set_title(UTF8ToUTF16(cur.title)); 157 url_info.set_title(UTF8ToUTF16(cur.title));
152 url_info.set_visit_count(cur.visit_count); 158 url_info.set_visit_count(cur.visit_count);
153 url_info.set_typed_count(cur.typed_count); 159 url_info.set_typed_count(cur.typed_count);
154 url_info.set_last_visit(visit_time); 160 url_info.set_last_visit(visit_time);
155 url_info.set_hidden(false); 161 url_info.set_hidden(false);
156 EXPECT_TRUE(db->AddURL(url_info)); 162 index->UpdateURL(i, 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);
162 } 163 }
163 164
164 history::InMemoryURLIndex* index = new history::InMemoryURLIndex(FilePath()); 165 provider_->set_index(index);
165 PrefService* prefs = profile_->GetPrefs();
166 std::string languages(prefs->GetString(prefs::kAcceptLanguages));
167 index->Init(db, languages);
168 provider_->SetIndexForTesting(index);
169 } 166 }
170 167
171 HistoryQuickProviderTest::SetShouldContain::SetShouldContain( 168 HistoryQuickProviderTest::SetShouldContain::SetShouldContain(
172 const ACMatches& matched_urls) { 169 const ACMatches& matched_urls) {
173 for (ACMatches::const_iterator iter = matched_urls.begin(); 170 for (ACMatches::const_iterator iter = matched_urls.begin();
174 iter != matched_urls.end(); ++iter) 171 iter != matched_urls.end(); ++iter)
175 matches_.insert(iter->destination_url.spec()); 172 matches_.insert(iter->destination_url.spec());
176 } 173 }
177 174
178 void HistoryQuickProviderTest::SetShouldContain::operator()( 175 void HistoryQuickProviderTest::SetShouldContain::operator()(
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 kMaxNonInliningScore - 1); 418 kMaxNonInliningScore - 1);
422 EXPECT_EQ(next_score, kMaxNonInliningScore - 2); 419 EXPECT_EQ(next_score, kMaxNonInliningScore - 2);
423 420
424 // Low score, can inline, not clamped. 421 // Low score, can inline, not clamped.
425 next_score = 1500; 422 next_score = 1500;
426 match.raw_score = 500; 423 match.raw_score = 500;
427 match.can_inline = true; 424 match.can_inline = true;
428 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), 500); 425 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), 500);
429 EXPECT_EQ(next_score, 499); 426 EXPECT_EQ(next_score, 499);
430 } 427 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/history_quick_provider.cc ('k') | chrome/browser/history/history_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698