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/search_provider.h" | 5 #include "chrome/browser/autocomplete/search_provider.h" |
6 | 6 |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 void SearchProviderTest::QueryForInput(const string16& text, | 195 void SearchProviderTest::QueryForInput(const string16& text, |
196 const string16& desired_tld, | 196 const string16& desired_tld, |
197 bool prevent_inline_autocomplete) { | 197 bool prevent_inline_autocomplete) { |
198 // Start a query. | 198 // Start a query. |
199 AutocompleteInput input(text, desired_tld, prevent_inline_autocomplete, | 199 AutocompleteInput input(text, desired_tld, prevent_inline_autocomplete, |
200 false, true, AutocompleteInput::ALL_MATCHES); | 200 false, true, AutocompleteInput::ALL_MATCHES); |
201 provider_->Start(input, false); | 201 provider_->Start(input, false); |
202 | 202 |
203 // RunAllPending so that the task scheduled by SearchProvider to create the | 203 // RunAllPending so that the task scheduled by SearchProvider to create the |
204 // URLFetchers runs. | 204 // URLFetchers runs. |
205 message_loop_.RunAllPending(); | 205 message_loop_.RunUntilIdle(); |
206 } | 206 } |
207 | 207 |
208 void SearchProviderTest::QueryForInputAndSetWYTMatch( | 208 void SearchProviderTest::QueryForInputAndSetWYTMatch( |
209 const string16& text, | 209 const string16& text, |
210 AutocompleteMatch* wyt_match) { | 210 AutocompleteMatch* wyt_match) { |
211 QueryForInput(text, string16(), false); | 211 QueryForInput(text, string16(), false); |
212 profile_.BlockUntilHistoryProcessesPendingRequests(); | 212 profile_.BlockUntilHistoryProcessesPendingRequests(); |
213 ASSERT_NO_FATAL_FAILURE(FinishDefaultSuggestQuery()); | 213 ASSERT_NO_FATAL_FAILURE(FinishDefaultSuggestQuery()); |
214 EXPECT_NE(InstantController::IsInstantEnabled(&profile_), provider_->done()); | 214 EXPECT_NE(InstantController::IsInstantEnabled(&profile_), provider_->done()); |
215 if (!wyt_match) | 215 if (!wyt_match) |
216 return; | 216 return; |
217 ASSERT_GE(provider_->matches().size(), 1u); | 217 ASSERT_GE(provider_->matches().size(), 1u); |
218 EXPECT_TRUE(FindMatchWithDestination(GURL( | 218 EXPECT_TRUE(FindMatchWithDestination(GURL( |
219 default_t_url_->url_ref().ReplaceSearchTerms( | 219 default_t_url_->url_ref().ReplaceSearchTerms( |
220 TemplateURLRef::SearchTermsArgs(text))), | 220 TemplateURLRef::SearchTermsArgs(text))), |
221 wyt_match)); | 221 wyt_match)); |
222 } | 222 } |
223 | 223 |
224 void SearchProviderTest::TearDown() { | 224 void SearchProviderTest::TearDown() { |
225 message_loop_.RunAllPending(); | 225 message_loop_.RunUntilIdle(); |
226 | 226 |
227 // Shutdown the provider before the profile. | 227 // Shutdown the provider before the profile. |
228 provider_ = NULL; | 228 provider_ = NULL; |
229 } | 229 } |
230 | 230 |
231 GURL SearchProviderTest::AddSearchToHistory(TemplateURL* t_url, | 231 GURL SearchProviderTest::AddSearchToHistory(TemplateURL* t_url, |
232 string16 term, | 232 string16 term, |
233 int visit_count) { | 233 int visit_count) { |
234 HistoryService* history = | 234 HistoryService* history = |
235 HistoryServiceFactory::GetForProfile(&profile_, | 235 HistoryServiceFactory::GetForProfile(&profile_, |
(...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1253 EXPECT_EQ(AutocompleteMatch::ACMatchClassification::URL, | 1253 EXPECT_EQ(AutocompleteMatch::ACMatchClassification::URL, |
1254 match.contents_class[0].style); | 1254 match.contents_class[0].style); |
1255 EXPECT_EQ(4U, match.contents_class[1].offset); | 1255 EXPECT_EQ(4U, match.contents_class[1].offset); |
1256 EXPECT_EQ(AutocompleteMatch::ACMatchClassification::URL | | 1256 EXPECT_EQ(AutocompleteMatch::ACMatchClassification::URL | |
1257 AutocompleteMatch::ACMatchClassification::MATCH, | 1257 AutocompleteMatch::ACMatchClassification::MATCH, |
1258 match.contents_class[1].style); | 1258 match.contents_class[1].style); |
1259 EXPECT_EQ(5U, match.contents_class[2].offset); | 1259 EXPECT_EQ(5U, match.contents_class[2].offset); |
1260 EXPECT_EQ(AutocompleteMatch::ACMatchClassification::URL, | 1260 EXPECT_EQ(AutocompleteMatch::ACMatchClassification::URL, |
1261 match.contents_class[2].style); | 1261 match.contents_class[2].style); |
1262 } | 1262 } |
OLD | NEW |