| 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/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/browser/webdata/web_data_service_factory.h" |
| 18 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
| 19 #include "chrome/test/base/testing_browser_process.h" | 20 #include "chrome/test/base/testing_browser_process.h" |
| 20 #include "chrome/test/base/testing_profile.h" | 21 #include "chrome/test/base/testing_profile.h" |
| 21 #include "content/test/test_browser_thread.h" | 22 #include "content/test/test_browser_thread.h" |
| 22 #include "content/test/test_url_fetcher_factory.h" | 23 #include "content/test/test_url_fetcher_factory.h" |
| 23 #include "net/url_request/url_request_status.h" | 24 #include "net/url_request/url_request_status.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 25 | 26 |
| 26 using content::BrowserThread; | 27 using content::BrowserThread; |
| 27 | 28 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 // If true, OnProviderUpdate exits out of the current message loop. | 106 // If true, OnProviderUpdate exits out of the current message loop. |
| 106 bool quit_when_done_; | 107 bool quit_when_done_; |
| 107 | 108 |
| 108 DISALLOW_COPY_AND_ASSIGN(SearchProviderTest); | 109 DISALLOW_COPY_AND_ASSIGN(SearchProviderTest); |
| 109 }; | 110 }; |
| 110 | 111 |
| 111 void SearchProviderTest::SetUp() { | 112 void SearchProviderTest::SetUp() { |
| 112 SearchProvider::set_query_suggest_immediately(true); | 113 SearchProvider::set_query_suggest_immediately(true); |
| 113 | 114 |
| 114 // We need both the history service and template url model loaded. | 115 // We need both the history service and template url model loaded. |
| 116 // TemplateURLService relies on the absence of the WebDataService in tests. |
| 117 WebDataServiceFactory::GetInstance()->SetTestingFactory(&profile_, NULL); |
| 115 profile_.CreateHistoryService(true, false); | 118 profile_.CreateHistoryService(true, false); |
| 116 profile_.CreateTemplateURLService(); | 119 profile_.CreateTemplateURLService(); |
| 117 | 120 |
| 118 TemplateURLService* turl_model = | 121 TemplateURLService* turl_model = |
| 119 TemplateURLServiceFactory::GetForProfile(&profile_); | 122 TemplateURLServiceFactory::GetForProfile(&profile_); |
| 120 | 123 |
| 121 turl_model->Load(); | 124 turl_model->Load(); |
| 122 | 125 |
| 123 // Reset the default TemplateURL. | 126 // Reset the default TemplateURL. |
| 124 TemplateURLData data; | 127 TemplateURLData data; |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 fetcher = NULL; | 664 fetcher = NULL; |
| 662 | 665 |
| 663 // Run till the history results complete. | 666 // Run till the history results complete. |
| 664 RunTillProviderDone(); | 667 RunTillProviderDone(); |
| 665 | 668 |
| 666 // Make sure there is a match for 'a.com' and it doesn't have a template_url. | 669 // Make sure there is a match for 'a.com' and it doesn't have a template_url. |
| 667 AutocompleteMatch nav_match; | 670 AutocompleteMatch nav_match; |
| 668 EXPECT_TRUE(FindMatchWithDestination(GURL("http://a.com"), &nav_match)); | 671 EXPECT_TRUE(FindMatchWithDestination(GURL("http://a.com"), &nav_match)); |
| 669 EXPECT_FALSE(nav_match.template_url); | 672 EXPECT_FALSE(nav_match.template_url); |
| 670 } | 673 } |
| OLD | NEW |