OLD | NEW |
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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 url_info.set_hidden(false); | 155 url_info.set_hidden(false); |
156 EXPECT_TRUE(db->AddURL(url_info)); | 156 EXPECT_TRUE(db->AddURL(url_info)); |
157 | 157 |
158 history_service_->AddPageWithDetails(current_url, UTF8ToUTF16(cur.title), | 158 history_service_->AddPageWithDetails(current_url, UTF8ToUTF16(cur.title), |
159 cur.visit_count, cur.typed_count, | 159 cur.visit_count, cur.typed_count, |
160 visit_time, false, | 160 visit_time, false, |
161 history::SOURCE_BROWSED); | 161 history::SOURCE_BROWSED); |
162 } | 162 } |
163 | 163 |
164 history::InMemoryURLIndex* index = | 164 history::InMemoryURLIndex* index = |
165 new history::InMemoryURLIndex(FilePath(FILE_PATH_LITERAL("/dummy"))); | 165 new history::InMemoryURLIndex(profile_.get(), |
| 166 FilePath(FILE_PATH_LITERAL("/dummy"))); |
166 PrefService* prefs = profile_->GetPrefs(); | 167 PrefService* prefs = profile_->GetPrefs(); |
167 std::string languages(prefs->GetString(prefs::kAcceptLanguages)); | 168 std::string languages(prefs->GetString(prefs::kAcceptLanguages)); |
168 index->Init(db, languages); | 169 index->Init(db, languages); |
169 provider_->SetIndexForTesting(index); | 170 provider_->set_index(index); |
170 } | 171 } |
171 | 172 |
172 HistoryQuickProviderTest::SetShouldContain::SetShouldContain( | 173 HistoryQuickProviderTest::SetShouldContain::SetShouldContain( |
173 const ACMatches& matched_urls) { | 174 const ACMatches& matched_urls) { |
174 for (ACMatches::const_iterator iter = matched_urls.begin(); | 175 for (ACMatches::const_iterator iter = matched_urls.begin(); |
175 iter != matched_urls.end(); ++iter) | 176 iter != matched_urls.end(); ++iter) |
176 matches_.insert(iter->destination_url.spec()); | 177 matches_.insert(iter->destination_url.spec()); |
177 } | 178 } |
178 | 179 |
179 void HistoryQuickProviderTest::SetShouldContain::operator()( | 180 void HistoryQuickProviderTest::SetShouldContain::operator()( |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 kMaxNonInliningScore - 1); | 423 kMaxNonInliningScore - 1); |
423 EXPECT_EQ(next_score, kMaxNonInliningScore - 2); | 424 EXPECT_EQ(next_score, kMaxNonInliningScore - 2); |
424 | 425 |
425 // Low score, can inline, not clamped. | 426 // Low score, can inline, not clamped. |
426 next_score = 1500; | 427 next_score = 1500; |
427 match.raw_score = 500; | 428 match.raw_score = 500; |
428 match.can_inline = true; | 429 match.can_inline = true; |
429 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), 500); | 430 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), 500); |
430 EXPECT_EQ(next_score, 499); | 431 EXPECT_EQ(next_score, 499); |
431 } | 432 } |
OLD | NEW |