| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_factory_test_util.h
" | 5 #include "chrome/browser/search_engines/template_url_service_factory_test_util.h
" |
| 6 | 6 |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "chrome/browser/search_engines/template_url_service_factory.h" | 8 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 9 #include "chrome/test/base/testing_profile.h" | 9 #include "chrome/test/base/testing_profile.h" |
| 10 #include "components/search_engines/default_search_pref_test_util.h" | |
| 11 #include "components/search_engines/template_url_service.h" | 10 #include "components/search_engines/template_url_service.h" |
| 12 #include "components/sync_preferences/testing_pref_service_syncable.h" | 11 #include "components/sync_preferences/testing_pref_service_syncable.h" |
| 13 | 12 |
| 14 TemplateURLServiceFactoryTestUtil::TemplateURLServiceFactoryTestUtil( | 13 TemplateURLServiceFactoryTestUtil::TemplateURLServiceFactoryTestUtil( |
| 15 TestingProfile* profile) | 14 TestingProfile* profile) |
| 16 : profile_(profile) { | 15 : profile_(profile) { |
| 17 profile_->CreateWebDataService(); | 16 profile_->CreateWebDataService(); |
| 18 | 17 |
| 19 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 18 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
| 20 profile_, TemplateURLServiceFactory::BuildInstanceFor); | 19 profile_, TemplateURLServiceFactory::BuildInstanceFor); |
| 21 } | 20 } |
| 22 | 21 |
| 23 TemplateURLServiceFactoryTestUtil::~TemplateURLServiceFactoryTestUtil() { | 22 TemplateURLServiceFactoryTestUtil::~TemplateURLServiceFactoryTestUtil() { |
| 24 // Flush the message loop to make application verifiers happy. | 23 // Flush the message loop to make application verifiers happy. |
| 25 base::RunLoop().RunUntilIdle(); | 24 base::RunLoop().RunUntilIdle(); |
| 26 } | 25 } |
| 27 | 26 |
| 28 void TemplateURLServiceFactoryTestUtil::VerifyLoad() { | 27 void TemplateURLServiceFactoryTestUtil::VerifyLoad() { |
| 29 model()->Load(); | 28 model()->Load(); |
| 30 base::RunLoop().RunUntilIdle(); | 29 base::RunLoop().RunUntilIdle(); |
| 31 } | 30 } |
| 32 | 31 |
| 33 void TemplateURLServiceFactoryTestUtil::SetManagedDefaultSearchPreferences( | |
| 34 bool enabled, | |
| 35 const std::string& name, | |
| 36 const std::string& keyword, | |
| 37 const std::string& search_url, | |
| 38 const std::string& suggest_url, | |
| 39 const std::string& icon_url, | |
| 40 const std::string& encodings, | |
| 41 const std::string& alternate_url, | |
| 42 const std::string& search_terms_replacement_key) { | |
| 43 DefaultSearchPrefTestUtil::SetManagedPref( | |
| 44 profile_->GetTestingPrefService(), | |
| 45 enabled, name, keyword, search_url, suggest_url, icon_url, encodings, | |
| 46 alternate_url, search_terms_replacement_key); | |
| 47 } | |
| 48 | |
| 49 void | |
| 50 TemplateURLServiceFactoryTestUtil::RemoveManagedDefaultSearchPreferences() { | |
| 51 DefaultSearchPrefTestUtil::RemoveManagedPref( | |
| 52 profile_->GetTestingPrefService()); | |
| 53 } | |
| 54 | |
| 55 TemplateURLService* TemplateURLServiceFactoryTestUtil::model() const { | 32 TemplateURLService* TemplateURLServiceFactoryTestUtil::model() const { |
| 56 return TemplateURLServiceFactory::GetForProfile(profile_); | 33 return TemplateURLServiceFactory::GetForProfile(profile_); |
| 57 } | 34 } |
| OLD | NEW |