| 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/autocomplete_match.h" | 19 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 20 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" | 20 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" |
| 21 #include "chrome/browser/autocomplete/autocomplete_result.h" | 21 #include "chrome/browser/autocomplete/autocomplete_result.h" |
| 22 #include "chrome/browser/autocomplete/history_url_provider.h" | 22 #include "chrome/browser/autocomplete/history_url_provider.h" |
| 23 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 23 #include "chrome/browser/bookmarks/bookmark_test_helpers.h" | 24 #include "chrome/browser/bookmarks/bookmark_test_helpers.h" |
| 24 #include "chrome/browser/history/history_backend.h" | 25 #include "chrome/browser/history/history_backend.h" |
| 25 #include "chrome/browser/history/history_database.h" | 26 #include "chrome/browser/history/history_database.h" |
| 26 #include "chrome/browser/history/history_service.h" | 27 #include "chrome/browser/history/history_service.h" |
| 27 #include "chrome/browser/history/history_service_factory.h" | 28 #include "chrome/browser/history/history_service_factory.h" |
| 28 #include "chrome/browser/history/in_memory_url_index.h" | 29 #include "chrome/browser/history/in_memory_url_index.h" |
| 29 #include "chrome/browser/history/url_database.h" | 30 #include "chrome/browser/history/url_database.h" |
| 30 #include "chrome/browser/history/url_index_private_data.h" | 31 #include "chrome/browser/history/url_index_private_data.h" |
| 31 #include "chrome/browser/search_engines/template_url.h" | 32 #include "chrome/browser/search_engines/template_url.h" |
| 32 #include "chrome/browser/search_engines/template_url_service.h" | 33 #include "chrome/browser/search_engines/template_url_service.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 155 |
| 155 ACMatches ac_matches_; // The resulting matches after running RunTest. | 156 ACMatches ac_matches_; // The resulting matches after running RunTest. |
| 156 | 157 |
| 157 scoped_refptr<HistoryQuickProvider> provider_; | 158 scoped_refptr<HistoryQuickProvider> provider_; |
| 158 }; | 159 }; |
| 159 | 160 |
| 160 void HistoryQuickProviderTest::SetUp() { | 161 void HistoryQuickProviderTest::SetUp() { |
| 161 profile_.reset(new TestingProfile()); | 162 profile_.reset(new TestingProfile()); |
| 162 ASSERT_TRUE(profile_->CreateHistoryService(true, false)); | 163 ASSERT_TRUE(profile_->CreateHistoryService(true, false)); |
| 163 profile_->CreateBookmarkModel(true); | 164 profile_->CreateBookmarkModel(true); |
| 164 test::WaitForBookmarkModelToLoad(profile_.get()); | 165 test::WaitForBookmarkModelToLoad( |
| 166 BookmarkModelFactory::GetForProfile(profile_.get())); |
| 165 profile_->BlockUntilHistoryIndexIsRefreshed(); | 167 profile_->BlockUntilHistoryIndexIsRefreshed(); |
| 166 history_service_ = | 168 history_service_ = |
| 167 HistoryServiceFactory::GetForProfile(profile_.get(), | 169 HistoryServiceFactory::GetForProfile(profile_.get(), |
| 168 Profile::EXPLICIT_ACCESS); | 170 Profile::EXPLICIT_ACCESS); |
| 169 EXPECT_TRUE(history_service_); | 171 EXPECT_TRUE(history_service_); |
| 170 provider_ = new HistoryQuickProvider(this, profile_.get()); | 172 provider_ = new HistoryQuickProvider(this, profile_.get()); |
| 171 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 173 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
| 172 profile_.get(), &HistoryQuickProviderTest::CreateTemplateURLService); | 174 profile_.get(), &HistoryQuickProviderTest::CreateTemplateURLService); |
| 173 FillData(); | 175 FillData(); |
| 174 provider_->GetIndex()->RebuildFromHistory( | 176 provider_->GetIndex()->RebuildFromHistory( |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 | 708 |
| 707 TEST_F(HQPOrderingTest, TEAMatch) { | 709 TEST_F(HQPOrderingTest, TEAMatch) { |
| 708 std::vector<std::string> expected_urls; | 710 std::vector<std::string> expected_urls; |
| 709 expected_urls.push_back("http://www.teamliquid.net/"); | 711 expected_urls.push_back("http://www.teamliquid.net/"); |
| 710 expected_urls.push_back("http://www.teamliquid.net/tlpd"); | 712 expected_urls.push_back("http://www.teamliquid.net/tlpd"); |
| 711 expected_urls.push_back("http://www.teamliquid.net/tlpd/korean/players"); | 713 expected_urls.push_back("http://www.teamliquid.net/tlpd/korean/players"); |
| 712 RunTest(ASCIIToUTF16("tea"), false, expected_urls, true, | 714 RunTest(ASCIIToUTF16("tea"), false, expected_urls, true, |
| 713 ASCIIToUTF16("www.teamliquid.net"), | 715 ASCIIToUTF16("www.teamliquid.net"), |
| 714 ASCIIToUTF16("mliquid.net")); | 716 ASCIIToUTF16("mliquid.net")); |
| 715 } | 717 } |
| OLD | NEW |