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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/string16.h" | 8 #include "base/string16.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 content::Source<AutocompleteController>(controller)); | 177 content::Source<AutocompleteController>(controller)); |
178 } | 178 } |
179 | 179 |
180 void AutocompleteProviderTest:: | 180 void AutocompleteProviderTest:: |
181 ResetControllerWithTestProvidersWithKeywordAndSearchProviders() { | 181 ResetControllerWithTestProvidersWithKeywordAndSearchProviders() { |
182 profile_.CreateTemplateURLService(); | 182 profile_.CreateTemplateURLService(); |
183 | 183 |
184 // Reset the default TemplateURL. | 184 // Reset the default TemplateURL. |
185 TemplateURLData data; | 185 TemplateURLData data; |
186 data.SetURL("http://defaultturl/{searchTerms}"); | 186 data.SetURL("http://defaultturl/{searchTerms}"); |
187 TemplateURL* default_t_url = new TemplateURL(data); | 187 TemplateURL* default_t_url = new TemplateURL(&profile_, data); |
188 TemplateURLService* turl_model = | 188 TemplateURLService* turl_model = |
189 TemplateURLServiceFactory::GetForProfile(&profile_); | 189 TemplateURLServiceFactory::GetForProfile(&profile_); |
190 turl_model->Add(default_t_url); | 190 turl_model->Add(default_t_url); |
191 turl_model->SetDefaultSearchProvider(default_t_url); | 191 turl_model->SetDefaultSearchProvider(default_t_url); |
192 TemplateURLID default_provider_id = default_t_url->id(); | 192 TemplateURLID default_provider_id = default_t_url->id(); |
193 ASSERT_NE(0, default_provider_id); | 193 ASSERT_NE(0, default_provider_id); |
194 | 194 |
195 // Create another TemplateURL for KeywordProvider. | 195 // Create another TemplateURL for KeywordProvider. |
196 data.short_name = ASCIIToUTF16("k"); | 196 data.short_name = ASCIIToUTF16("k"); |
197 data.SetKeyword(ASCIIToUTF16("k")); | 197 data.SetKeyword(ASCIIToUTF16("k")); |
198 data.SetURL("http://keyword/{searchTerms}"); | 198 data.SetURL("http://keyword/{searchTerms}"); |
199 TemplateURL* keyword_t_url = new TemplateURL(data); | 199 TemplateURL* keyword_t_url = new TemplateURL(&profile_, data); |
200 turl_model->Add(keyword_t_url); | 200 turl_model->Add(keyword_t_url); |
201 ASSERT_NE(0, keyword_t_url->id()); | 201 ASSERT_NE(0, keyword_t_url->id()); |
202 | 202 |
203 // Forget about any existing providers. The controller owns them and will | 203 // Forget about any existing providers. The controller owns them and will |
204 // Release() them below, when we delete it during the call to reset(). | 204 // Release() them below, when we delete it during the call to reset(). |
205 providers_.clear(); | 205 providers_.clear(); |
206 | 206 |
207 // Create both a keyword and search provider, and add them in that order. | 207 // Create both a keyword and search provider, and add them in that order. |
208 // (Order is important; see comments in RunExactKeymatchTest().) | 208 // (Order is important; see comments in RunExactKeymatchTest().) |
209 AutocompleteProvider* keyword_provider = new KeywordProvider(NULL, &profile_); | 209 AutocompleteProvider* keyword_provider = new KeywordProvider(NULL, &profile_); |
(...skipping 11 matching lines...) Expand all Loading... |
221 profile_.CreateTemplateURLService(); | 221 profile_.CreateTemplateURLService(); |
222 | 222 |
223 TemplateURLService* turl_model = | 223 TemplateURLService* turl_model = |
224 TemplateURLServiceFactory::GetForProfile(&profile_); | 224 TemplateURLServiceFactory::GetForProfile(&profile_); |
225 | 225 |
226 // Create a TemplateURL for KeywordProvider. | 226 // Create a TemplateURL for KeywordProvider. |
227 TemplateURLData data; | 227 TemplateURLData data; |
228 data.short_name = ASCIIToUTF16("foo.com"); | 228 data.short_name = ASCIIToUTF16("foo.com"); |
229 data.SetKeyword(ASCIIToUTF16("foo.com")); | 229 data.SetKeyword(ASCIIToUTF16("foo.com")); |
230 data.SetURL("http://foo.com/{searchTerms}"); | 230 data.SetURL("http://foo.com/{searchTerms}"); |
231 TemplateURL* keyword_t_url = new TemplateURL(data); | 231 TemplateURL* keyword_t_url = new TemplateURL(&profile_, data); |
232 turl_model->Add(keyword_t_url); | 232 turl_model->Add(keyword_t_url); |
233 ASSERT_NE(0, keyword_t_url->id()); | 233 ASSERT_NE(0, keyword_t_url->id()); |
234 | 234 |
235 // Create another TemplateURL for KeywordProvider. | 235 // Create another TemplateURL for KeywordProvider. |
236 data.short_name = ASCIIToUTF16("bar.com"); | 236 data.short_name = ASCIIToUTF16("bar.com"); |
237 data.SetKeyword(ASCIIToUTF16("bar.com")); | 237 data.SetKeyword(ASCIIToUTF16("bar.com")); |
238 data.SetURL("http://bar.com/{searchTerms}"); | 238 data.SetURL("http://bar.com/{searchTerms}"); |
239 keyword_t_url = new TemplateURL(data); | 239 keyword_t_url = new TemplateURL(&profile_, data); |
240 turl_model->Add(keyword_t_url); | 240 turl_model->Add(keyword_t_url); |
241 ASSERT_NE(0, keyword_t_url->id()); | 241 ASSERT_NE(0, keyword_t_url->id()); |
242 | 242 |
243 // Forget about any existing providers. The controller owns them and will | 243 // Forget about any existing providers. The controller owns them and will |
244 // Release() them below, when we delete it during the call to reset(). | 244 // Release() them below, when we delete it during the call to reset(). |
245 providers_.clear(); | 245 providers_.clear(); |
246 | 246 |
247 // Create both a keyword and search provider, and add them in that order. | 247 // Create both a keyword and search provider, and add them in that order. |
248 // (Order is important; see comments in RunExactKeymatchTest().) | 248 // (Order is important; see comments in RunExactKeymatchTest().) |
249 KeywordProvider* keyword_provider = new KeywordProvider(NULL, &profile_); | 249 KeywordProvider* keyword_provider = new KeywordProvider(NULL, &profile_); |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 &scheme, | 607 &scheme, |
608 &host); | 608 &host); |
609 AutocompleteInput input(input_cases[i].input, string16(), true, false, | 609 AutocompleteInput input(input_cases[i].input, string16(), true, false, |
610 true, AutocompleteInput::ALL_MATCHES); | 610 true, AutocompleteInput::ALL_MATCHES); |
611 EXPECT_EQ(input_cases[i].scheme.begin, scheme.begin); | 611 EXPECT_EQ(input_cases[i].scheme.begin, scheme.begin); |
612 EXPECT_EQ(input_cases[i].scheme.len, scheme.len); | 612 EXPECT_EQ(input_cases[i].scheme.len, scheme.len); |
613 EXPECT_EQ(input_cases[i].host.begin, host.begin); | 613 EXPECT_EQ(input_cases[i].host.begin, host.begin); |
614 EXPECT_EQ(input_cases[i].host.len, host.len); | 614 EXPECT_EQ(input_cases[i].host.len, host.len); |
615 } | 615 } |
616 } | 616 } |
OLD | NEW |