| 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 145 |
| 146 history::InMemoryURLIndex* index = | 146 history::InMemoryURLIndex* index = |
| 147 new history::InMemoryURLIndex(FilePath()); | 147 new history::InMemoryURLIndex(profile_.get(), FilePath()); |
| 148 PrefService* prefs = profile_->GetPrefs(); | 148 PrefService* prefs = profile_->GetPrefs(); |
| 149 std::string languages(prefs->GetString(prefs::kAcceptLanguages)); | 149 std::string languages(prefs->GetString(prefs::kAcceptLanguages)); |
| 150 index->Init(db, languages); | 150 index->Init(db, languages); |
| 151 for (size_t i = 0; i < arraysize(quick_test_db); ++i) { | 151 for (size_t i = 0; i < arraysize(quick_test_db); ++i) { |
| 152 const TestURLInfo& cur = quick_test_db[i]; | 152 const TestURLInfo& cur = quick_test_db[i]; |
| 153 const GURL current_url(cur.url); | 153 const GURL current_url(cur.url); |
| 154 Time visit_time = Time::Now() - TimeDelta::FromDays(cur.days_from_now); | 154 Time visit_time = Time::Now() - TimeDelta::FromDays(cur.days_from_now); |
| 155 | 155 |
| 156 history::URLRow url_info(current_url); | 156 history::URLRow url_info(current_url); |
| 157 url_info.set_title(UTF8ToUTF16(cur.title)); | 157 url_info.set_title(UTF8ToUTF16(cur.title)); |
| 158 url_info.set_visit_count(cur.visit_count); | 158 url_info.set_visit_count(cur.visit_count); |
| 159 url_info.set_typed_count(cur.typed_count); | 159 url_info.set_typed_count(cur.typed_count); |
| 160 url_info.set_last_visit(visit_time); | 160 url_info.set_last_visit(visit_time); |
| 161 url_info.set_hidden(false); | 161 url_info.set_hidden(false); |
| 162 index->UpdateURL(i, url_info); | 162 url_info.set_id(i); |
| 163 index->UpdateURL(url_info); |
| 163 } | 164 } |
| 164 | 165 |
| 165 provider_->set_index(index); | 166 provider_->set_index(index); |
| 166 } | 167 } |
| 167 | 168 |
| 168 HistoryQuickProviderTest::SetShouldContain::SetShouldContain( | 169 HistoryQuickProviderTest::SetShouldContain::SetShouldContain( |
| 169 const ACMatches& matched_urls) { | 170 const ACMatches& matched_urls) { |
| 170 for (ACMatches::const_iterator iter = matched_urls.begin(); | 171 for (ACMatches::const_iterator iter = matched_urls.begin(); |
| 171 iter != matched_urls.end(); ++iter) | 172 iter != matched_urls.end(); ++iter) |
| 172 matches_.insert(iter->destination_url.spec()); | 173 matches_.insert(iter->destination_url.spec()); |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 kMaxNonInliningScore - 1); | 419 kMaxNonInliningScore - 1); |
| 419 EXPECT_EQ(next_score, kMaxNonInliningScore - 2); | 420 EXPECT_EQ(next_score, kMaxNonInliningScore - 2); |
| 420 | 421 |
| 421 // Low score, can inline, not clamped. | 422 // Low score, can inline, not clamped. |
| 422 next_score = 1500; | 423 next_score = 1500; |
| 423 match.raw_score = 500; | 424 match.raw_score = 500; |
| 424 match.can_inline = true; | 425 match.can_inline = true; |
| 425 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), 500); | 426 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), 500); |
| 426 EXPECT_EQ(next_score, 499); | 427 EXPECT_EQ(next_score, 499); |
| 427 } | 428 } |
| OLD | NEW |