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> |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 122 |
123 private: | 123 private: |
124 std::set<std::string> matches_; | 124 std::set<std::string> matches_; |
125 }; | 125 }; |
126 | 126 |
127 static KeyedService* CreateTemplateURLService( | 127 static KeyedService* CreateTemplateURLService( |
128 content::BrowserContext* context) { | 128 content::BrowserContext* context) { |
129 Profile* profile = static_cast<Profile*>(context); | 129 Profile* profile = static_cast<Profile*>(context); |
130 return new TemplateURLService( | 130 return new TemplateURLService( |
131 profile->GetPrefs(), make_scoped_ptr(new SearchTermsData), NULL, | 131 profile->GetPrefs(), make_scoped_ptr(new SearchTermsData), NULL, |
132 scoped_ptr<TemplateURLServiceClient>( | 132 scoped_ptr<TemplateURLServiceClient>(new ChromeTemplateURLServiceClient( |
133 new ChromeTemplateURLServiceClient( | 133 HistoryServiceFactory::GetForProfile( |
134 HistoryServiceFactory::GetForProfile( | 134 profile, ServiceAccessType::EXPLICIT_ACCESS))), |
135 profile, Profile::EXPLICIT_ACCESS))), | |
136 NULL, NULL, base::Closure()); | 135 NULL, NULL, base::Closure()); |
137 } | 136 } |
138 | 137 |
139 void SetUp() override; | 138 void SetUp() override; |
140 void TearDown() override; | 139 void TearDown() override; |
141 | 140 |
142 virtual void GetTestData(size_t* data_count, TestURLInfo** test_data); | 141 virtual void GetTestData(size_t* data_count, TestURLInfo** test_data); |
143 | 142 |
144 // Fills test data into the history system. | 143 // Fills test data into the history system. |
145 void FillData(); | 144 void FillData(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 scoped_refptr<HistoryQuickProvider> provider_; | 178 scoped_refptr<HistoryQuickProvider> provider_; |
180 }; | 179 }; |
181 | 180 |
182 void HistoryQuickProviderTest::SetUp() { | 181 void HistoryQuickProviderTest::SetUp() { |
183 profile_.reset(new TestingProfile()); | 182 profile_.reset(new TestingProfile()); |
184 ASSERT_TRUE(profile_->CreateHistoryService(true, false)); | 183 ASSERT_TRUE(profile_->CreateHistoryService(true, false)); |
185 profile_->CreateBookmarkModel(true); | 184 profile_->CreateBookmarkModel(true); |
186 bookmarks::test::WaitForBookmarkModelToLoad( | 185 bookmarks::test::WaitForBookmarkModelToLoad( |
187 BookmarkModelFactory::GetForProfile(profile_.get())); | 186 BookmarkModelFactory::GetForProfile(profile_.get())); |
188 profile_->BlockUntilHistoryIndexIsRefreshed(); | 187 profile_->BlockUntilHistoryIndexIsRefreshed(); |
189 history_service_ = | 188 history_service_ = HistoryServiceFactory::GetForProfile( |
190 HistoryServiceFactory::GetForProfile(profile_.get(), | 189 profile_.get(), ServiceAccessType::EXPLICIT_ACCESS); |
191 Profile::EXPLICIT_ACCESS); | |
192 EXPECT_TRUE(history_service_); | 190 EXPECT_TRUE(history_service_); |
193 provider_ = new HistoryQuickProvider(profile_.get()); | 191 provider_ = new HistoryQuickProvider(profile_.get()); |
194 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 192 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
195 profile_.get(), &HistoryQuickProviderTest::CreateTemplateURLService); | 193 profile_.get(), &HistoryQuickProviderTest::CreateTemplateURLService); |
196 FillData(); | 194 FillData(); |
197 provider_->GetIndex()->RebuildFromHistory(history_backend()->db()); | 195 provider_->GetIndex()->RebuildFromHistory(history_backend()->db()); |
198 } | 196 } |
199 | 197 |
200 void HistoryQuickProviderTest::TearDown() { | 198 void HistoryQuickProviderTest::TearDown() { |
201 provider_ = NULL; | 199 provider_ = NULL; |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 | 773 |
776 TEST_F(HQPOrderingTest, TEAMatch) { | 774 TEST_F(HQPOrderingTest, TEAMatch) { |
777 std::vector<std::string> expected_urls; | 775 std::vector<std::string> expected_urls; |
778 expected_urls.push_back("http://www.teamliquid.net/"); | 776 expected_urls.push_back("http://www.teamliquid.net/"); |
779 expected_urls.push_back("http://www.teamliquid.net/tlpd"); | 777 expected_urls.push_back("http://www.teamliquid.net/tlpd"); |
780 expected_urls.push_back("http://www.teamliquid.net/tlpd/korean/players"); | 778 expected_urls.push_back("http://www.teamliquid.net/tlpd/korean/players"); |
781 RunTest(ASCIIToUTF16("tea"), false, expected_urls, true, | 779 RunTest(ASCIIToUTF16("tea"), false, expected_urls, true, |
782 ASCIIToUTF16("www.teamliquid.net"), | 780 ASCIIToUTF16("www.teamliquid.net"), |
783 ASCIIToUTF16("mliquid.net")); | 781 ASCIIToUTF16("mliquid.net")); |
784 } | 782 } |
OLD | NEW |