OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/format_macros.h" | 13 #include "base/format_macros.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
16 #include "base/prefs/pref_service.h" | 16 #include "base/prefs/pref_service.h" |
17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 19 #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" |
19 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" | 20 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
20 #include "chrome/browser/autocomplete/history_url_provider.h" | 21 #include "chrome/browser/autocomplete/history_url_provider.h" |
21 #include "chrome/browser/autocomplete/in_memory_url_index.h" | 22 #include "chrome/browser/autocomplete/in_memory_url_index.h" |
22 #include "chrome/browser/autocomplete/in_memory_url_index_factory.h" | 23 #include "chrome/browser/autocomplete/in_memory_url_index_factory.h" |
23 #include "chrome/browser/autocomplete/url_index_private_data.h" | 24 #include "chrome/browser/autocomplete/url_index_private_data.h" |
24 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 25 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
25 #include "chrome/browser/history/history_service_factory.h" | 26 #include "chrome/browser/history/history_service_factory.h" |
26 #include "chrome/browser/search_engines/chrome_template_url_service_client.h" | 27 #include "chrome/browser/search_engines/chrome_template_url_service_client.h" |
27 #include "chrome/browser/search_engines/template_url_service_factory.h" | 28 #include "chrome/browser/search_engines/template_url_service_factory.h" |
28 #include "chrome/test/base/testing_browser_process.h" | 29 #include "chrome/test/base/testing_browser_process.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 | 210 |
210 history::HistoryBackend* history_backend() { | 211 history::HistoryBackend* history_backend() { |
211 return history_service_->history_backend_.get(); | 212 return history_service_->history_backend_.get(); |
212 } | 213 } |
213 | 214 |
214 base::MessageLoopForUI message_loop_; | 215 base::MessageLoopForUI message_loop_; |
215 content::TestBrowserThread ui_thread_; | 216 content::TestBrowserThread ui_thread_; |
216 content::TestBrowserThread file_thread_; | 217 content::TestBrowserThread file_thread_; |
217 | 218 |
218 scoped_ptr<TestingProfile> profile_; | 219 scoped_ptr<TestingProfile> profile_; |
| 220 scoped_ptr<ChromeAutocompleteProviderClient> client_; |
219 history::HistoryService* history_service_; | 221 history::HistoryService* history_service_; |
220 | 222 |
221 ACMatches ac_matches_; // The resulting matches after running RunTest. | 223 ACMatches ac_matches_; // The resulting matches after running RunTest. |
222 | 224 |
223 scoped_refptr<HistoryQuickProvider> provider_; | 225 scoped_refptr<HistoryQuickProvider> provider_; |
224 }; | 226 }; |
225 | 227 |
226 void HistoryQuickProviderTest::SetUp() { | 228 void HistoryQuickProviderTest::SetUp() { |
227 profile_.reset(new TestingProfile()); | 229 profile_.reset(new TestingProfile()); |
| 230 client_.reset(new ChromeAutocompleteProviderClient(profile_.get())); |
228 ASSERT_TRUE(profile_->CreateHistoryService(true, false)); | 231 ASSERT_TRUE(profile_->CreateHistoryService(true, false)); |
229 profile_->CreateBookmarkModel(true); | 232 profile_->CreateBookmarkModel(true); |
230 bookmarks::test::WaitForBookmarkModelToLoad( | 233 bookmarks::test::WaitForBookmarkModelToLoad( |
231 BookmarkModelFactory::GetForProfile(profile_.get())); | 234 BookmarkModelFactory::GetForProfile(profile_.get())); |
232 profile_->BlockUntilHistoryIndexIsRefreshed(); | 235 profile_->BlockUntilHistoryIndexIsRefreshed(); |
233 history_service_ = HistoryServiceFactory::GetForProfile( | 236 history_service_ = HistoryServiceFactory::GetForProfile( |
234 profile_.get(), ServiceAccessType::EXPLICIT_ACCESS); | 237 profile_.get(), ServiceAccessType::EXPLICIT_ACCESS); |
235 EXPECT_TRUE(history_service_); | 238 EXPECT_TRUE(history_service_); |
236 InMemoryURLIndex* index = | 239 InMemoryURLIndex* index = |
237 InMemoryURLIndexFactory::GetForProfile(profile_.get()); | 240 InMemoryURLIndexFactory::GetForProfile(profile_.get()); |
238 EXPECT_TRUE(index); | 241 EXPECT_TRUE(index); |
239 provider_ = new HistoryQuickProvider(profile_.get(), index); | 242 provider_ = new HistoryQuickProvider(client_.get(), profile_.get(), index); |
240 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 243 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
241 profile_.get(), &HistoryQuickProviderTest::CreateTemplateURLService); | 244 profile_.get(), &HistoryQuickProviderTest::CreateTemplateURLService); |
242 FillData(); | 245 FillData(); |
243 index->RebuildFromHistory(history_backend()->db()); | 246 index->RebuildFromHistory(history_backend()->db()); |
244 } | 247 } |
245 | 248 |
246 void HistoryQuickProviderTest::TearDown() { | 249 void HistoryQuickProviderTest::TearDown() { |
247 provider_ = NULL; | 250 provider_ = NULL; |
248 } | 251 } |
249 | 252 |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 | 832 |
830 TEST_F(HQPOrderingTest, TEAMatch) { | 833 TEST_F(HQPOrderingTest, TEAMatch) { |
831 std::vector<std::string> expected_urls; | 834 std::vector<std::string> expected_urls; |
832 expected_urls.push_back("http://www.teamliquid.net/"); | 835 expected_urls.push_back("http://www.teamliquid.net/"); |
833 expected_urls.push_back("http://www.teamliquid.net/tlpd"); | 836 expected_urls.push_back("http://www.teamliquid.net/tlpd"); |
834 expected_urls.push_back("http://www.teamliquid.net/tlpd/korean/players"); | 837 expected_urls.push_back("http://www.teamliquid.net/tlpd/korean/players"); |
835 RunTest(ASCIIToUTF16("tea"), false, expected_urls, true, | 838 RunTest(ASCIIToUTF16("tea"), false, expected_urls, true, |
836 ASCIIToUTF16("www.teamliquid.net"), | 839 ASCIIToUTF16("www.teamliquid.net"), |
837 ASCIIToUTF16("mliquid.net")); | 840 ASCIIToUTF16("mliquid.net")); |
838 } | 841 } |
OLD | NEW |