OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/autocomplete/autocomplete.h" | 10 #include "chrome/browser/autocomplete/autocomplete.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 ASCIIToUTF16("http://a")); | 146 ASCIIToUTF16("http://a")); |
147 providerA->AddRef(); | 147 providerA->AddRef(); |
148 providers_.push_back(providerA); | 148 providers_.push_back(providerA); |
149 | 149 |
150 TestProvider* providerB = new TestProvider(num_results_per_provider * 2, | 150 TestProvider* providerB = new TestProvider(num_results_per_provider * 2, |
151 same_destinations ? ASCIIToUTF16("http://a") : ASCIIToUTF16("http://b")); | 151 same_destinations ? ASCIIToUTF16("http://a") : ASCIIToUTF16("http://b")); |
152 providerB->AddRef(); | 152 providerB->AddRef(); |
153 providers_.push_back(providerB); | 153 providers_.push_back(providerB); |
154 | 154 |
155 // Reset the controller to contain our new providers. | 155 // Reset the controller to contain our new providers. |
156 AutocompleteController* controller = | 156 AutocompleteController* controller = new AutocompleteController(providers_); |
157 new AutocompleteController(providers_, &profile_); | |
158 controller_.reset(controller); | 157 controller_.reset(controller); |
159 providerA->set_listener(controller); | 158 providerA->set_listener(controller); |
160 providerB->set_listener(controller); | 159 providerB->set_listener(controller); |
161 | 160 |
162 // The providers don't complete synchronously, so listen for "result updated" | 161 // The providers don't complete synchronously, so listen for "result updated" |
163 // notifications. | 162 // notifications. |
164 registrar_.Add(this, | 163 registrar_.Add(this, |
165 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY, | 164 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY, |
166 NotificationService::AllSources()); | 165 NotificationService::AllSources()); |
167 } | 166 } |
(...skipping 27 matching lines...) Expand all Loading... |
195 // Create both a keyword and search provider, and add them in that order. | 194 // Create both a keyword and search provider, and add them in that order. |
196 // (Order is important; see comments in RunExactKeymatchTest().) | 195 // (Order is important; see comments in RunExactKeymatchTest().) |
197 AutocompleteProvider* keyword_provider = new KeywordProvider(NULL, | 196 AutocompleteProvider* keyword_provider = new KeywordProvider(NULL, |
198 &profile_); | 197 &profile_); |
199 keyword_provider->AddRef(); | 198 keyword_provider->AddRef(); |
200 providers_.push_back(keyword_provider); | 199 providers_.push_back(keyword_provider); |
201 AutocompleteProvider* search_provider = new SearchProvider(NULL, &profile_); | 200 AutocompleteProvider* search_provider = new SearchProvider(NULL, &profile_); |
202 search_provider->AddRef(); | 201 search_provider->AddRef(); |
203 providers_.push_back(search_provider); | 202 providers_.push_back(search_provider); |
204 | 203 |
205 AutocompleteController* controller = | 204 AutocompleteController* controller = new AutocompleteController(providers_); |
206 new AutocompleteController(providers_, &profile_); | |
207 controller_.reset(controller); | 205 controller_.reset(controller); |
208 } | 206 } |
209 | 207 |
210 void AutocompleteProviderTest::RunTest() { | 208 void AutocompleteProviderTest::RunTest() { |
211 result_.Reset(); | 209 result_.Reset(); |
212 controller_->Start(ASCIIToUTF16("a"), string16(), true, false, true, | 210 controller_->Start(ASCIIToUTF16("a"), string16(), true, false, true, |
213 AutocompleteInput::ALL_MATCHES); | 211 AutocompleteInput::ALL_MATCHES); |
214 | 212 |
215 // The message loop will terminate when all autocomplete input has been | 213 // The message loop will terminate when all autocomplete input has been |
216 // collected. | 214 // collected. |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 EXPECT_EQ(input_cases[i].scheme.len, scheme.len) << "Input: " << | 471 EXPECT_EQ(input_cases[i].scheme.len, scheme.len) << "Input: " << |
474 input_cases[i].input; | 472 input_cases[i].input; |
475 EXPECT_EQ(input_cases[i].host.begin, host.begin) << "Input: " << | 473 EXPECT_EQ(input_cases[i].host.begin, host.begin) << "Input: " << |
476 input_cases[i].input; | 474 input_cases[i].input; |
477 EXPECT_EQ(input_cases[i].host.len, host.len) << "Input: " << | 475 EXPECT_EQ(input_cases[i].host.len, host.len) << "Input: " << |
478 input_cases[i].input; | 476 input_cases[i].input; |
479 } | 477 } |
480 } | 478 } |
481 | 479 |
482 } // namespace | 480 } // namespace |
OLD | NEW |