OLD | NEW |
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 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 // GoogleURLTracker is not created in tests. | 71 // GoogleURLTracker is not created in tests. |
72 // (See GoogleURLTrackerFactory::ServiceIsNULLWhileTesting()) | 72 // (See GoogleURLTrackerFactory::ServiceIsNULLWhileTesting()) |
73 // For determining google:baseURL for NTP, the following is used: | 73 // For determining google:baseURL for NTP, the following is used: |
74 // UIThreadSearchTermsData::GoogleBaseURLValue() | 74 // UIThreadSearchTermsData::GoogleBaseURLValue() |
75 // For simulating test behavior, this is overridden below. | 75 // For simulating test behavior, this is overridden below. |
76 UIThreadSearchTermsData::SetGoogleBaseURL(new_google_base_url); | 76 UIThreadSearchTermsData::SetGoogleBaseURL(new_google_base_url); |
77 TemplateURLServiceFactory::GetForProfile(profile())->GoogleBaseURLChanged(); | 77 TemplateURLServiceFactory::GetForProfile(profile())->GoogleBaseURLChanged(); |
78 } | 78 } |
79 | 79 |
80 bool InstantUnitTestBase::IsInstantServiceObserver( | 80 bool InstantUnitTestBase::IsInstantServiceObserver( |
81 InstantServiceObserver* observer) { | 81 const InstantServiceObserver* observer) const { |
82 return instant_service_->observers_.HasObserver(observer); | 82 return instant_service_->observers_.HasObserver(observer); |
83 } | 83 } |
84 | 84 |
85 TestingProfile* InstantUnitTestBase::CreateProfile() { | 85 TestingProfile* InstantUnitTestBase::CreateProfile() { |
86 TestingProfile* profile = BrowserWithTestWindowTest::CreateProfile(); | 86 TestingProfile* profile = BrowserWithTestWindowTest::CreateProfile(); |
87 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 87 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
88 profile, &TemplateURLServiceFactory::BuildInstanceFor); | 88 profile, &TemplateURLServiceFactory::BuildInstanceFor); |
89 return profile; | 89 return profile; |
90 } | 90 } |
91 | 91 |
92 void InstantUnitTestBase::SetUpHelper() { | 92 void InstantUnitTestBase::SetUpHelper() { |
93 BrowserWithTestWindowTest::SetUp(); | 93 BrowserWithTestWindowTest::SetUp(); |
94 | 94 |
95 template_url_service_ = TemplateURLServiceFactory::GetForProfile(profile()); | 95 template_url_service_ = TemplateURLServiceFactory::GetForProfile(profile()); |
96 ui_test_utils::WaitForTemplateURLServiceToLoad(template_url_service_); | 96 ui_test_utils::WaitForTemplateURLServiceToLoad(template_url_service_); |
97 | 97 |
98 UIThreadSearchTermsData::SetGoogleBaseURL("https://www.google.com/"); | 98 UIThreadSearchTermsData::SetGoogleBaseURL("https://www.google.com/"); |
99 TestingPrefServiceSyncable* pref_service = profile()->GetTestingPrefService(); | 99 TestingPrefServiceSyncable* pref_service = profile()->GetTestingPrefService(); |
100 pref_service->SetUserPref(prefs::kLastPromptedGoogleURL, | 100 pref_service->SetUserPref(prefs::kLastPromptedGoogleURL, |
101 new base::StringValue("https://www.google.com/")); | 101 new base::StringValue("https://www.google.com/")); |
102 SetUserSelectedDefaultSearchProvider("{google:baseURL}"); | 102 SetUserSelectedDefaultSearchProvider("{google:baseURL}"); |
103 instant_service_ = InstantServiceFactory::GetForProfile(profile()); | 103 instant_service_ = InstantServiceFactory::GetForProfile(profile()); |
104 } | 104 } |
OLD | NEW |