| 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/string_util.h" | 5 #include "base/string_util.h" |
| 6 #include "base/time.h" | 6 #include "base/time.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "chrome/browser/autocomplete/autocomplete_match.h" | 9 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 10 #include "chrome/browser/autocomplete/search_provider.h" | 10 #include "chrome/browser/autocomplete/search_provider.h" |
| 11 #include "chrome/browser/browser_thread.h" | 11 #include "chrome/browser/browser_thread.h" |
| 12 #include "chrome/browser/history/history.h" | 12 #include "chrome/browser/history/history.h" |
| 13 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
| 14 #include "chrome/browser/search_engines/template_url.h" | 14 #include "chrome/browser/search_engines/template_url.h" |
| 15 #include "chrome/browser/search_engines/template_url_model.h" | 15 #include "chrome/browser/search_engines/template_url_model.h" |
| 16 #include "chrome/common/net/test_url_fetcher_factory.h" | 16 #include "chrome/common/net/test_url_fetcher_factory.h" |
| 17 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 18 #include "chrome/test/testing_browser_process.h" |
| 19 #include "chrome/test/testing_browser_process_test.h" |
| 18 #include "chrome/test/testing_profile.h" | 20 #include "chrome/test/testing_profile.h" |
| 19 #include "net/url_request/url_request_status.h" | 21 #include "net/url_request/url_request_status.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 21 | 23 |
| 22 // The following environment is configured for these tests: | 24 // The following environment is configured for these tests: |
| 23 // . The TemplateURL default_t_url_ is set as the default provider. | 25 // . The TemplateURL default_t_url_ is set as the default provider. |
| 24 // . The TemplateURL keyword_t_url_ is added to the TemplateURLModel. This | 26 // . The TemplateURL keyword_t_url_ is added to the TemplateURLModel. This |
| 25 // TemplateURL has a valid suggest and search URL. | 27 // TemplateURL has a valid suggest and search URL. |
| 26 // . The URL created by using the search term term1_ with default_t_url_ is | 28 // . The URL created by using the search term term1_ with default_t_url_ is |
| 27 // added to history. | 29 // added to history. |
| 28 // . The URL created by using the search term keyword_term_ with keyword_t_url_ | 30 // . The URL created by using the search term keyword_term_ with keyword_t_url_ |
| 29 // is added to history. | 31 // is added to history. |
| 30 // . test_factory_ is set as the URLFetcher::Factory. | 32 // . test_factory_ is set as the URLFetcher::Factory. |
| 31 class SearchProviderTest : public testing::Test, | 33 class SearchProviderTest : public TestingBrowserProcessTest, |
| 32 public AutocompleteProvider::ACProviderListener { | 34 public AutocompleteProvider::ACProviderListener { |
| 33 public: | 35 public: |
| 34 SearchProviderTest() | 36 SearchProviderTest() |
| 35 : default_t_url_(NULL), | 37 : default_t_url_(NULL), |
| 36 term1_(UTF8ToUTF16("term1")), | 38 term1_(UTF8ToUTF16("term1")), |
| 37 keyword_t_url_(NULL), | 39 keyword_t_url_(NULL), |
| 38 keyword_term_(UTF8ToUTF16("keyword")), | 40 keyword_term_(UTF8ToUTF16("keyword")), |
| 39 io_thread_(BrowserThread::IO), | 41 io_thread_(BrowserThread::IO), |
| 40 quit_when_done_(false) { | 42 quit_when_done_(false) { |
| 41 io_thread_.Start(); | 43 io_thread_.Start(); |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 // originally supplied. | 446 // originally supplied. |
| 445 QueryForInput(ASCIIToUTF16("foo "), false, true); | 447 QueryForInput(ASCIIToUTF16("foo "), false, true); |
| 446 | 448 |
| 447 // There should only one match, for what you typed. | 449 // There should only one match, for what you typed. |
| 448 EXPECT_EQ(1u, provider_->matches().size()); | 450 EXPECT_EQ(1u, provider_->matches().size()); |
| 449 GURL instant_url = GURL(default_t_url_->url()->ReplaceSearchTerms( | 451 GURL instant_url = GURL(default_t_url_->url()->ReplaceSearchTerms( |
| 450 *default_t_url_, ASCIIToUTF16("foo"), 0, string16())); | 452 *default_t_url_, ASCIIToUTF16("foo"), 0, string16())); |
| 451 AutocompleteMatch instant_match = FindMatchWithDestination(instant_url); | 453 AutocompleteMatch instant_match = FindMatchWithDestination(instant_url); |
| 452 EXPECT_FALSE(instant_match.destination_url.is_empty()); | 454 EXPECT_FALSE(instant_match.destination_url.is_empty()); |
| 453 } | 455 } |
| OLD | NEW |