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_url_provider.h" | 5 #include "chrome/browser/autocomplete/history_url_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
10 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
11 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
14 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" | 15 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
15 #include "chrome/browser/autocomplete/history_quick_provider.h" | 16 #include "chrome/browser/autocomplete/history_quick_provider.h" |
16 #include "chrome/browser/history/history_service_factory.h" | 17 #include "chrome/browser/history/history_service_factory.h" |
17 #include "chrome/browser/search_engines/chrome_template_url_service_client.h" | 18 #include "chrome/browser/search_engines/chrome_template_url_service_client.h" |
18 #include "chrome/browser/search_engines/template_url_service_factory.h" | 19 #include "chrome/browser/search_engines/template_url_service_factory.h" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 } | 164 } |
164 | 165 |
165 ~HistoryURLProviderTest() override { | 166 ~HistoryURLProviderTest() override { |
166 HistoryQuickProvider::set_disabled(false); | 167 HistoryQuickProvider::set_disabled(false); |
167 } | 168 } |
168 | 169 |
169 // AutocompleteProviderListener: | 170 // AutocompleteProviderListener: |
170 void OnProviderUpdate(bool updated_matches) override; | 171 void OnProviderUpdate(bool updated_matches) override; |
171 | 172 |
172 protected: | 173 protected: |
173 static KeyedService* CreateTemplateURLService( | 174 static scoped_ptr<KeyedService> CreateTemplateURLService( |
174 content::BrowserContext* context) { | 175 content::BrowserContext* context) { |
175 Profile* profile = static_cast<Profile*>(context); | 176 Profile* profile = static_cast<Profile*>(context); |
176 return new TemplateURLService( | 177 return make_scoped_ptr(new TemplateURLService( |
177 profile->GetPrefs(), make_scoped_ptr(new SearchTermsData), NULL, | 178 profile->GetPrefs(), make_scoped_ptr(new SearchTermsData), NULL, |
178 scoped_ptr<TemplateURLServiceClient>(new ChromeTemplateURLServiceClient( | 179 scoped_ptr<TemplateURLServiceClient>(new ChromeTemplateURLServiceClient( |
179 HistoryServiceFactory::GetForProfile( | 180 HistoryServiceFactory::GetForProfile( |
180 profile, ServiceAccessType::EXPLICIT_ACCESS))), | 181 profile, ServiceAccessType::EXPLICIT_ACCESS))), |
181 NULL, NULL, base::Closure()); | 182 NULL, NULL, base::Closure())); |
182 } | 183 } |
183 | 184 |
184 // testing::Test | 185 // testing::Test |
185 void SetUp() override { | 186 void SetUp() override { |
186 ASSERT_TRUE(SetUpImpl(false)); | 187 ASSERT_TRUE(SetUpImpl(false)); |
187 } | 188 } |
188 void TearDown() override; | 189 void TearDown() override; |
189 | 190 |
190 // Does the real setup. | 191 // Does the real setup. |
191 bool SetUpImpl(bool no_db) WARN_UNUSED_RESULT; | 192 bool SetUpImpl(bool no_db) WARN_UNUSED_RESULT; |
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1059 // Test the experiment (scoring enabled). | 1060 // Test the experiment (scoring enabled). |
1060 autocomplete_->scoring_params_.experimental_scoring_enabled = true; | 1061 autocomplete_->scoring_params_.experimental_scoring_enabled = true; |
1061 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16(test_cases[i].input), | 1062 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16(test_cases[i].input), |
1062 std::string(), false, output, max_matches)); | 1063 std::string(), false, output, max_matches)); |
1063 for (int j = 0; j < max_matches; ++j) { | 1064 for (int j = 0; j < max_matches; ++j) { |
1064 EXPECT_EQ(test_cases[i].matches[j].experiment_relevance, | 1065 EXPECT_EQ(test_cases[i].matches[j].experiment_relevance, |
1065 matches_[j].relevance); | 1066 matches_[j].relevance); |
1066 } | 1067 } |
1067 } | 1068 } |
1068 } | 1069 } |
OLD | NEW |