| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_engines/template_url_service_test_util.h" | 5 #include "chrome/browser/search_engines/template_url_service_test_util.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/scoped_temp_dir.h" | 9 #include "base/scoped_temp_dir.h" |
| 10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| 11 #include "chrome/browser/search_engines/template_url.h" | 11 #include "chrome/browser/search_engines/template_url.h" |
| 12 #include "chrome/browser/search_engines/template_url_service.h" | 12 #include "chrome/browser/search_engines/template_url_service.h" |
| 13 #include "chrome/browser/search_engines/template_url_service_factory.h" | 13 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 14 #include "chrome/common/chrome_notification_types.h" |
| 14 #include "chrome/test/testing_profile.h" | 15 #include "chrome/test/testing_profile.h" |
| 15 #include "content/common/notification_service.h" | 16 #include "content/common/notification_service.h" |
| 16 #include "content/common/notification_type.h" | |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 // A Task used to coordinate when the database has finished processing | 21 // A Task used to coordinate when the database has finished processing |
| 22 // requests. See note in BlockTillServiceProcessesRequests for details. | 22 // requests. See note in BlockTillServiceProcessesRequests for details. |
| 23 // | 23 // |
| 24 // When Run() schedules a QuitTask on the message loop it was created with. | 24 // When Run() schedules a QuitTask on the message loop it was created with. |
| 25 class QuitTask2 : public Task { | 25 class QuitTask2 : public Task { |
| 26 public: | 26 public: |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 } | 220 } |
| 221 | 221 |
| 222 string16 TemplateURLServiceTestUtil::GetAndClearSearchTerm() { | 222 string16 TemplateURLServiceTestUtil::GetAndClearSearchTerm() { |
| 223 return | 223 return |
| 224 static_cast<TestingTemplateURLService*>(model())->GetAndClearSearchTerm(); | 224 static_cast<TestingTemplateURLService*>(model())->GetAndClearSearchTerm(); |
| 225 } | 225 } |
| 226 | 226 |
| 227 void TemplateURLServiceTestUtil::SetGoogleBaseURL( | 227 void TemplateURLServiceTestUtil::SetGoogleBaseURL( |
| 228 const std::string& base_url) const { | 228 const std::string& base_url) const { |
| 229 TemplateURLRef::SetGoogleBaseURL(new std::string(base_url)); | 229 TemplateURLRef::SetGoogleBaseURL(new std::string(base_url)); |
| 230 NotificationService::current()->Notify(NotificationType::GOOGLE_URL_UPDATED, | 230 NotificationService::current()->Notify( |
| 231 NotificationService::AllSources(), | 231 chrome::NOTIFICATION_GOOGLE_URL_UPDATED, |
| 232 NotificationService::NoDetails()); | 232 NotificationService::AllSources(), |
| 233 NotificationService::NoDetails()); |
| 233 } | 234 } |
| 234 | 235 |
| 235 WebDataService* TemplateURLServiceTestUtil::GetWebDataService() { | 236 WebDataService* TemplateURLServiceTestUtil::GetWebDataService() { |
| 236 return profile_->GetWebDataService(Profile::EXPLICIT_ACCESS); | 237 return profile_->GetWebDataService(Profile::EXPLICIT_ACCESS); |
| 237 } | 238 } |
| 238 | 239 |
| 239 TemplateURLService* TemplateURLServiceTestUtil::model() const { | 240 TemplateURLService* TemplateURLServiceTestUtil::model() const { |
| 240 return TemplateURLServiceFactory::GetForProfile(profile()); | 241 return TemplateURLServiceFactory::GetForProfile(profile()); |
| 241 } | 242 } |
| 242 | 243 |
| 243 TestingProfile* TemplateURLServiceTestUtil::profile() const { | 244 TestingProfile* TemplateURLServiceTestUtil::profile() const { |
| 244 return profile_.get(); | 245 return profile_.get(); |
| 245 } | 246 } |
| 246 | 247 |
| 247 void TemplateURLServiceTestUtil::StartIOThread() { | 248 void TemplateURLServiceTestUtil::StartIOThread() { |
| 248 profile_->StartIOThread(); | 249 profile_->StartIOThread(); |
| 249 } | 250 } |
| OLD | NEW |