| 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" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" | 12 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" |
| 13 #include "chrome/browser/autocomplete/autocomplete_controller.h" | 13 #include "chrome/browser/autocomplete/autocomplete_controller.h" |
| 14 #include "chrome/browser/autocomplete/autocomplete_input.h" | 14 #include "chrome/browser/autocomplete/autocomplete_input.h" |
| 15 #include "chrome/browser/autocomplete/autocomplete_match.h" | 15 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 16 #include "chrome/browser/autocomplete/autocomplete_provider.h" | 16 #include "chrome/browser/autocomplete/autocomplete_provider.h" |
| 17 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" | 17 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" |
| 18 #include "chrome/browser/history/history.h" | 18 #include "chrome/browser/history/history.h" |
| 19 #include "chrome/browser/history/history_service_factory.h" | 19 #include "chrome/browser/history/history_service_factory.h" |
| 20 #include "chrome/browser/instant/instant_controller.h" |
| 20 #include "chrome/browser/prefs/pref_service.h" | 21 #include "chrome/browser/prefs/pref_service.h" |
| 21 #include "chrome/browser/search_engines/template_url.h" | 22 #include "chrome/browser/search_engines/template_url.h" |
| 22 #include "chrome/browser/search_engines/template_url_service.h" | 23 #include "chrome/browser/search_engines/template_url_service.h" |
| 23 #include "chrome/browser/search_engines/template_url_service_factory.h" | 24 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 24 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
| 25 #include "chrome/test/base/testing_browser_process.h" | 26 #include "chrome/test/base/testing_browser_process.h" |
| 26 #include "chrome/test/base/testing_profile.h" | 27 #include "chrome/test/base/testing_profile.h" |
| 27 #include "content/public/test/test_browser_thread.h" | 28 #include "content/public/test/test_browser_thread.h" |
| 28 #include "net/url_request/test_url_fetcher_factory.h" | 29 #include "net/url_request/test_url_fetcher_factory.h" |
| 29 #include "net/url_request/url_request_status.h" | 30 #include "net/url_request/url_request_status.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 // URLFetchers runs. | 204 // URLFetchers runs. |
| 204 message_loop_.RunAllPending(); | 205 message_loop_.RunAllPending(); |
| 205 } | 206 } |
| 206 | 207 |
| 207 void SearchProviderTest::QueryForInputAndSetWYTMatch( | 208 void SearchProviderTest::QueryForInputAndSetWYTMatch( |
| 208 const string16& text, | 209 const string16& text, |
| 209 AutocompleteMatch* wyt_match) { | 210 AutocompleteMatch* wyt_match) { |
| 210 QueryForInput(text, string16(), false); | 211 QueryForInput(text, string16(), false); |
| 211 profile_.BlockUntilHistoryProcessesPendingRequests(); | 212 profile_.BlockUntilHistoryProcessesPendingRequests(); |
| 212 ASSERT_NO_FATAL_FAILURE(FinishDefaultSuggestQuery()); | 213 ASSERT_NO_FATAL_FAILURE(FinishDefaultSuggestQuery()); |
| 213 EXPECT_NE(profile_.GetPrefs()->GetBoolean(prefs::kInstantEnabled), | 214 EXPECT_NE(InstantController::IsSuggestEnabled(&profile_), provider_->done()); |
| 214 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() { |
| (...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1248 EXPECT_EQ(AutocompleteMatch::ACMatchClassification::URL, | 1248 EXPECT_EQ(AutocompleteMatch::ACMatchClassification::URL, |
| 1249 match.contents_class[0].style); | 1249 match.contents_class[0].style); |
| 1250 EXPECT_EQ(4U, match.contents_class[1].offset); | 1250 EXPECT_EQ(4U, match.contents_class[1].offset); |
| 1251 EXPECT_EQ(AutocompleteMatch::ACMatchClassification::URL | | 1251 EXPECT_EQ(AutocompleteMatch::ACMatchClassification::URL | |
| 1252 AutocompleteMatch::ACMatchClassification::MATCH, | 1252 AutocompleteMatch::ACMatchClassification::MATCH, |
| 1253 match.contents_class[1].style); | 1253 match.contents_class[1].style); |
| 1254 EXPECT_EQ(5U, match.contents_class[2].offset); | 1254 EXPECT_EQ(5U, match.contents_class[2].offset); |
| 1255 EXPECT_EQ(AutocompleteMatch::ACMatchClassification::URL, | 1255 EXPECT_EQ(AutocompleteMatch::ACMatchClassification::URL, |
| 1256 match.contents_class[2].style); | 1256 match.contents_class[2].style); |
| 1257 } | 1257 } |
| OLD | NEW |