Index: chrome/browser/search/search_unittest.cc |
diff --git a/chrome/browser/search/search_unittest.cc b/chrome/browser/search/search_unittest.cc |
index 36a09d651aa7e946bdd04cb85490c1079b5cb8c5..893230880f357b5707fc5bdb43f987ae86df271c 100644 |
--- a/chrome/browser/search/search_unittest.cc |
+++ b/chrome/browser/search/search_unittest.cc |
@@ -11,6 +11,7 @@ |
#include "chrome/browser/search/instant_service.h" |
#include "chrome/browser/search/instant_service_factory.h" |
#include "chrome/browser/search/search.h" |
+#include "chrome/browser/search/search_test_utils.h" |
#include "chrome/browser/search_engines/search_terms_data.h" |
#include "chrome/browser/search_engines/template_url_service.h" |
#include "chrome/browser/search_engines/template_url_service_factory.h" |
@@ -184,47 +185,7 @@ class SearchTest : public BrowserWithTestWindowTest { |
TemplateURLService* template_url_service = |
TemplateURLServiceFactory::GetForProfile(profile()); |
ui_test_utils::WaitForTemplateURLServiceToLoad(template_url_service); |
- SetSearchProvider(); |
- } |
- |
- void SetSearchProvider() { |
- TemplateURLService* template_url_service = |
- TemplateURLServiceFactory::GetForProfile(profile()); |
- TemplateURLData data; |
- data.SetURL("http://foo.com/url?bar={searchTerms}"); |
- data.instant_url = "http://foo.com/instant?" |
- "{google:omniboxStartMarginParameter}foo=foo#foo=foo&strk"; |
- data.alternate_urls.push_back("http://foo.com/alt#quux={searchTerms}"); |
- data.search_terms_replacement_key = "strk"; |
- |
- TemplateURL* template_url = new TemplateURL(profile(), data); |
- // Takes ownership of |template_url|. |
- template_url_service->Add(template_url); |
- template_url_service->SetDefaultSearchProvider(template_url); |
- } |
- |
- // Build an Instant URL with or without a valid search terms replacement key |
- // as per |has_search_term_replacement_key|. Set that URL as the instant URL |
- // for the default search provider. |
- void SetDefaultInstantTemplateUrl(bool has_search_term_replacement_key) { |
- TemplateURLService* template_url_service = |
- TemplateURLServiceFactory::GetForProfile(profile()); |
- |
- static const char kInstantURLWithStrk[] = |
- "http://foo.com/instant?foo=foo#foo=foo&strk"; |
- static const char kInstantURLNoStrk[] = |
- "http://foo.com/instant?foo=foo#foo=foo"; |
- |
- TemplateURLData data; |
- data.SetURL("http://foo.com/url?bar={searchTerms}"); |
- data.instant_url = (has_search_term_replacement_key ? |
- kInstantURLWithStrk : kInstantURLNoStrk); |
- data.search_terms_replacement_key = "strk"; |
- |
- TemplateURL* template_url = new TemplateURL(profile(), data); |
- // Takes ownership of |template_url|. |
- template_url_service->Add(template_url); |
- template_url_service->SetDefaultSearchProvider(template_url); |
+ search_test_utils::SetSearchProvider(profile()); |
} |
bool InInstantProcess(const content::WebContents* contents) { |
@@ -523,11 +484,11 @@ TEST_F(SearchTest, GetInstantURLExtendedEnabled) { |
// Enable Instant. Still no Instant URL because "strk" is missing. |
EnableInstantExtendedAPIForTesting(); |
- SetDefaultInstantTemplateUrl(false); |
+ search_test_utils::SetDefaultInstantTemplateUrl(profile(), false); |
EXPECT_EQ(GURL(), GetInstantURL(profile(), kDisableStartMargin)); |
// Set an Instant URL with a valid search terms replacement key. |
- SetDefaultInstantTemplateUrl(true); |
+ search_test_utils::SetDefaultInstantTemplateUrl(profile(), true); |
// Now there should be a valid Instant URL. Note the HTTPS "upgrade". |
EXPECT_EQ(GURL("https://foo.com/instant?foo=foo#foo=foo&strk"), |