Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: chrome/browser/search/instant_unittest_base.cc

Issue 141893009: Create a new helper function to extract search terms from the URL irrespective of the availablility (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/search/instant_unittest_base.h ('k') | chrome/browser/search/search.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/search/instant_unittest_base.h" 5 #include "chrome/browser/search/instant_unittest_base.h"
6 #include <string> 6 #include <string>
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/google/google_url_tracker.h" 10 #include "chrome/browser/google/google_url_tracker.h"
(...skipping 16 matching lines...) Expand all
27 27
28 InstantUnitTestBase::InstantUnitTestBase() { 28 InstantUnitTestBase::InstantUnitTestBase() {
29 field_trial_list_.reset(new base::FieldTrialList( 29 field_trial_list_.reset(new base::FieldTrialList(
30 new metrics::SHA1EntropyProvider("42"))); 30 new metrics::SHA1EntropyProvider("42")));
31 } 31 }
32 32
33 InstantUnitTestBase::~InstantUnitTestBase() { 33 InstantUnitTestBase::~InstantUnitTestBase() {
34 } 34 }
35 35
36 void InstantUnitTestBase::SetUp() { 36 void InstantUnitTestBase::SetUp() {
37 chrome::EnableQueryExtractionForTesting();
37 SetUpHelper(); 38 SetUpHelper();
38 } 39 }
39 40
40 void InstantUnitTestBase::SetUpHelper() {
41 chrome::EnableQueryExtractionForTesting();
42 BrowserWithTestWindowTest::SetUp();
43
44 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
45 profile(), &TemplateURLServiceFactory::BuildInstanceFor);
46 template_url_service_ = TemplateURLServiceFactory::GetForProfile(profile());
47 ui_test_utils::WaitForTemplateURLServiceToLoad(template_url_service_);
48
49 UIThreadSearchTermsData::SetGoogleBaseURL("https://www.google.com/");
50 TestingPrefServiceSyncable* pref_service = profile()->GetTestingPrefService();
51 pref_service->SetUserPref(prefs::kLastPromptedGoogleURL,
52 new base::StringValue("https://www.google.com/"));
53 SetDefaultSearchProvider("{google:baseURL}");
54 instant_service_ = InstantServiceFactory::GetForProfile(profile());
55 }
56
57 void InstantUnitTestBase::TearDown() { 41 void InstantUnitTestBase::TearDown() {
58 UIThreadSearchTermsData::SetGoogleBaseURL(""); 42 UIThreadSearchTermsData::SetGoogleBaseURL("");
59 BrowserWithTestWindowTest::TearDown(); 43 BrowserWithTestWindowTest::TearDown();
60 } 44 }
61 45
46 #if !defined(OS_IOS) && !defined(OS_ANDROID)
47 void InstantUnitTestBase::SetUpWithoutQueryExtraction() {
48 SetUpHelper();
49 }
50 #endif
51
62 void InstantUnitTestBase::SetDefaultSearchProvider( 52 void InstantUnitTestBase::SetDefaultSearchProvider(
63 const std::string& base_url) { 53 const std::string& base_url) {
64 TemplateURLData data; 54 TemplateURLData data;
65 data.SetURL(base_url + "url?bar={searchTerms}"); 55 data.SetURL(base_url + "url?bar={searchTerms}");
66 data.instant_url = base_url + 56 data.instant_url = base_url +
67 "instant?{google:omniboxStartMarginParameter}{google:forceInstantResults}" 57 "instant?{google:omniboxStartMarginParameter}{google:forceInstantResults}"
68 "foo=foo#foo=foo&strk"; 58 "foo=foo#foo=foo&strk";
69 data.new_tab_url = base_url + "newtab"; 59 data.new_tab_url = base_url + "newtab";
70 data.alternate_urls.push_back(base_url + "alt#quux={searchTerms}"); 60 data.alternate_urls.push_back(base_url + "alt#quux={searchTerms}");
71 data.search_terms_replacement_key = "strk"; 61 data.search_terms_replacement_key = "strk";
(...skipping 13 matching lines...) Expand all
85 // For simulating test behavior, this is overridden below. 75 // For simulating test behavior, this is overridden below.
86 UIThreadSearchTermsData::SetGoogleBaseURL(new_google_base_url); 76 UIThreadSearchTermsData::SetGoogleBaseURL(new_google_base_url);
87 GoogleURLTracker::UpdatedDetails details(GURL("https://www.google.com/"), 77 GoogleURLTracker::UpdatedDetails details(GURL("https://www.google.com/"),
88 GURL(new_google_base_url)); 78 GURL(new_google_base_url));
89 content::NotificationService::current()->Notify( 79 content::NotificationService::current()->Notify(
90 chrome::NOTIFICATION_GOOGLE_URL_UPDATED, 80 chrome::NOTIFICATION_GOOGLE_URL_UPDATED,
91 content::Source<Profile>(profile()->GetOriginalProfile()), 81 content::Source<Profile>(profile()->GetOriginalProfile()),
92 content::Details<GoogleURLTracker::UpdatedDetails>(&details)); 82 content::Details<GoogleURLTracker::UpdatedDetails>(&details));
93 } 83 }
94 84
95
96 bool InstantUnitTestBase::IsInstantServiceObserver( 85 bool InstantUnitTestBase::IsInstantServiceObserver(
97 InstantServiceObserver* observer) { 86 InstantServiceObserver* observer) {
98 return instant_service_->observers_.HasObserver(observer); 87 return instant_service_->observers_.HasObserver(observer);
99 } 88 }
100 89
90 void InstantUnitTestBase::SetUpHelper() {
91 BrowserWithTestWindowTest::SetUp();
92
93 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
94 profile(), &TemplateURLServiceFactory::BuildInstanceFor);
95 template_url_service_ = TemplateURLServiceFactory::GetForProfile(profile());
96 ui_test_utils::WaitForTemplateURLServiceToLoad(template_url_service_);
97
98 UIThreadSearchTermsData::SetGoogleBaseURL("https://www.google.com/");
99 TestingPrefServiceSyncable* pref_service = profile()->GetTestingPrefService();
100 pref_service->SetUserPref(prefs::kLastPromptedGoogleURL,
101 new base::StringValue("https://www.google.com/"));
102 SetDefaultSearchProvider("{google:baseURL}");
103 instant_service_ = InstantServiceFactory::GetForProfile(profile());
104 }
OLDNEW
« no previous file with comments | « chrome/browser/search/instant_unittest_base.h ('k') | chrome/browser/search/search.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698