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

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

Issue 273153004: Revert of Handle TemplateURLService load failure better, and make some test correctness fixes that will be ne… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
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/strings/utf_string_conversions.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"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/search/instant_service.h" 12 #include "chrome/browser/search/instant_service.h"
13 #include "chrome/browser/search/instant_service_factory.h" 13 #include "chrome/browser/search/instant_service_factory.h"
14 #include "chrome/browser/search/search.h" 14 #include "chrome/browser/search/search.h"
15 #include "chrome/browser/search_engines/search_terms_data.h" 15 #include "chrome/browser/search_engines/search_terms_data.h"
16 #include "chrome/browser/search_engines/template_url.h" 16 #include "chrome/browser/search_engines/template_url.h"
17 #include "chrome/browser/search_engines/template_url_service.h" 17 #include "chrome/browser/search_engines/template_url_service.h"
18 #include "chrome/browser/search_engines/template_url_service_factory.h" 18 #include "chrome/browser/search_engines/template_url_service_factory.h"
(...skipping 26 matching lines...) Expand all
45 45
46 #if !defined(OS_IOS) && !defined(OS_ANDROID) 46 #if !defined(OS_IOS) && !defined(OS_ANDROID)
47 void InstantUnitTestBase::SetUpWithoutQueryExtraction() { 47 void InstantUnitTestBase::SetUpWithoutQueryExtraction() {
48 SetUpHelper(); 48 SetUpHelper();
49 } 49 }
50 #endif 50 #endif
51 51
52 void InstantUnitTestBase::SetUserSelectedDefaultSearchProvider( 52 void InstantUnitTestBase::SetUserSelectedDefaultSearchProvider(
53 const std::string& base_url) { 53 const std::string& base_url) {
54 TemplateURLData data; 54 TemplateURLData data;
55 data.SetKeyword(base::UTF8ToUTF16(base_url));
56 data.SetURL(base_url + "url?bar={searchTerms}"); 55 data.SetURL(base_url + "url?bar={searchTerms}");
57 data.instant_url = base_url + 56 data.instant_url = base_url +
58 "instant?{google:omniboxStartMarginParameter}{google:forceInstantResults}" 57 "instant?{google:omniboxStartMarginParameter}{google:forceInstantResults}"
59 "foo=foo#foo=foo&strk"; 58 "foo=foo#foo=foo&strk";
60 data.new_tab_url = base_url + "newtab"; 59 data.new_tab_url = base_url + "newtab";
61 data.alternate_urls.push_back(base_url + "alt#quux={searchTerms}"); 60 data.alternate_urls.push_back(base_url + "alt#quux={searchTerms}");
62 data.search_terms_replacement_key = "strk"; 61 data.search_terms_replacement_key = "strk";
63 62
64 TemplateURL* template_url = new TemplateURL(profile(), data); 63 TemplateURL* template_url = new TemplateURL(profile(), data);
65 // Takes ownership of |template_url|. 64 // Takes ownership of |template_url|.
(...skipping 15 matching lines...) Expand all
81 chrome::NOTIFICATION_GOOGLE_URL_UPDATED, 80 chrome::NOTIFICATION_GOOGLE_URL_UPDATED,
82 content::Source<Profile>(profile()->GetOriginalProfile()), 81 content::Source<Profile>(profile()->GetOriginalProfile()),
83 content::Details<GoogleURLTracker::UpdatedDetails>(&details)); 82 content::Details<GoogleURLTracker::UpdatedDetails>(&details));
84 } 83 }
85 84
86 bool InstantUnitTestBase::IsInstantServiceObserver( 85 bool InstantUnitTestBase::IsInstantServiceObserver(
87 InstantServiceObserver* observer) { 86 InstantServiceObserver* observer) {
88 return instant_service_->observers_.HasObserver(observer); 87 return instant_service_->observers_.HasObserver(observer);
89 } 88 }
90 89
91 TestingProfile* InstantUnitTestBase::CreateProfile() {
92 TestingProfile* profile = BrowserWithTestWindowTest::CreateProfile();
93 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
94 profile, &TemplateURLServiceFactory::BuildInstanceFor);
95 return profile;
96 }
97
98 void InstantUnitTestBase::SetUpHelper() { 90 void InstantUnitTestBase::SetUpHelper() {
99 BrowserWithTestWindowTest::SetUp(); 91 BrowserWithTestWindowTest::SetUp();
100 92
93 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
94 profile(), &TemplateURLServiceFactory::BuildInstanceFor);
101 template_url_service_ = TemplateURLServiceFactory::GetForProfile(profile()); 95 template_url_service_ = TemplateURLServiceFactory::GetForProfile(profile());
102 ui_test_utils::WaitForTemplateURLServiceToLoad(template_url_service_); 96 ui_test_utils::WaitForTemplateURLServiceToLoad(template_url_service_);
103 97
104 UIThreadSearchTermsData::SetGoogleBaseURL("https://www.google.com/"); 98 UIThreadSearchTermsData::SetGoogleBaseURL("https://www.google.com/");
105 TestingPrefServiceSyncable* pref_service = profile()->GetTestingPrefService(); 99 TestingPrefServiceSyncable* pref_service = profile()->GetTestingPrefService();
106 pref_service->SetUserPref(prefs::kLastPromptedGoogleURL, 100 pref_service->SetUserPref(prefs::kLastPromptedGoogleURL,
107 new base::StringValue("https://www.google.com/")); 101 new base::StringValue("https://www.google.com/"));
108 SetUserSelectedDefaultSearchProvider("{google:baseURL}"); 102 SetUserSelectedDefaultSearchProvider("{google:baseURL}");
109 instant_service_ = InstantServiceFactory::GetForProfile(profile()); 103 instant_service_ = InstantServiceFactory::GetForProfile(profile());
110 } 104 }
OLDNEW
« no previous file with comments | « chrome/browser/search/instant_unittest_base.h ('k') | chrome/browser/search_engines/default_search_pref_migration_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698