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/autocomplete_provider.h" | 5 #include "chrome/browser/autocomplete/autocomplete_provider.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 // a corresponding call to RegisterTemplateURL; otherwise the | 246 // a corresponding call to RegisterTemplateURL; otherwise the |
247 // controller flow will crash; this practically means that | 247 // controller flow will crash; this practically means that |
248 // RunTests/ResetControllerXXX/RegisterTemplateURL should | 248 // RunTests/ResetControllerXXX/RegisterTemplateURL should |
249 // be coordinated with each other. | 249 // be coordinated with each other. |
250 // (2) Inject test arguments rather than rely on the hardcoded values, e.g. | 250 // (2) Inject test arguments rather than rely on the hardcoded values, e.g. |
251 // don't rely on kResultsPerProvided and default relevance ordering | 251 // don't rely on kResultsPerProvided and default relevance ordering |
252 // (B > A). | 252 // (B > A). |
253 RegisterTemplateURL(base::ASCIIToUTF16(kTestTemplateURLKeyword), | 253 RegisterTemplateURL(base::ASCIIToUTF16(kTestTemplateURLKeyword), |
254 "http://aqs/{searchTerms}/{google:assistedQueryStats}"); | 254 "http://aqs/{searchTerms}/{google:assistedQueryStats}"); |
255 | 255 |
256 ACProviders providers; | 256 AutocompleteController::Providers providers; |
257 | 257 |
258 // Construct two new providers, with either the same or different prefixes. | 258 // Construct two new providers, with either the same or different prefixes. |
259 TestProvider* provider1 = new TestProvider( | 259 TestProvider* provider1 = new TestProvider( |
260 kResultsPerProvider, | 260 kResultsPerProvider, |
261 base::ASCIIToUTF16("http://a"), | 261 base::ASCIIToUTF16("http://a"), |
262 &profile_, | 262 &profile_, |
263 base::ASCIIToUTF16(kTestTemplateURLKeyword)); | 263 base::ASCIIToUTF16(kTestTemplateURLKeyword)); |
264 provider1->AddRef(); | |
265 providers.push_back(provider1); | 264 providers.push_back(provider1); |
266 | 265 |
267 TestProvider* provider2 = new TestProvider( | 266 TestProvider* provider2 = new TestProvider( |
268 kResultsPerProvider * 2, | 267 kResultsPerProvider * 2, |
269 same_destinations ? base::ASCIIToUTF16("http://a") | 268 same_destinations ? base::ASCIIToUTF16("http://a") |
270 : base::ASCIIToUTF16("http://b"), | 269 : base::ASCIIToUTF16("http://b"), |
271 &profile_, | 270 &profile_, |
272 base::string16()); | 271 base::string16()); |
273 provider2->AddRef(); | |
274 providers.push_back(provider2); | 272 providers.push_back(provider2); |
275 | 273 |
276 // Reset the controller to contain our new providers. | 274 // Reset the controller to contain our new providers. |
277 controller_.reset(new AutocompleteController( | 275 controller_.reset(new AutocompleteController( |
278 &profile_, TemplateURLServiceFactory::GetForProfile(&profile_), NULL, 0)); | 276 &profile_, TemplateURLServiceFactory::GetForProfile(&profile_), NULL, 0)); |
279 // We're going to swap the providers vector, but the old vector should be | 277 // We're going to swap the providers vector, but the old vector should be |
280 // empty so no elements need to be freed at this point. | 278 // empty so no elements need to be freed at this point. |
281 EXPECT_TRUE(controller_->providers_.empty()); | 279 EXPECT_TRUE(controller_->providers_.empty()); |
282 controller_->providers_.swap(providers); | 280 controller_->providers_.swap(providers); |
283 provider1->set_listener(controller_.get()); | 281 provider1->set_listener(controller_.get()); |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); | 666 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); |
669 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j0j4&", url.path()); | 667 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j0j4&", url.path()); |
670 | 668 |
671 // Test page classification and field trial triggered set. | 669 // Test page classification and field trial triggered set. |
672 controller_->search_provider_->field_trial_triggered_in_session_ = true; | 670 controller_->search_provider_->field_trial_triggered_in_session_ = true; |
673 EXPECT_TRUE( | 671 EXPECT_TRUE( |
674 controller_->search_provider_->field_trial_triggered_in_session()); | 672 controller_->search_provider_->field_trial_triggered_in_session()); |
675 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); | 673 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); |
676 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j1j4&", url.path()); | 674 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j1j4&", url.path()); |
677 } | 675 } |
OLD | NEW |