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 "chrome/browser/autocomplete/search_provider.h" | 5 #include "chrome/browser/autocomplete/search_provider.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/time.h" | 8 #include "base/time.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
11 #include "chrome/browser/autocomplete/autocomplete.h" | 11 #include "chrome/browser/autocomplete/autocomplete.h" |
12 #include "chrome/browser/autocomplete/autocomplete_match.h" | 12 #include "chrome/browser/autocomplete/autocomplete_match.h" |
13 #include "chrome/browser/history/history.h" | 13 #include "chrome/browser/history/history.h" |
14 #include "chrome/browser/prefs/pref_service.h" | 14 #include "chrome/browser/prefs/pref_service.h" |
15 #include "chrome/browser/search_engines/template_url.h" | 15 #include "chrome/browser/search_engines/template_url.h" |
16 #include "chrome/browser/search_engines/template_url_service.h" | 16 #include "chrome/browser/search_engines/template_url_service.h" |
17 #include "chrome/browser/search_engines/template_url_service_factory.h" | 17 #include "chrome/browser/search_engines/template_url_service_factory.h" |
18 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
19 #include "chrome/test/base/testing_browser_process.h" | 19 #include "chrome/test/base/testing_browser_process.h" |
20 #include "chrome/test/base/testing_browser_process_test.h" | |
21 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
22 #include "content/browser/browser_thread.h" | 21 #include "content/browser/browser_thread.h" |
23 #include "content/test/test_url_fetcher_factory.h" | 22 #include "content/test/test_url_fetcher_factory.h" |
24 #include "net/url_request/url_request_status.h" | 23 #include "net/url_request/url_request_status.h" |
25 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
26 | 25 |
27 // The following environment is configured for these tests: | 26 // The following environment is configured for these tests: |
28 // . The TemplateURL default_t_url_ is set as the default provider. | 27 // . The TemplateURL default_t_url_ is set as the default provider. |
29 // . The TemplateURL keyword_t_url_ is added to the TemplateURLService. This | 28 // . The TemplateURL keyword_t_url_ is added to the TemplateURLService. This |
30 // TemplateURL has a valid suggest and search URL. | 29 // TemplateURL has a valid suggest and search URL. |
31 // . The URL created by using the search term term1_ with default_t_url_ is | 30 // . The URL created by using the search term term1_ with default_t_url_ is |
32 // added to history. | 31 // added to history. |
33 // . The URL created by using the search term keyword_term_ with keyword_t_url_ | 32 // . The URL created by using the search term keyword_term_ with keyword_t_url_ |
34 // is added to history. | 33 // is added to history. |
35 // . test_factory_ is set as the URLFetcher::Factory. | 34 // . test_factory_ is set as the URLFetcher::Factory. |
36 class SearchProviderTest : public TestingBrowserProcessTest, | 35 class SearchProviderTest : public testing::Test, |
37 public AutocompleteProvider::ACProviderListener { | 36 public AutocompleteProvider::ACProviderListener { |
38 public: | 37 public: |
39 SearchProviderTest() | 38 SearchProviderTest() |
40 : default_t_url_(NULL), | 39 : default_t_url_(NULL), |
41 term1_(UTF8ToUTF16("term1")), | 40 term1_(UTF8ToUTF16("term1")), |
42 keyword_t_url_(NULL), | 41 keyword_t_url_(NULL), |
43 keyword_term_(UTF8ToUTF16("keyword")), | 42 keyword_term_(UTF8ToUTF16("keyword")), |
44 io_thread_(BrowserThread::IO), | 43 io_thread_(BrowserThread::IO), |
45 quit_when_done_(false) { | 44 quit_when_done_(false) { |
46 io_thread_.Start(); | 45 io_thread_.Start(); |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 fetcher = NULL; | 657 fetcher = NULL; |
659 | 658 |
660 // Run till the history results complete. | 659 // Run till the history results complete. |
661 RunTillProviderDone(); | 660 RunTillProviderDone(); |
662 | 661 |
663 // Make sure there is a match for 'a.com' and it doesn't have a template_url. | 662 // Make sure there is a match for 'a.com' and it doesn't have a template_url. |
664 AutocompleteMatch nav_match; | 663 AutocompleteMatch nav_match; |
665 EXPECT_TRUE(FindMatchWithDestination(GURL("http://a.com"), &nav_match)); | 664 EXPECT_TRUE(FindMatchWithDestination(GURL("http://a.com"), &nav_match)); |
666 EXPECT_FALSE(nav_match.template_url); | 665 EXPECT_FALSE(nav_match.template_url); |
667 } | 666 } |
OLD | NEW |