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

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

Issue 287103002: Introduce ability to register callback with GoogleURLTracker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Response to review 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/strings/utf_string_conversions.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"
19 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
20 #include "chrome/test/base/browser_with_test_window_test.h" 20 #include "chrome/test/base/browser_with_test_window_test.h"
21 #include "chrome/test/base/testing_pref_service_syncable.h" 21 #include "chrome/test/base/testing_pref_service_syncable.h"
22 #include "chrome/test/base/ui_test_utils.h" 22 #include "chrome/test/base/ui_test_utils.h"
23 #include "components/variations/entropy_provider.h" 23 #include "components/variations/entropy_provider.h"
24 #include "content/public/browser/notification_details.h"
25 #include "content/public/browser/notification_service.h"
26 #include "content/public/browser/notification_source.h"
27 24
28 InstantUnitTestBase::InstantUnitTestBase() { 25 InstantUnitTestBase::InstantUnitTestBase() {
29 field_trial_list_.reset(new base::FieldTrialList( 26 field_trial_list_.reset(new base::FieldTrialList(
30 new metrics::SHA1EntropyProvider("42"))); 27 new metrics::SHA1EntropyProvider("42")));
31 } 28 }
32 29
33 InstantUnitTestBase::~InstantUnitTestBase() { 30 InstantUnitTestBase::~InstantUnitTestBase() {
34 } 31 }
35 32
36 void InstantUnitTestBase::SetUp() { 33 void InstantUnitTestBase::SetUp() {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 } 65 }
69 66
70 void InstantUnitTestBase::NotifyGoogleBaseURLUpdate( 67 void InstantUnitTestBase::NotifyGoogleBaseURLUpdate(
71 const std::string& new_google_base_url) { 68 const std::string& new_google_base_url) {
72 // GoogleURLTracker is not created in tests. 69 // GoogleURLTracker is not created in tests.
73 // (See GoogleURLTrackerFactory::ServiceIsNULLWhileTesting()) 70 // (See GoogleURLTrackerFactory::ServiceIsNULLWhileTesting())
74 // For determining google:baseURL for NTP, the following is used: 71 // For determining google:baseURL for NTP, the following is used:
75 // UIThreadSearchTermsData::GoogleBaseURLValue() 72 // UIThreadSearchTermsData::GoogleBaseURLValue()
76 // For simulating test behavior, this is overridden below. 73 // For simulating test behavior, this is overridden below.
77 UIThreadSearchTermsData::SetGoogleBaseURL(new_google_base_url); 74 UIThreadSearchTermsData::SetGoogleBaseURL(new_google_base_url);
78 GoogleURLTracker::UpdatedDetails details(GURL("https://www.google.com/"), 75 TemplateURLServiceFactory::GetForProfile(profile())->OnGoogleURLUpdated(
79 GURL(new_google_base_url)); 76 GURL("https://www.google.com"), GURL(new_google_base_url));
80 content::NotificationService::current()->Notify(
81 chrome::NOTIFICATION_GOOGLE_URL_UPDATED,
82 content::Source<Profile>(profile()->GetOriginalProfile()),
83 content::Details<GoogleURLTracker::UpdatedDetails>(&details));
84 } 77 }
85 78
86 bool InstantUnitTestBase::IsInstantServiceObserver( 79 bool InstantUnitTestBase::IsInstantServiceObserver(
87 InstantServiceObserver* observer) { 80 InstantServiceObserver* observer) {
88 return instant_service_->observers_.HasObserver(observer); 81 return instant_service_->observers_.HasObserver(observer);
89 } 82 }
90 83
91 TestingProfile* InstantUnitTestBase::CreateProfile() { 84 TestingProfile* InstantUnitTestBase::CreateProfile() {
92 TestingProfile* profile = BrowserWithTestWindowTest::CreateProfile(); 85 TestingProfile* profile = BrowserWithTestWindowTest::CreateProfile();
93 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( 86 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
94 profile, &TemplateURLServiceFactory::BuildInstanceFor); 87 profile, &TemplateURLServiceFactory::BuildInstanceFor);
95 return profile; 88 return profile;
96 } 89 }
97 90
98 void InstantUnitTestBase::SetUpHelper() { 91 void InstantUnitTestBase::SetUpHelper() {
99 BrowserWithTestWindowTest::SetUp(); 92 BrowserWithTestWindowTest::SetUp();
100 93
101 template_url_service_ = TemplateURLServiceFactory::GetForProfile(profile()); 94 template_url_service_ = TemplateURLServiceFactory::GetForProfile(profile());
102 ui_test_utils::WaitForTemplateURLServiceToLoad(template_url_service_); 95 ui_test_utils::WaitForTemplateURLServiceToLoad(template_url_service_);
103 96
104 UIThreadSearchTermsData::SetGoogleBaseURL("https://www.google.com/"); 97 UIThreadSearchTermsData::SetGoogleBaseURL("https://www.google.com/");
105 TestingPrefServiceSyncable* pref_service = profile()->GetTestingPrefService(); 98 TestingPrefServiceSyncable* pref_service = profile()->GetTestingPrefService();
106 pref_service->SetUserPref(prefs::kLastPromptedGoogleURL, 99 pref_service->SetUserPref(prefs::kLastPromptedGoogleURL,
107 new base::StringValue("https://www.google.com/")); 100 new base::StringValue("https://www.google.com/"));
108 SetUserSelectedDefaultSearchProvider("{google:baseURL}"); 101 SetUserSelectedDefaultSearchProvider("{google:baseURL}");
109 instant_service_ = InstantServiceFactory::GetForProfile(profile()); 102 instant_service_ = InstantServiceFactory::GetForProfile(profile());
110 } 103 }
OLDNEW
« no previous file with comments | « chrome/browser/google/google_url_tracker.cc ('k') | chrome/browser/search_engines/search_provider_install_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698